public override void OnTick(GameLevel gameLevel, int currentTick, out int outTick) { base.OnTick(gameLevel, currentTick, out outTick); int secondsLeft = GetSecondsLeft(); if (secondsLeft > (MaxGameTime / 2)) { return; //Ignore until the ticker has finished } if (secondsLeft == 0) { gameLevel.UpdateGameState(GetNextGameState(gameLevel)); return; } ITickableInformation tickableInformation = GetTickableInformation(null); gameLevel.DoForAllPlayers(player => { SendTickableMessage(gameLevel, player, tickableInformation); if (player.IsSprinting && player.GameTeam != MurderTeam.Murderer) { player.SetSprinting(false); } if (player.IsGameSpectator) { if (player.Inventory.InHandSlot == 4) { if (_modalCountdownDict.TryGetValue(player.Username, out var countdownValue)) { if (countdownValue == 1) { if (player.Level is GameLevel level) { level.ShowEndGameMenu(player); _modalCountdownDict[player.Username] = 6; //Reset to default player.Inventory.SetHeldItemSlot(3); //Shift off slot. player.BarHandler.AddMinorLine("§r", 1); return; } } else { _modalCountdownDict[player.Username] = (countdownValue = (countdownValue - 1)); } } else { _modalCountdownDict.Add(player.Username, 6); //Default to 3 seconds countdownValue = 6; } int visibleCountdown = (int)Math.Ceiling(countdownValue / 2D); player.BarHandler.AddMinorLine($"§dContinue Holding for {visibleCountdown} Second{(visibleCountdown == 1 ? "" : "s")} to Open Menu", 1); } else { _modalCountdownDict.Remove(player.Username); } } }); /* * Gun Parts */ //Every 15 Seconds -- Can't spawn any gun parts if the spawned amount == the total locations // V Avoid spawning gun parts on the first possible spawn tick if (secondsLeft < (MaxGameTime / 2) - 10 && currentTick % 30 == 0 && GunParts.Count != GunPartLocations.Count) { //SkyUtil.log("Attempting to spawn gun parts at tick " + currentTick); PlayerLocation spawnLocation = null; int maxSpawnAmount = gameLevel.GetPlayerCount(); int spawnCount = 0; while (++spawnCount < maxSpawnAmount) { int rollCount = 0; while (++rollCount < 10 && GunParts.ContainsKey(spawnLocation = GunPartLocations[Random.Next(GunPartLocations.Count)])) { // } if (rollCount == 10) { break; //No more spawn points available. } if (spawnLocation != null) { MurderGunPartEntity item = new MurderGunPartEntity(this, (MurderLevel)gameLevel, spawnLocation); GunParts.Add(spawnLocation, item); gameLevel.AddEntity(item); } } } }