public MessageWrapperHandler(UdpSendUtils udpSendUtils, int matchId, ITransformStorage transformStorage, IPlayersStorage playersStorage, IHealthPointsStorage healthPointsStorage, IMaxHealthPointsMessagePackStorage maxHealthPointsMessagePackStorage, IPingStatisticsStorage pingStatisticsStorage, IKillMessageStorage killMessageStorage) { receivedMessagesRudp = new HashSet <uint>(); deliveryConfirmationSender = new DeliveryConfirmationSender(udpSendUtils); MessageType lastEnum = Enum.GetValues(typeof(MessageType)).Cast <MessageType>().Max(); handlers = new IMessageHandler[(int)lastEnum + 1]; handlers[(int)MessageType.PlayerInfo] = new PlayerInfoMessageHandler(playersStorage); handlers[(int)MessageType.Positions] = new PositionsMessageHandler(transformStorage); handlers[(int)MessageType.HealthPointsMessagePack] = new HealthPointsPackHandler(healthPointsStorage); handlers[(int)MessageType.DeliveryConfirmation] = new RudpConfirmationReceiver(); handlers[(int)MessageType.ShowPlayerAchievements] = new ShowPlayerAchievementsHandler(matchId); handlers[(int)MessageType.MaxHealthPointsMessagePack] = new MaxHealthPointsMessagePackHandler(maxHealthPointsMessagePackStorage); handlers[(int)MessageType.PingAnswerMessage] = new PingAnswerMessageHandler(pingStatisticsStorage); handlers[(int)MessageType.Kill] = new KillMessageHandler(killMessageStorage); }
private Entitas.Systems CreateSystems(UdpSendUtils udpSendUtils, BattleRoyaleClientMatchModel matchModel, PingStatisticsStorage statisticsStorage) { GameSceneFactory gameSceneFactory = new GameSceneFactory(); var matchScene = gameSceneFactory.Create(); PhysicsSpawner physicsSpawner = new PhysicsSpawner(matchScene); contexts = Contexts.sharedInstance; var updatePlayersSystem = new UpdatePlayersSystem(contexts, matchModel); playersStorage = updatePlayersSystem; var healthUpdaterSystem = new HealthUpdaterSystem(contexts); healthPointsStorage = healthUpdaterSystem; var maxHealthUpdaterSystem = new MaxHealthUpdaterSystem(contexts); maxHealthPointsMessagePackStorage = maxHealthUpdaterSystem; Vector3 cameraShift = new Vector3(0, 60, -30); ushort playerTmpId = matchModel.PlayerTemporaryId; int matchId = matchModel.MatchId; Text pingText = battleUiController.GetPingText(); pingSystem = new PingSystem(pingText, statisticsStorage); ClientInputMessagesHistory clientInputMessagesHistory = new ClientInputMessagesHistory(playerTmpId, matchId); ClientPrefabsStorage clientPrefabsStorage = new ClientPrefabsStorage(); PhysicsVelocityManager physicsVelocityManager = new PhysicsVelocityManager(); ArrangeTransformSystem[] arrangeCollidersSystems = { new WithHpArrangeTransformSystem(contexts) }; PhysicsRollbackManager physicsRollbackManager = new PhysicsRollbackManager(arrangeCollidersSystems); PhysicsRotationManager physicsRotationManager = new PhysicsRotationManager(); SnapshotFactory snapshotFactory = new SnapshotFactory(contexts.serverGame); PlayerPredictor playerPredictor = new PlayerPredictor(physicsRollbackManager, matchScene, contexts.serverGame, physicsVelocityManager, physicsRotationManager, snapshotFactory); PlayerEntityComparer playerEntityComparer = new PlayerEntityComparer(); PredictedSnapshotsStorage predictedSnapshotsStorage = new PredictedSnapshotsStorage(); AverageInputManager averageInputManager = new AverageInputManager(); PredictionChecker predictionChecker = new PredictionChecker(playerEntityComparer, predictedSnapshotsStorage); SimulationCorrector simulationCorrector = new SimulationCorrector(playerPredictor, averageInputManager, clientInputMessagesHistory, predictedSnapshotsStorage); var predictionManager = new PredictionManager(predictionChecker, simulationCorrector); Joystick movementJoystick = battleUiController.GetMovementJoystick(); Joystick attackJoystick = battleUiController.GetAttackJoystick(); LastInputIdStorage lastInputIdStorage = new LastInputIdStorage(); SnapshotBuffer snapshotBuffer = new SnapshotBuffer(); var snapshotInterpolator = new SnapshotInterpolator(snapshotBuffer); var consoleStub = new ConsoleNetworkProblemWarningView(); NetworkTimeManager timeManager = new NetworkTimeManager(pingStatisticsStorage, snapshotBuffer, consoleStub); INetworkTimeManager networkTimeManager = timeManager; ITimeUpdater timeUpdater = timeManager; snapshotManager = new SnapshotManager(snapshotBuffer, snapshotInterpolator); transformStorage = new TransformMessageHandler(snapshotBuffer, timeUpdater); MatchTimeSystem matchTimeSystem = new MatchTimeSystem(networkTimeManager); IMatchTimeStorage matchTimeStorage = matchTimeSystem; var updateTransformSystem = new UpdateTransformSystem(contexts, snapshotManager, matchTimeStorage); SpawnManager spawnManager = new SpawnManager(clientPrefabsStorage, physicsSpawner); var killsIndicatorSystem = new KillsIndicatorSystem(battleUiController.GetKillMessage(), battleUiController.GetKillIndicator(), battleUiController.GetKillsText(), battleUiController.GetAliveText(), matchModel.PlayerModels.Length, new PlayerNameHelper(matchModel)); killMessageStorage = killsIndicatorSystem; systems = new Entitas.Systems() .Add(matchTimeSystem) .Add(new ServerGameStateDebugSystem(snapshotBuffer, clientPrefabsStorage)) .Add(new PredictionСheckSystem(snapshotBuffer, predictionManager)) .Add(updateTransformSystem) .Add(updatePlayersSystem) .Add(new PrefabSpawnerSystem(contexts, spawnManager)) .Add(new InputSystem(movementJoystick, attackJoystick, clientInputMessagesHistory, snapshotManager, matchTimeStorage, lastInputIdStorage)) .Add(new PlayerStopSystem(contexts)) .Add(new PlayerPredictionSystem(contexts, clientInputMessagesHistory, playerPredictor)) .Add(new CameraMoveSystem(contexts, battleUiController.GetMainCamera(), cameraShift)) .Add(new LoadingImageSwitcherSystem(contexts, battleUiController.GetLoadingImage())) .Add(killsIndicatorSystem) .Add(healthUpdaterSystem) .Add(maxHealthUpdaterSystem) .Add(new HealthBarSpawnSystem(contexts, new HealthBarStorage())) .Add(new HealthBarSliderUpdaterSystem(contexts)) .Add(new HealthBarPositionUpdaterSystem(contexts)) .Add(new HealthBarRotatingSystem(contexts, cameraShift)) .Add(new HealthTextUpdatingSystem(contexts)) .Add(new HealthBarDestroyHelperSystem(contexts)) .Add(new DestroyViewSystem(contexts)) .Add(new InputSenderSystem(udpSendUtils, clientInputMessagesHistory)) .Add(new RudpMessagesSenderSystem(udpSendUtils)) .Add(new GameContextClearSystem(contexts)) .Add(new PredictedSnapshotHistoryUpdater(contexts, predictedSnapshotsStorage, matchTimeStorage, lastInputIdStorage)) ; return(systems); }
public PositionsMessageHandler(ITransformStorage transformStorage) { this.transformStorage = transformStorage; }