Class AbstractItem
The base class for all items.
Inheritance
Inherited Members
Namespace: ItemChanger
Assembly: ItemChanger.dll
Syntax
public abstract class AbstractItem : TaggableObject
Fields
| Improve this Doc View Sourcename
The name of the item. Item names are not guaranteed to be unique.
Declaration
public string name
Field Value
Type | Description |
---|---|
System.String |
UIDef
The UIDef associated to an item. GetResolvedUIDef() is preferred in most cases, since it accounts for the hooks which may modify the item.
Declaration
public UIDef UIDef
Field Value
Type | Description |
---|---|
UIDef |
Methods
| Improve this Doc View SourceClone()
Returns a deep clone of the current item.
Declaration
public virtual AbstractItem Clone()
Returns
Type | Description |
---|---|
AbstractItem |
GetPreferredContainer()
Used by some placements to decide what container to use for the item. A value of "Unknown" is ignored, and usually leads to a shiny item by default.
Declaration
public virtual string GetPreferredContainer()
Returns
Type | Description |
---|---|
System.String |
GetPreviewName(AbstractPlacement)
Declaration
public string GetPreviewName(AbstractPlacement placement = null)
Parameters
Type | Name | Description |
---|---|---|
AbstractPlacement | placement |
Returns
Type | Description |
---|---|
System.String |
GetPreviewSprite(AbstractPlacement)
Declaration
public Sprite? GetPreviewSprite(AbstractPlacement placement = null)
Parameters
Type | Name | Description |
---|---|---|
AbstractPlacement | placement |
Returns
Type | Description |
---|---|
System.Nullable<Sprite> |
GetResolvedUIDef(AbstractPlacement)
Returns the UIDef of the item yielded after all of the events for modifying items.
Declaration
public UIDef GetResolvedUIDef(AbstractPlacement placement = null)
Parameters
Type | Name | Description |
---|---|---|
AbstractPlacement | placement |
Returns
Type | Description |
---|---|
UIDef |
Give(AbstractPlacement, GiveInfo)
The method called to give an item.
Declaration
public void Give(AbstractPlacement placement, GiveInfo info)
Parameters
Type | Name | Description |
---|---|---|
AbstractPlacement | placement | |
GiveInfo | info |
GiveEarly(String)
Indicates that the item can be given early in a special way from the given container.
For example, SpawnGeoItem can be given early from Container.Chest by flinging geo directly from the chest.
Declaration
public virtual bool GiveEarly(string containerType)
Parameters
Type | Name | Description |
---|---|---|
System.String | containerType |
Returns
Type | Description |
---|---|
System.Boolean |
GiveImmediate(GiveInfo)
Specifies the effect of giving a particular item.
Declaration
public abstract void GiveImmediate(GiveInfo info)
Parameters
Type | Name | Description |
---|---|---|
GiveInfo | info |
IsObtained()
Returns whether the item is currently obtained. A value of true indicates the item is not eligible to be given.
Declaration
public bool IsObtained()
Returns
Type | Description |
---|---|
System.Boolean |
Load()
Called on each item tied to a placement when the save is created or resumed.
Execution order is (modules load -> placement tags load -> items load -> placements load)
Declaration
public void Load()
OnLoad()
Method allowing derived item classes to initialize and place hooks.
Declaration
protected virtual void OnLoad()
OnUnload()
Method allowing derived item classes to dispose hooks.
Declaration
protected virtual void OnUnload()
Redundant()
Method used to determine if a unique item should be replaced (i.e. duplicates, etc). No relation to ObtainState.
Declaration
public virtual bool Redundant()
Returns
Type | Description |
---|---|
System.Boolean |
RefreshObtained()
Marks the item as available to be given again. Used, for example, with persistent and semipersistent items.
Declaration
public void RefreshObtained()
ResolveItem(GiveEventArgs)
Determines the item yielded after all of the events for modifying items, by acting in place on the GiveEventArgs.
Declaration
public virtual void ResolveItem(GiveEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
GiveEventArgs | args |
SetObtained()
Marks the item as obtained and no longer eligible to be given. Called by Give().
Declaration
public void SetObtained()
Unload()
Called on each item tied to a placement upon returning to the main menu.
Execution order is (modules unload -> placement tags unload -> items unload -> placements unload)
Declaration
public void Unload()
WasEverObtained()
Returns whether the item has ever been obtained, regardless of whether it is currently refreshed.
Declaration
public bool WasEverObtained()
Returns
Type | Description |
---|---|
System.Boolean |
Events
| Improve this Doc View SourceAfterGive
Event invoked by this item just after GiveImmediate(), giving access to the final give parameters.
Declaration
public event Action<ReadOnlyGiveEventArgs>? AfterGive
Event Type
Type | Description |
---|---|
System.Nullable<Action<ReadOnlyGiveEventArgs>> |
AfterGiveGlobal
Event invoked by each item just after GiveImmediate(), giving access to the final give parameters.
Declaration
public static event Action<ReadOnlyGiveEventArgs>? AfterGiveGlobal
Event Type
Type | Description |
---|---|
System.Nullable<Action<ReadOnlyGiveEventArgs>> |
BeforeGive
Event invoked by this item at the start of Give(), giving access to the initial give parameters.
Declaration
public event Action<ReadOnlyGiveEventArgs>? BeforeGive
Event Type
Type | Description |
---|---|
System.Nullable<Action<ReadOnlyGiveEventArgs>> |
BeforeGiveGlobal
Event invoked by each item at the start of Give(), giving access to the initial give parameters.
Declaration
public static event Action<ReadOnlyGiveEventArgs>? BeforeGiveGlobal
Event Type
Type | Description |
---|---|
System.Nullable<Action<ReadOnlyGiveEventArgs>> |
ModifyItem
Event invoked by this item during Give() to allow modification of any of the give parameters, including the item given.
Declaration
public event Action<GiveEventArgs>? ModifyItem
Event Type
Type | Description |
---|---|
System.Nullable<Action<GiveEventArgs>> |
ModifyItemGlobal
Event invoked by each item during Give() to allow modification of any of the give parameters, including the item given.
Declaration
public static event Action<GiveEventArgs>? ModifyItemGlobal
Event Type
Type | Description |
---|---|
System.Nullable<Action<GiveEventArgs>> |
ModifyRedundantItem
Event invoked by this item after the ModifyItem events, if the resulting item is null or redundant.
Declaration
public event Action<GiveEventArgs>? ModifyRedundantItem
Event Type
Type | Description |
---|---|
System.Nullable<Action<GiveEventArgs>> |
ModifyRedundantItemGlobal
Event invoked by each item after the ModifyItem events, if the resulting item is null or redundant.
Declaration
public static event Action<GiveEventArgs>? ModifyRedundantItemGlobal
Event Type
Type | Description |
---|---|
System.Nullable<Action<GiveEventArgs>> |
OnGive
Event invoked by this item just before GiveImmediate(), giving access to the final give parameters.
Declaration
public event Action<ReadOnlyGiveEventArgs>? OnGive
Event Type
Type | Description |
---|---|
System.Nullable<Action<ReadOnlyGiveEventArgs>> |
OnGiveGlobal
Event invoked by each item just before GiveImmediate(), giving access to the final give parameters.
Declaration
public static event Action<ReadOnlyGiveEventArgs>? OnGiveGlobal
Event Type
Type | Description |
---|---|
System.Nullable<Action<ReadOnlyGiveEventArgs>> |