Skip to main content

ModifiableStaticObject

A class in Root.Township, Alta.Networking.

Part of the static world that can be swapped between an original and a modified look (a cleared rock, opened passage and so on). Its state comes from ModifiableStaticManager by hash.

Constructors​

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

Fields​

MemberWhat it is
protected bool isModifiedWhether it's currently in its modified state.
7 private and internal fields
MemberWhat it is
private bool canReturnIf true the object can go back to its original state, so Modify keeps the original objects instead of destroying them.
private int hashBacking field for Hash, set in the editor by OnValidate.
private ModifiableStaticEvent modifiedEventBacking field for ModifiedEvent, run when the object is modified live.
private GameObject[] modifiedObjectsObjects turned on when modified and off when unmodified.
private ModifiableStaticEvent modifyInstantEvent run instead of modifiedEvent when the object starts already modified (no live change).
private GameObject[] originalObjectsObjects shown before the change. Destroyed on modify unless canReturn is set.
private ModifiableStaticEvent unModifiedEventBacking field for UnModifiedEvent.

Properties​

MemberWhat it is
uint Hash { get; set; }Id used to look up and set its state in ModifiableStaticManager.
ModifiableStaticEvent ModifiedEvent { get; }Raised when it changes to modified while running.
ModifiableStaticEvent UnModifiedEvent { get; }Raised when it changes back to the original.

Methods​

MemberWhat it is
void Modify(bool hasEvents = true)Shows the modified objects. The originals are destroyed unless it can return, in which case they stay active.
void UnModify(bool hasEvents = true)Shows the original objects and hides the modified ones.
protected virtual void OnValidate()Editor: makes sure it has a hash.
protected virtual void Start()Reads its state from the manager and applies it without events.
5 private and internal methods
MemberWhat it is
private void IChangeWithChunking.BeforeSaving()Does nothing.
private void CheckChange(uint objectHash, bool isModified)Handler for ModifiableStaticManager.ObjectChanged: if the hash is this object's, modifies or unmodifies it with events.
private void IChangeWithChunking.Loaded()Does nothing.
private void OnDisable()Stops listening for changes and removes the object from ModifiableStaticManager.
private void OnEnable()Listens for changes and registers the object with ModifiableStaticManager by hash.

Used in​

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