private void TeleportChest(Chest chest, PlayerController user) { CachedChestData item = new CachedChestData(chest); SpawnManager.SpawnVFX(EasyVFXDatabase.ChestTeleporterTimeWarp, chest.sprite.WorldCenter, Quaternion.identity, true); user.CurrentRoom.DeregisterInteractable(chest); chest.DeregisterChestOnMinimap(); if (chest.majorBreakable) { chest.majorBreakable.TemporarilyInvulnerable = true; } Object.Destroy(chest.gameObject, 0.8f); this.m_chestos.Add(item); }
private IEnumerator LaunchChestSpawns() { while (Dungeon.IsGenerating) { yield return(null); } yield return(null); List <CachedChestData> failedList = new List <CachedChestData>(); for (int i = 0; i < this.m_chestos.Count; i++) { CachedChestData cachedChestData = this.m_chestos[i]; RoomHandler entrance = GameManager.Instance.Dungeon.data.Entrance; RoomHandler roomHandler = entrance; cachedChestData.Upgrade(); CellValidator cellValidator = delegate(IntVector2 c) { for (int n = 0; n < 5; n++) { for (int num2 = 0; num2 < 5; num2++) { if (!GameManager.Instance.Dungeon.data.CheckInBoundsAndValid(c.x + n, c.y + num2) || GameManager.Instance.Dungeon.data[c.x + n, c.y + num2].type == CellType.PIT || GameManager.Instance.Dungeon.data[c.x + n, c.y + num2].isOccupied) { return(false); } } } return(true); }; IntVector2?randomAvailableCell = roomHandler.GetRandomAvailableCell(new IntVector2?(IntVector2.One * 5), new CellTypes?(CellTypes.FLOOR), false, cellValidator); IntVector2?intVector = (randomAvailableCell == null) ? null : new IntVector2?(randomAvailableCell.GetValueOrDefault() + IntVector2.One); if (intVector != null) { cachedChestData.SpawnChest(intVector.Value); for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { IntVector2 key = intVector.Value + IntVector2.One + new IntVector2(j, k); GameManager.Instance.Dungeon.data[key].isOccupied = true; } } } else { roomHandler = ((roomHandler != entrance) ? entrance : ChestTeleporterItem.FindBossFoyer()); if (roomHandler == null) { roomHandler = entrance; } IntVector2?randomAvailableCell2 = roomHandler.GetRandomAvailableCell(new IntVector2?(IntVector2.One * 5), new CellTypes?(CellTypes.FLOOR), false, cellValidator); intVector = ((randomAvailableCell2 == null) ? null : new IntVector2?(randomAvailableCell2.GetValueOrDefault() + IntVector2.One)); if (intVector != null) { cachedChestData.SpawnChest(intVector.Value); for (int l = 0; l < 3; l++) { for (int m = 0; m < 3; m++) { IntVector2 key2 = intVector.Value + IntVector2.One + new IntVector2(l, m); GameManager.Instance.Dungeon.data[key2].isOccupied = true; } } } else { failedList.Add(cachedChestData); } } } this.m_chestos.Clear(); this.m_chestos.AddRange(failedList); yield break; }