using System; using Hazel; using UnityEngine; namespace InnerNet { public abstract class InnerNetObject : MonoBehaviour, IComparable { public bool AmOwner { get { return this.OwnerId == AmongUsClient.Instance.ClientId; } } public uint SpawnId; public uint NetId; public uint DirtyBits; public SpawnFlags SpawnFlags; public SendOption sendMode = SendOption.Reliable; public int OwnerId; protected bool DespawnOnDestroy = true; public void Despawn() { UnityEngine.Object.Destroy(base.gameObject); AmongUsClient.Instance.Despawn(this); } public virtual void OnDestroy() { if (AmongUsClient.Instance && this.NetId != 4294967295U) { if (this.DespawnOnDestroy && this.AmOwner) { AmongUsClient.Instance.Despawn(this); return; } AmongUsClient.Instance.RemoveNetObject(this); } } public abstract void HandleRpc(byte callId, MessageReader reader); public abstract bool Serialize(MessageWriter writer, bool initialState); public abstract void Deserialize(MessageReader reader, bool initialState); public int CompareTo(InnerNetObject other) { if (this.NetId > other.NetId) { return 1; } if (this.NetId < other.NetId) { return -1; } return 0; } protected void SetDirtyBit(uint val) { this.DirtyBits |= val; } } }