/// <summary> /// Create the smallest platoon allowed. /// </summary> private void StartNewPlatoon() { _smallestPlatoonSize = MIN_PLATOON_SIZE; _newestPlatoon = GhostPlatoonBehaviour.CreatePreviewMode(Unit, Owner, MIN_PLATOON_SIZE); PreviewPlatoons.Add(_newestPlatoon); }
public void CmdEnqueuePlatoonPurchase( byte playerId, byte unitCategoryId, int unitId, int unitCount, byte spawnPointId, Vector3 destinationCenter, float destinationHeading) { Logger.LogNetworking( LogLevel.DEBUG, this, $"Enqueueing platoon purchase at spawn pt = {spawnPointId}."); if (MatchSession.Current.Players.Count > playerId && unitCount >= MIN_PLATOON_SIZE && unitCount <= MAX_PLATOON_SIZE) { if (MatchSession.Current.SpawnPoints.Length > spawnPointId) { PlayerData owner = MatchSession.Current.Players[playerId]; SpawnPointBehaviour spawn = MatchSession.Current.SpawnPoints[spawnPointId]; if (unitCategoryId < owner.Deck.Categories.Length && unitId < GameSession.Singleton.Armory.Categories[unitCategoryId].Count) { Unit unit = GameSession.Singleton.Armory.Categories[unitCategoryId][unitId]; GhostPlatoonBehaviour g = GhostPlatoonBehaviour.CreatePreviewMode(unit, owner, unitCount); g.SetPositionAndOrientation(destinationCenter, destinationHeading); NetworkServer.Spawn(g.gameObject); spawn.BuyPlatoon(g); } else { if (unitCategoryId < GameSession.Singleton.Armory.Categories.Length) { Logger.LogNetworking(LogLevel.ERROR, $"Got bad unit id = {unitId} from " + $"the server. Total units = {GameSession.Singleton.Armory.Categories[unitCategoryId].Count} " + $"(category = {unitCategoryId})."); } else { Logger.LogNetworking(LogLevel.ERROR, $"Got bad category id = {unitCategoryId} from " + $"the server. Total categories = {GameSession.Singleton.Armory.Categories.Length}"); } } } else { Logger.LogNetworking(LogLevel.ERROR, $"Client asked to create a platoon with an invalid spawn id {spawnPointId}."); } } else { // Got an invalid player id, client is trying to crash us? Logger.LogNetworking(LogLevel.ERROR, $"Client asked to create a platoon with an invalid player id {playerId}."); } }