Skip to main content

Enchantable

A class in Root.Township, Alta.Enchantments.

Component on an item that holds its enchantments and syncs their trigger and effect messages to clients. The server adds the prefab's initial enchantments; loading ignores the saved list.

Constructors​

MemberWhat it is
Enchantable()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

9 private and internal fields
MemberWhat it is
private IEnchantmentEffectApplication effectApplicationPrivate: the effect whose message is being sent or received.
private Dictionary<Enchantment, EnchantmentApplication> enchantmentsPrivate: the active enchantments and their applications.
private Enchantment[] initialEnchantments added when the server spawns the item. Also filled with the current ones when saving.
private Pickup pickupBacking field for Pickup.
private int sendingEffectIndexPrivate: index of the effect in the message, or -1.
private Enchantment sendingEnchantmentPrivate: the enchantment the message is for.
private int sendingTriggerIndexPrivate: index of the trigger in the message, or -1.
private MethodSync syncMessagePrivate: message used by SendTriggerMessage and SendEffectMessage.
private IEnchantmentTriggerApplication triggerApplicationPrivate: the trigger whose message is being sent or received.

Properties​

MemberWhat it is
Pickup Pickup { get; }The item's pickup.

Methods​

MemberWhat it is
EnchantmentApplication Add(Enchantment enchantment)Adds an enchantment and returns its application, or null if the item already has it.
EnchantmentApplication Get(Enchantment enchantment)Returns the application of an enchantment on this item, or null.
override void Initialize()Creates the enchantment list and the sync message.
override void InitializeAsServer(SpawnData spawnData)Server: adds the initial enchantments.
void SendEffectMessage(IEnchantmentEffectApplication effectApplication)Sends one effect application's message to players in the chunk.
void SendTriggerMessage(IEnchantmentTriggerApplication triggerApplication)Sends one trigger application's message to players in the chunk.
2 private and internal methods
MemberWhat it is
private void EnchantmentRemoved(EnchantmentApplication application)Private: drops an enchantment from the list when its application is removed.
private void SyncEffect(IPlayer player, Stream stream)Private: sends or receives one enchantment trigger or effect message, by enchantment and index, and passes the stream to it.

Used in​

Members of other types that take, return or hold a Enchantable: