public void RpcRemoveUnit(uint unitNetId) { NetworkIdentity identity; if (NetworkIdentity.spawned.TryGetValue(unitNetId, out identity)) { UnitDispatcher unit = identity.GetComponent <UnitDispatcher>(); RemoveUnit(unit); } }
/// <summary> /// Call this to notify when a unit is destroyed /// or otherwise removed from the platoon. /// </summary> public void RemoveUnit(UnitDispatcher unit) { Units.Remove(unit); GhostPlatoon.RemoveOneGhostUnit(); if (Units.Count == 0) { Destroy(gameObject); MatchSession.Current.RegisterPlatoonDeath(this); } }
public void RpcEstablishReferences( uint ghostPlatoonNetId, uint[] unitNetIds) { NetworkIdentity identity; if (NetworkIdentity.spawned.TryGetValue(ghostPlatoonNetId, out identity)) { GhostPlatoon = identity.gameObject.GetComponent <GhostPlatoonBehaviour>(); } // Also find, augment and link to the units: foreach (uint unitNetId in unitNetIds) { if (NetworkIdentity.spawned.TryGetValue(unitNetId, out identity)) { UnitDispatcher unit = identity.GetComponent <UnitDispatcher>(); AddSingleExistingUnit(unit); } } }
/// <summary> /// Meant to put already existing units into the platoon /// (such as when merging or splitting platoons). /// </summary> /// <param name="realUnit"></param> public void AddSingleExistingUnit(UnitDispatcher realUnit) { GhostPlatoon.AddSingleUnit(); Units.Add(realUnit); }