public override void Process() { LoadNetworkObject(DespawnedObject); //call all the hooks! if (NetworkObject == null) { Logger.LogTraceFormat("Not calling client side despawn hooks, object no longer exists", Category.Inventory); } else { var comps = NetworkObject.GetComponents <IClientDespawn>(); var despawnInfo = ClientDespawnInfo.Default(); if (comps != null) { foreach (var comp in comps) { comp.OnDespawnClient(despawnInfo); } } } }
/// <summary> /// Despawn the object locally, on this client only. Despawning removes an /// object from the game, but may not necessarilly destroy it completely - it may end up back in the /// object pool to be later reused. /// </summary> /// <param name="info"></param> /// <returns></returns> public static DespawnResult Client(DespawnInfo info) { if (info == null) { Logger.LogError("Cannot despawn - info is null", Category.ItemSpawn); return(DespawnResult.Fail(info)); } //fire despawn hooks var hooks = info.GameObject.GetComponents <IClientDespawn>(); if (hooks != null) { foreach (var hook in hooks) { hook.OnDespawnClient(ClientDespawnInfo.Default()); } } Spawn._AddToPool(info.GameObject); info.GameObject.SetActive(false); return(DespawnResult.Single(info)); }
public void OnDespawnClient(ClientDespawnInfo info) { //free the slots ItemSlot.Free(this); }