> For the complete documentation index, see [llms.txt](https://infinitypbr.gitbook.io/magic-pig-games/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://infinitypbr.gitbook.io/magic-pig-games/game-modules-4/module-documentation/items/gameitemattribute.cs.md).

# GameItemAttribute.cs

v4.0

The `ItemAttribute` Scriptable Object will not be serialized at runtime, and is intended to store permenent data, rather than mutable data that may change during the game. The `GameItemAttribute` is used for runtime use instead. It implements `IHaveStats`.

{% code title="GameItemAttribute.cs" %}

```csharp
// Owner will be the owner of the GameItemObject this is attached to. If it is not, 
// then owner will be the GameItemAttributeList this is in. If it is not in a
// List, then it will be the value of _owner. The Owner is the IHaveStats objects
// which is affected by the stat effects on these objects.
public IHaveStats Owner => ParentList == null ? _owner : ParentList.Owner;
public ItemAttribute Parent() // Get the ItemAttribute scriptable object
public GameItemObject ParentItemObject // The GameItemObject this is attached to
public GameItemAttributeList ParentList // the List this is in
public string Uid() // Uid of the parent
public virtual string GameId(bool forceNew = false) // In game unique ID of this GameItemObject

public int NameOrder // Name order for this attribute
public string HumanName // Human name
```

{% endcode %}

## Constructor

Pass in the `ItemAttribute` and the `owner`. The `owner` can be `null`, but is required if this `ItemAttribute` is meant to affect the `stats` of the `owner`. `ItemAttribute` can be `null` as well, if you are creating a container for a future `ItemAttribute`. Generally that is unlikely I think.

<pre class="language-csharp"><code class="lang-csharp">public GameItemAttribute(ItemAttribute parent, IHaveStats newOwner = null)
{
<strong>    _parent = parent; // v3.6
</strong>    SetUid(parent.Uid()); // v3.6 -- set the uid with this method now
    objectName = parent.objectName;
    objectType = parent.objectType;
    dictionaries = parent.dictionaries.Clone(); // Clone the dictionaries object, so we don't overwrite our Scriptable Object data!

    GameId();
    SetOwner(newOwner); // Will set null if value is default. Owner is first taken from Parents before reverting to _owner
}
</code></pre>

## Methods

```csharp
// Returns true if it is compatible with the provided uid or ItemAttribute
public bool CompatibleWith(string itemAttributeUid)
public bool CompatibleWith(ItemAttribute itemAttribute)
public bool CompatibleWith(GameItemAttribute gameItemAttribute)

// Returns true if it is not compatible with the provided uid or ItemAttribute
public bool IncompatibleWith(string itemAttributeUid)
public bool IncompatibleWith(ItemAttribute itemAttribute)
public bool IncompatibleWith(GameItemAttribute gameItemAttribute) 

// Returns true if the comparison is correct
public bool IsHigherLevelThan(GameItemAttribute other) => Level > other.Level;
public bool IsLowerLevelThan(GameItemAttribute other) => Level < other.Level;
public bool IsSameLevelAs(GameItemAttribute other) => Level == other.Level;

public bool IsHigherLevelThan(ItemAttribute other) => Level > other.level;
public bool IsLowerLevelThan(ItemAttribute other) => Level < other.level;
public bool IsSameLevelAs(ItemAttribute other) => Level == other.level;
```

#### Additional Methods

```csharp
// Sets the Owners stats dirty, any stat that the Owner has which are affected by this
// GameItemAttribute.
public void SetDirty(bool dirtyValue = true)
```

## Properties

```csharp
public int Level => Parent().level;
public bool Distinct => Parent().distinct;
public bool ReplaceOthers => Parent().replaceOthers;
public bool AffectsActor => Parent().affectsActor;
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://infinitypbr.gitbook.io/magic-pig-games/game-modules-4/module-documentation/items/gameitemattribute.cs.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
