public void OnBalanceAttachmentSpawnerEnter(GameObject obj, BalanceAttachmentSpawner bs) { if (Time.time - bs.m_LastSpawnObjectTime < BalanceSystem.s_BalanceSpawnerCooldown) { return; } BalanceSystemObject objectInPos = this.m_QuadTree.GetObjectInPos(obj.transform.position); if (objectInPos != null) { if (Time.time - objectInPos.m_LastSpawnObjectTime < BalanceSystem.s_BalanceSpawnerCooldown) { return; } if (objectInPos.m_GameObject == null) { if (bs.m_StaticSystem) { bs.Attach(objectInPos.m_ItemID, objectInPos.m_ChildNum, objectInPos.m_ActiveChildrenMask); objectInPos.m_LastSpawnObjectTime = Time.time; } else { this.TryToAttach(bs, objectInPos); } } } else { this.TryToAttach(bs, null); } }
public void OnBalanceAttachmentSpawnerEnter(GameObject obj, BalanceAttachmentSpawner bs) { if (Time.time - bs.m_LastSpawnObjectTime < BalanceSystem20.s_BalanceSpawnerCooldown && !this.IsDeserializingNetworkData()) { return; } BalanceSystemObject objectInPos = this.m_QuadTree.GetObjectInPos(obj.transform.position); if (objectInPos != null) { if (objectInPos.m_GameObject == null) { if (!bs.m_StaticSystem) { this.TryToAttach(bs, objectInPos); return; } if (!objectInPos.m_AllChildrenDestroyed) { Item item = bs.Attach(objectInPos.m_ItemID, objectInPos.m_ChildNum, objectInPos.m_ActiveChildrenMask); objectInPos.m_GameObject = item.gameObject; objectInPos.m_BalanceSpawner = bs.gameObject; this.m_ObjectsInArea[objectInPos.m_Group.name].Add(objectInPos); return; } if (Time.time - objectInPos.m_LastSpawnObjectTime > BalanceSystem20.s_BalanceSpawnerCooldown) { this.TryToAttach(bs, objectInPos); return; } } else if (!this.m_ObjectsInArea[objectInPos.m_Group.name].Contains(objectInPos)) { this.m_ObjectsInArea[objectInPos.m_Group.name].Add(objectInPos); return; } } else { if (bs != null && (Time.time - bs.m_LastSpawnObjectTime < BalanceSystem20.s_BalanceSpawnerCooldown || Time.time - bs.m_LastNoSpawnObjectTime < BalanceSystem20.s_BalanceSpawnerNoSpawnCooldown)) { return; } if (this.IsDeserializingNetworkData()) { return; } this.TryToAttach(bs, null); } }
private void TryToAttach(BalanceAttachmentSpawner bs, BalanceSystemObject bso) { string empty = string.Empty; BSItemData objectToAttach = this.GetObjectToAttach(ref empty, bs.m_ItemIDNamesList); if (objectToAttach != null) { int childNum = -1; GameObject gameObject = bs.TryToAttach(objectToAttach.m_ItemID, out childNum); if (gameObject != null) { objectToAttach.m_LastSpawnTime = Time.time; BalanceSystemObject balanceSystemObject = (bso != null) ? bso : new BalanceSystemObject(); balanceSystemObject.m_Group = empty; balanceSystemObject.m_ChildNum = childNum; balanceSystemObject.m_ItemID = objectToAttach.m_ItemID; balanceSystemObject.m_BalanceSpawner = bs.gameObject; balanceSystemObject.m_GameObject = gameObject; balanceSystemObject.m_Position = bs.transform.position; this.m_ObjectsInArea[empty].Add(balanceSystemObject); this.m_QuadTree.InsertObject(balanceSystemObject); if (empty == "Sanity") { CJObject[] componentsInChildren = gameObject.GetComponentsInChildren <CJObject>(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].m_Hallucination = true; } } else { balanceSystemObject.m_LastSpawnObjectTime = Time.time; } } } }
private void TryToAttach(BalanceAttachmentSpawner bs, BalanceSystemObject bso) { if (this.IsDeserializingNetworkData() && bso != null) { Item item = bs.Attach(bso.m_ItemID, bso.m_ChildNum, bso.m_ActiveChildrenMask); if (item) { bso.m_GameObject = item.gameObject; return; } } else { string empty = string.Empty; BSItemData bsitemData = (bso != null) ? this.GetObjectToAttach(ref empty, new List <string> { EnumUtils <ItemID> .GetName(bso.m_ItemID) }) : this.GetObjectToAttach(ref empty, bs.m_ItemIDNamesList); if (bsitemData != null) { int childNum = -1; GameObject gameObject = bs.TryToAttach(bsitemData.m_ItemID, out childNum); if (gameObject != null) { this.OnObjectSpawned(bsitemData, bs); bsitemData.m_LastSpawnTime = Time.time; BalanceSystemObject balanceSystemObject = bso ?? new BalanceSystemObject(); balanceSystemObject.m_Group = this.m_Groups[empty]; balanceSystemObject.m_ChildNum = childNum; balanceSystemObject.m_ItemID = bsitemData.m_ItemID; balanceSystemObject.m_BalanceSpawner = bs.gameObject; balanceSystemObject.m_GameObject = gameObject; balanceSystemObject.m_Position = bs.transform.position; balanceSystemObject.m_AllChildrenDestroyed = false; this.m_ObjectsInArea[empty].Add(balanceSystemObject); this.m_QuadTree.InsertObject(balanceSystemObject); if (bso == null) { this.DetachActiveRigidbodies(gameObject); this.SetupActiveChildrenMask(gameObject, ref balanceSystemObject.m_ActiveChildrenMask); } else { this.ApplyActiveChildrenMask(balanceSystemObject); } if (empty == "Sanity") { CJObject[] componentsInChildren = gameObject.GetComponentsInChildren <CJObject>(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].m_Hallucination = true; } } else { balanceSystemObject.m_LastSpawnObjectTime = Time.time; } if (!this.IsDeserializingNetworkData()) { ReplicatedBalanceObjects.OnObjectChanged(balanceSystemObject); return; } } } else { bs.m_LastNoSpawnObjectTime = Time.time; } } }