public VehiclesGroup(int formationId, List <long> vehicleIds, VehicleRegistry registry, CommandManager commandManager) { this.registry = registry; this.commandManager = commandManager; FormationId = formationId; VehicleIds = vehicleIds; }
public bool PlayCommandIfPossible(VehicleRegistry registry, Player player, Move move, int worldTick) { if (!commandQueues.Any()) { return(false); } return(lockedFormationId != 0 ? PlayFormationCommandIfPossible(commandQueues[lockedFormationId], registry, player, move, worldTick) : commandQueues.Any(t => PlayFormationCommandIfPossible(commandQueues.ElementAt(GetNextQueueId()).Value, registry, player, move, worldTick))); }
private bool PlayFormationCommandIfPossible(Queue <Command> formationQueue, VehicleRegistry registry, Player player, Move move, int worldTick) { if (formationQueue.Count == 0) { return(false); } var canPlayCommand = CanPlayCommand(player); if (!canPlayCommand) { return(true); } var currentCommand = formationQueue.Peek(); #if DEBUG RewindClient.Instance.Message($"=== Current command {currentCommand} ==="); #endif if (!currentCommand.IsStarted()) { currentCommand.Commit(move, registry); if (IsSelectCommand(currentCommand)) { lockedFormationId = currentCommand.FormationId; } if (formationQueue.Count == 1 || IsSelectCommand(formationQueue.ElementAt(1))) { lockedFormationId = 0; } #if DEBUG RewindClient.Instance.Message($"=== Commiting command {currentCommand} ==="); #endif } if (forcePlayNextCommand) { forcePlayNextCommand = currentCommand.ForcePlayNextCommand; return(true); } if (currentCommand.CanBeParallel() || currentCommand.IsFinished(worldTick, registry)) { #if DEBUG RewindClient.Instance.Message($"=== {currentCommand} {nameof(currentCommand.CanBeParallel)}:{currentCommand.CanBeParallel()} ==="); RewindClient.Instance.Message($"=== {currentCommand} {nameof(currentCommand.IsFinished)}:{currentCommand.IsFinished(worldTick, registry)} ==="); #endif forcePlayNextCommand = currentCommand.ForcePlayNextCommand; formationQueue.Dequeue(); return(true); } return(false); }