public List <BalanceSystemObject> GetObjectsInRadius(Vector3 pos, float radius) { this.m_ObjectsInRadius.Clear(); Vector3 pos2 = pos; pos2.x -= radius; pos2.z -= radius; QuadTreeCellBalanceSystem cellAtPos = this.GetCellAtPos(pos2); Vector3 pos3 = pos; pos3.x += radius; pos3.z += radius; QuadTreeCellBalanceSystem cellAtPos2 = this.GetCellAtPos(pos3); for (int i = cellAtPos.m_X; i <= cellAtPos2.m_X; i++) { for (int j = cellAtPos.m_Y; j <= cellAtPos2.m_Y; j++) { QuadTreeCellBalanceSystem quadTreeCellBalanceSystem = this.m_Cells[i, j]; for (int k = 0; k < quadTreeCellBalanceSystem.m_Objects.Count; k++) { BalanceSystemObject balanceSystemObject = quadTreeCellBalanceSystem.m_Objects[k]; if (balanceSystemObject == null) { Debug.Log("Quad tree GetObjectsInRadius - obj is null : GameObject obj = cell.m_Objects[i];"); } if (balanceSystemObject != null && (balanceSystemObject.m_GameObject.transform.position - pos).magnitude < radius) { this.m_ObjectsInRadius.Add(balanceSystemObject); } } } } return(this.m_ObjectsInRadius); }
public void OnBalanceSpawnerEnter(GameObject spawner_obj, BalanceSpawner bs) { if (this.m_DisabledSpawnersQuadTree.GetObjectInPos(spawner_obj.transform.position)) { return; } BalanceSystemObject objectInPos = this.m_QuadTree.GetObjectInPos(spawner_obj.transform.position); if (objectInPos != null) { if (objectInPos.m_BalanceSpawner == null) { objectInPos.m_BalanceSpawner = spawner_obj; } if (objectInPos.m_ActiveChildrenMask != 0 && objectInPos.m_GameObject == null && objectInPos.m_ItemID != ItemID.None) { this.SpawnObject(spawner_obj, bs, objectInPos); } if (!this.m_ObjectsInArea[objectInPos.m_Group.name].Contains(objectInPos)) { this.m_ObjectsInArea[objectInPos.m_Group.name].Add(objectInPos); } return; } if (bs != null && (Time.time - bs.m_LastSpawnObjectTime < BalanceSystem20.s_BalanceSpawnerCooldown || Time.time - bs.m_LastNoSpawnObjectTime < BalanceSystem20.s_BalanceSpawnerNoSpawnCooldown) && !this.IsDeserializingNetworkData()) { return; } this.SpawnObject(spawner_obj, bs, null); }
public static void OnObjectDestroyed(BalanceSystemObject obj) { if (ReplicatedBalanceObjects.s_LocalReplicatedBalanceObjects != null) { ReplicatedBalanceObjects.s_LocalReplicatedBalanceObjects.StoreObjectDestroyed(obj); } }
public void InsertObject(BalanceSystemObject obj) { QuadTreeCellBalanceSystem cellAtPos = this.GetCellAtPos(obj.m_GameObject.transform.position); cellAtPos.m_Objects.Add(obj); this.m_ObjCellMap[obj] = cellAtPos; }
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 CopyReplValues(BalanceSystemObject obj) { this.m_Position = obj.m_Position; this.m_ItemID = obj.m_ItemID; this.m_ActiveChildrenMask = obj.m_ActiveChildrenMask; this.m_Group = obj.m_Group; }
private void StoreObjectDestroyed(BalanceSystemObject obj) { if (!ReplTools.IsPlayingAlone()) { this.m_ReplDestroyedBalanceObjects.Add(obj); this.ReplSetDirty(); } }
public void InsertObject(BalanceSystemObject obj, Vector3 position) { QuadTreeCellBalanceSystem cellAtPos = this.GetCellAtPos(position); if (!cellAtPos.m_Objects.Contains(obj)) { cellAtPos.m_Objects.Add(obj); } this.m_ObjCellMap[obj] = cellAtPos; }
private void ApplyActiveChildrenMask(BalanceSystemObject bso) { for (int i = 0; i < bso.m_GameObject.transform.childCount; i++) { Transform child = bso.m_GameObject.transform.GetChild(i); if ((bso.m_ActiveChildrenMask & 1 << i) == 0) { UnityEngine.Object.Destroy(child.gameObject); } } }
private void RemoveObjectFromArea(GameObject obj) { BalanceSystemObject objectInPos = this.m_QuadTree.GetObjectInPos(obj.transform.position); if (objectInPos != null) { foreach (string key in this.m_Groups.Keys) { this.m_ObjectsInArea[key].Remove(objectInPos); } } }
public void OnBalanceSpawnerEnter(GameObject obj, BalanceSpawner bs) { BalanceSystemObject objectInPos = this.m_QuadTree.GetObjectInPos(obj.transform.position); if (objectInPos == null) { if (bs != null && Time.time - bs.m_LastSpawnObjectTime < BalanceSystem.s_BalanceSpawnerCooldown) { return; } string empty = string.Empty; BSItemData objectToSpawn = this.GetObjectToSpawn(ref empty); GameObject gameObject = null; if (objectToSpawn != null) { gameObject = objectToSpawn.m_Prefab; } if (gameObject != null) { objectToSpawn.m_LastSpawnTime = Time.time; GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(gameObject, obj.transform.position, obj.transform.rotation); Item component = gameObject2.GetComponent <Item>(); if (component) { component.m_CanSave = false; } BalanceSystemObject balanceSystemObject = new BalanceSystemObject(); balanceSystemObject.m_GameObject = gameObject2; balanceSystemObject.m_Group = empty; balanceSystemObject.m_BalanceSpawner = bs.gameObject; this.m_QuadTree.InsertObject(balanceSystemObject); this.m_ObjectsInArea[empty].Add(balanceSystemObject); if (empty == "Sanity") { CJObject[] componentsInChildren = gameObject2.GetComponentsInChildren <CJObject>(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].m_Hallucination = true; } } else { bs.m_LastSpawnObjectTime = Time.time; } bs.m_LastCheckSpawnTime = Time.time; } } else { this.m_ObjectsInArea[objectInPos.m_Group].Add(objectInPos); } }
public void OnBalanceSystemObjectReplReceived(BalanceSystemObject readonly_temp_obj, bool destroyed = false) { BalanceSystemObject balanceSystemObject = this.m_QuadTree.GetObjectInPos(readonly_temp_obj.m_Position); if (destroyed) { if (balanceSystemObject != null && balanceSystemObject.m_GameObject != null) { balanceSystemObject.m_AllChildrenDestroyed = true; UnityEngine.Object.Destroy(balanceSystemObject.m_GameObject); return; } } else { if (balanceSystemObject != null) { int activeChildrenMask = balanceSystemObject.m_ActiveChildrenMask; if (readonly_temp_obj.m_ActiveChildrenMask != activeChildrenMask) { GameObject gameObject = balanceSystemObject.m_GameObject; if (gameObject != null) { for (int i = 0; i < gameObject.transform.childCount; i++) { GameObject gameObject2 = gameObject.transform.GetChild(i).gameObject; if (gameObject2.activeSelf) { bool flag = (activeChildrenMask & 1 << i) != 0; bool flag2 = (readonly_temp_obj.m_ActiveChildrenMask & 1 << i) != 0; if (flag != flag2 && !flag2) { UnityEngine.Object.Destroy(gameObject2); } } } } else { balanceSystemObject.CopyReplValues(readonly_temp_obj); } } this.SpawnObjectsIfNeeded(); return; } balanceSystemObject = new BalanceSystemObject(); balanceSystemObject.CopyReplValues(readonly_temp_obj); this.m_QuadTree.InsertObject(balanceSystemObject, balanceSystemObject.m_Position); this.SpawnObjectsIfNeeded(); } }
private void SpawnObjectsIfNeeded() { foreach (GameObject gameObject in this.m_CurrentTriggers) { if (gameObject != null) { BalanceSystemObject objectInPos = this.m_QuadTree.GetObjectInPos(gameObject.transform.position); if (objectInPos != null && objectInPos.m_GameObject == null) { this.OnObjectTriggerEnter(gameObject); } } } }
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); } }
public void RemoveObject(BalanceSystemObject go) { if (!this.m_ObjCellMap.ContainsKey(go)) { DebugUtils.Assert("[QuadTree:RemoveObject] Tree does not contains object - " + go.m_GameObject.name, true, DebugUtils.AssertType.Info); return; } QuadTreeCellBalanceSystem quadTreeCellBalanceSystem = null; if (this.m_ObjCellMap.TryGetValue(go, out quadTreeCellBalanceSystem)) { quadTreeCellBalanceSystem.RemoveObject(go); this.m_ObjCellMap.Remove(go); return; } DebugUtils.Assert(false, true); }
private BSItemData GetObjectToSpawn(ref string group, BalanceSystemObject bso = null) { group = string.Empty; if (bso != null && bso.m_ItemID != ItemID.None) { BSItemData bsitemData = null; foreach (string text in this.m_SpawnData.Keys) { if (!(text == "Sanity")) { for (int i = 0; i < this.m_SpawnData[text].Count; i++) { if (bso.m_ItemID == this.m_SpawnData[text][i].m_ItemID) { group = text; bsitemData = this.m_SpawnData[text][i]; break; } } } } if (bsitemData != null) { return(bsitemData); } } if (PlayerSanityModule.Get().m_ItemHallucinationsEnabled&& this.m_ObjectsInArea["Sanity"].Count < PlayerSanityModule.Get().GetWantedItemsHallucinationsCount()) { group = "Sanity"; return(this.GetRandomObject(this.m_SpawnData[group], ItemID.None)); } foreach (string text2 in this.m_SpawnData.Keys) { if (!(text2 == "Sanity")) { BSItemData randomObject = this.GetRandomObject(this.m_SpawnData[text2], ItemID.None); if (randomObject != null) { group = text2; return(randomObject); } } } return(null); }
private QuadTreeCellBalanceSystem FindObjectCell(GameObject go) { for (int i = 0; i < this.m_NumCellsX; i++) { for (int j = 0; j < this.m_NumCellsY; j++) { QuadTreeCellBalanceSystem quadTreeCellBalanceSystem = this.m_Cells[i, j]; for (int k = 0; k < quadTreeCellBalanceSystem.m_Objects.Count; k++) { BalanceSystemObject balanceSystemObject = quadTreeCellBalanceSystem.m_Objects[k]; if (go == balanceSystemObject.m_GameObject) { return(quadTreeCellBalanceSystem); } } } } return(null); }
public override void OnReplicationDeserialize(P2PNetworkReader reader, bool initial_state) { if (initial_state) { foreach (string key in this.m_Groups.Keys) { this.m_ObjectsInArea[key].Clear(); } this.m_QuadTree.Clear(); int num = reader.ReadInt32(); for (int i = 0; i < num; i++) { BalanceSystemObject balanceSystemObject = new BalanceSystemObject(); reader.ReadVector3(); balanceSystemObject.Deserialize(reader); this.m_QuadTree.InsertObject(balanceSystemObject, balanceSystemObject.m_Position); } this.SpawnObjectsIfNeeded(); } }
public void Clear() { for (int i = 0; i < this.m_NumCellsX; i++) { for (int j = 0; j < this.m_NumCellsY; j++) { QuadTreeCellBalanceSystem quadTreeCellBalanceSystem = this.m_Cells[i, j]; for (int k = 0; k < quadTreeCellBalanceSystem.m_Objects.Count; k++) { BalanceSystemObject balanceSystemObject = quadTreeCellBalanceSystem.m_Objects[k]; if (balanceSystemObject.m_GameObject) { UnityEngine.Object.Destroy(balanceSystemObject.m_GameObject); balanceSystemObject.m_GameObject = null; } } quadTreeCellBalanceSystem.m_Objects.Clear(); } } this.m_ObjCellMap.Clear(); }
public void DrawDebug() { bool flag = false; bool flag2 = true; bool flag3 = true; for (int i = 0; i < this.m_NumCellsX; i++) { for (int j = 0; j < this.m_NumCellsY; j++) { QuadTreeCellBalanceSystem quadTreeCellBalanceSystem = this.m_Cells[i, j]; if (flag || (flag3 && quadTreeCellBalanceSystem.m_Objects.Count > 0)) { Vector3 zero = Vector3.zero; zero.x = quadTreeCellBalanceSystem.m_Pos.x; zero.z = quadTreeCellBalanceSystem.m_Pos.y; Vector3 end = zero; end.x += quadTreeCellBalanceSystem.m_Size.x; DebugRender.DrawLine(zero, end, Color.white, 0f); end = zero; end.z += quadTreeCellBalanceSystem.m_Size.y; DebugRender.DrawLine(zero, end, Color.white, 0f); } if (flag2) { for (int k = 0; k < quadTreeCellBalanceSystem.m_Objects.Count; k++) { BalanceSystemObject balanceSystemObject = quadTreeCellBalanceSystem.m_Objects[k]; if (balanceSystemObject.m_GameObject != null) { DebugRender.DrawPoint(balanceSystemObject.m_GameObject.transform.position, (!balanceSystemObject.m_GameObject.activeSelf) ? Color.green : Color.red, 0.3f, 0f); } } } } } }
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; } } } }
public void SerializeAllObjects(P2PNetworkWriter writer) { using (P2PNetworkWriterSeekHelper p2PNetworkWriterSeekHelper = new P2PNetworkWriterSeekHelper(writer)) { writer.Write(0); int num = 0; for (int i = 0; i < this.m_NumCellsX; i++) { for (int j = 0; j < this.m_NumCellsY; j++) { QuadTreeCellBalanceSystem quadTreeCellBalanceSystem = this.m_Cells[i, j]; for (int k = 0; k < quadTreeCellBalanceSystem.m_Objects.Count; k++) { BalanceSystemObject balanceSystemObject = quadTreeCellBalanceSystem.m_Objects[k]; writer.Write(balanceSystemObject.m_Position); balanceSystemObject.Serialize(writer); num++; } } } p2PNetworkWriterSeekHelper.SeekToStoredPos(); writer.Write(num); } }
private void ItemDestroyed(string group, GameObject go) { int i = 0; while (i < this.m_ObjectsInArea[group].Count) { BalanceSystemObject balanceSystemObject = this.m_ObjectsInArea[group][i]; GameObject gameObject = balanceSystemObject.m_GameObject; if (gameObject == go) { if (balanceSystemObject.m_BalanceSpawner != null) { BalanceSpawner component = balanceSystemObject.m_BalanceSpawner.GetComponent <BalanceSpawner>(); bool flag = component.IsAttachmentSpawner(); if (flag) { DestroyIfNoChildren component2 = gameObject.GetComponent <DestroyIfNoChildren>(); if (component2 == null) { DebugUtils.Assert(DebugUtils.AssertType.Info); } if (component2.CheckNoChildren()) { balanceSystemObject.m_ActiveChildrenMask = -1; } else { this.SetupActiveChildrenMask(gameObject, out balanceSystemObject.m_ActiveChildrenMask); } this.m_ObjectsInArea[group].Remove(balanceSystemObject); } else { Item item = null; this.m_TempItemList.Clear(); go.GetComponents <Item>(this.m_TempItemList); if (this.m_TempList.Count > 0) { item = this.m_TempItemList[0]; } if (item && item.m_DestroyingOnlyScript) { i++; } else { this.m_QuadTree.RemoveObject(balanceSystemObject); this.m_ObjectsInArea[group].Remove(balanceSystemObject); } } } else { i++; } } else { i++; } } }
public void OnObjectTriggerExit(GameObject obj) { BalanceSystemObject objectInPos = this.m_QuadTree.GetObjectInPos(obj.transform.position); this.RemoveObjectFromArea(obj); }
public void RemoveObject(BalanceSystemObject go) { this.m_Objects.Remove(go); }
private void SpawnObject(GameObject spawner_obj, BalanceSpawner bs, BalanceSystemObject bso = null) { string empty = string.Empty; BSItemData objectToSpawn = this.GetObjectToSpawn(ref empty, bso); GameObject gameObject = null; if (objectToSpawn != null) { gameObject = objectToSpawn.m_Prefab; this.OnObjectSpawned(objectToSpawn, bs); } else { bs.m_LastNoSpawnObjectTime = Time.time; } if (gameObject != null) { objectToSpawn.m_LastSpawnTime = Time.time; GameObject gameObject2 = (bso != null) ? bso.m_GameObject : null; if (gameObject2 == null && spawner_obj != null) { gameObject2 = UnityEngine.Object.Instantiate <GameObject>(gameObject, spawner_obj.transform.position, spawner_obj.transform.rotation); Item component = gameObject2.GetComponent <Item>(); if (component) { component.m_CanSaveNotTriggered = false; Item[] componentsInChildren = component.GetComponentsInChildren <Item>(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].m_CanSaveNotTriggered = false; } } } BalanceSystemObject balanceSystemObject = bso ?? new BalanceSystemObject(); balanceSystemObject.m_GameObject = gameObject2; balanceSystemObject.m_Group = this.m_Groups[empty]; balanceSystemObject.m_BalanceSpawner = bs.gameObject; balanceSystemObject.m_Position = bs.transform.position; balanceSystemObject.m_ItemID = objectToSpawn.m_ItemID; this.m_QuadTree.InsertObject(balanceSystemObject); if (!this.m_ObjectsInArea[empty].Contains(balanceSystemObject)) { this.m_ObjectsInArea[empty].Add(balanceSystemObject); } if (empty == "Sanity") { CJObject[] array = (gameObject2 != null) ? gameObject2.GetComponentsInChildren <CJObject>() : null; for (int j = 0; j < array.Length; j++) { array[j].m_Hallucination = true; } } else { bs.m_LastSpawnObjectTime = Time.time; } this.ApplyActiveChildrenMask(balanceSystemObject); if (!this.IsDeserializingNetworkData() && bso == null) { ReplicatedBalanceObjects.OnObjectChanged(balanceSystemObject); } } }
private bool ItemDestroyed(string group, GameObject go, bool main_obj_destroyed) { int i = 0; while (i < this.m_ObjectsInArea[group].Count) { BalanceSystemObject balanceSystemObject = this.m_ObjectsInArea[group][i]; GameObject gameObject = balanceSystemObject.m_GameObject; if (gameObject == go) { if (balanceSystemObject.m_BalanceSpawner != null) { BalanceSpawner component = balanceSystemObject.m_BalanceSpawner.GetComponent <BalanceSpawner>(); int activeChildrenMask = balanceSystemObject.m_ActiveChildrenMask; if (component.IsAttachmentSpawner()) { DestroyIfNoChildren component2 = gameObject.GetComponent <DestroyIfNoChildren>(); if (component2 == null) { Debug.Log("obj_in_area name: " + gameObject.name); DebugUtils.Assert(DebugUtils.AssertType.Info); continue; } if (component2.m_NumChildren == 0) { balanceSystemObject.m_AllChildrenDestroyed = true; } if (component2.CheckNoChildren()) { balanceSystemObject.m_ActiveChildrenMask = 0; } else { this.SetupActiveChildrenMask(gameObject, ref balanceSystemObject.m_ActiveChildrenMask); } if (main_obj_destroyed) { this.m_ObjectsInArea[group].Remove(balanceSystemObject); } else { i++; } } else { Item item = null; this.m_TempItemList.Clear(); go.GetComponents <Item>(this.m_TempItemList); if (this.m_TempItemList.Count > 0) { item = this.m_TempItemList[0]; } if (item && item.m_DestroyingOnlyScript) { i++; } else { if (main_obj_destroyed) { this.m_QuadTree.RemoveObject(balanceSystemObject); this.m_ObjectsInArea[group].Remove(balanceSystemObject); } else { i++; } if (go.GetComponent <DestroyablePlant>()) { balanceSystemObject.m_ActiveChildrenMask = 0; } else { this.SetupActiveChildrenMask(gameObject, ref balanceSystemObject.m_ActiveChildrenMask); } } } if (main_obj_destroyed && balanceSystemObject.m_ActiveChildrenMask == 0) { ReplicatedBalanceObjects.OnObjectDestroyed(balanceSystemObject); } else if (activeChildrenMask != balanceSystemObject.m_ActiveChildrenMask) { ReplicatedBalanceObjects.OnObjectChanged(balanceSystemObject); } return(true); } i++; } else { i++; } } return(false); }
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; } } }