Beispiel #1
0
        private void Start()
        {
            var contexts = new Contexts();

            _systems = new Entitas.Systems()
                       .Add(new SyncModelPositionSystem(contexts))
                       .Add(new CreateViewSystem(contexts.game))
                       .Add(new InputSystem(contexts))
                       .Add(new ArenaStartupSystem(contexts))
                       .Add(new MovementSystem(contexts))
                       .Add(new RotationSystem(contexts))
                       .Add(new CameraControlSystem(contexts))
                       .Add(new SyncViewPositionSystem(contexts))
                       .Add(new SyncViewRotationSystem(contexts))
                       .Add(new FindTargetSystem(contexts))
                       .Add(new MoveToTargetSystem(contexts))
                       //HealthBar Feature
                       .Add(new CreateHealthBarSystem(contexts.game))
                       .Add(new UpdateHealthBarValueSystem(contexts.game))
                       .Add(new UpdateHealthBarPositionSystem(contexts))
                       //Player target Feature
                       .Add(new UpdatePlayerTargetSystem(contexts.game))
                       .Add(new UpdatePlayerTargetViewSystem(contexts));


            _systems.Initialize();
        }
        public Entity AddLogicSystems(Entitas.Systems newSystems)
        {
            var component = CreateComponent <LogicSystemsComponent>(ComponentIds.LogicSystems);

            component.systems = newSystems;
            return(AddComponent(ComponentIds.LogicSystems, component));
        }
Beispiel #3
0
    public void ReplaceLogicSystems(Entitas.Systems newValue)
    {
        var index     = ManageComponentsLookup.LogicSystems;
        var component = (LogicSystemsComponent)CreateComponent(index, typeof(LogicSystemsComponent));

        component.value = newValue;
        ReplaceComponent(index, component);
    }
Beispiel #4
0
        private void Awake()
        {
            var services = new UnityServices();
            var contexts = Contexts.sharedInstance;

            systems = CreateSystems(contexts, services);
            systems.Initialize();
        }
    public void AddLogicSystem(Entitas.Systems newSystems)
    {
        var index     = GameComponentsLookup.LogicSystem;
        var component = CreateComponent <LogicSystemComponent>(index);

        component.systems = newSystems;
        AddComponent(index, component);
    }
Beispiel #6
0
    public void ReplaceLogicSystem(Entitas.Systems newValue)
    {
        var index     = GameComponentsLookup.LogicSystem;
        var component = CreateComponent <LogicSystemComponent>(index);

        component.Value = newValue;
        ReplaceComponent(index, component);
    }
    public void ReplaceLogicSystem(Entitas.Systems newSystem)
    {
        var index     = TimeComponentsLookup.LogicSystem;
        var component = CreateComponent <LogicSystemComponent>(index);

        component.system = newSystem;
        ReplaceComponent(index, component);
    }
Beispiel #8
0
    public void ReplaceLogicSystems(Entitas.Systems newSystems)
    {
        var index     = GameComponentsLookup.LogicSystems;
        var component = CreateComponent <LogicSystemsComponent>(index);

        component.systems = newSystems;
        ReplaceComponent(index, component);
    }
    public void AddFutureLogicSystem(Entitas.Systems newSystem)
    {
        var index     = TimeComponentsLookup.FutureLogicSystem;
        var component = CreateComponent <FutureLogicSystemComponent>(index);

        component.system = newSystem;
        AddComponent(index, component);
    }
        public Entity ReplaceLogicSystems(Entitas.Systems newSystems)
        {
            var component = CreateComponent <LogicSystemsComponent>(ComponentIds.LogicSystems);

            component.systems = newSystems;
            ReplaceComponent(ComponentIds.LogicSystems, component);
            return(this);
        }
    public void ReplaceLogicSystems(Entitas.Systems newSystems)
    {
        var index     = GameComponentsLookup.LogicSystems;
        var component = (Entitas_Reactive_UI.Example.LogicSystemsComponent)CreateComponent(index, typeof(Entitas_Reactive_UI.Example.LogicSystemsComponent));

        component.systems = newSystems;
        ReplaceComponent(index, component);
    }
Beispiel #12
0
        private void OnDisable()
        {
            _systems.TearDown();
            _systems.DeactivateReactiveSystems();
            _systems.ClearReactiveSystems();

            _systems = null;
        }
        public Entity AddEntitas(Entitas.Systems newPausableUpdateSystems, Entitas.Systems newUnpausableUpdateSystems, Entitas.Systems newPausableFixedUpdateSystems)
        {
            var component = CreateComponent <Oultrox.Common.Entitas.Components.Entitas.EntitasComponent>(ComponentIds.Entitas);

            component.pausableUpdateSystems      = newPausableUpdateSystems;
            component.unpausableUpdateSystems    = newUnpausableUpdateSystems;
            component.pausableFixedUpdateSystems = newPausableFixedUpdateSystems;
            return(AddComponent(ComponentIds.Entitas, component));
        }
 private void Awake() =>
 systems = new DeadBreachSystems(
     Contexts.sharedInstance.game,
     Canvas,
     MapTilePrefab,
     MapTile,
     PathTile,
     PathTileEndPrefab,
     PlayerPrefab,
     ObstaclePrefab);
        public Entity ReplaceEntitas(Entitas.Systems newPausableUpdateSystems, Entitas.Systems newUnpausableUpdateSystems, Entitas.Systems newPausableFixedUpdateSystems)
        {
            var component = CreateComponent <RMC.Common.Entitas.Components.Entitas.EntitasComponent>(ComponentIds.Entitas);

            component.pausableUpdateSystems      = newPausableUpdateSystems;
            component.unpausableUpdateSystems    = newUnpausableUpdateSystems;
            component.pausableFixedUpdateSystems = newPausableFixedUpdateSystems;
            ReplaceComponent(ComponentIds.Entitas, component);
            return(this);
        }
Beispiel #16
0
        //ECS
        public void ConfigureSystems(BattleRoyaleMatchModel matchModelArg, UdpSendUtils udpSendUtils,
                                     IpAddressesStorage ipAddressesStorage)
        {
            log.Info($"Создание нового матча {nameof(matchId)} {matchId}");

            //TODO это нужно убрать в отдельный класс
            Dictionary <int, (int playerId, ViewTypeId type)> possibleKillersInfo = new Dictionary <int, (int playerId, ViewTypeId type)>();


            // var test = new BattleRoyalePlayerModelFactory().Create(matchModelArg).Select(model=>model.AccountId);
            // playersIds = new HashSet<int>(test);

            contexts = ContextsPool.GetContexts();
            contexts.SubscribeId();
            TryEnableDebug();

            playerDeathHandler = new PlayerDeathHandler(matchmakerNotifier, udpSendUtils, ipAddressesStorage);
            var playersViewAreas = new PlayersViewAreas(matchModelArg.GameUnits.Players.Count);

            systems = new Entitas.Systems()
                      .Add(new MapInitSystem(contexts, matchModelArg, udpSendUtils, out var chunks))
                      .Add(new ViewAreasInitSystem(contexts, playersViewAreas))
                      // .Add(new TestEndMatchSystem(contexts))
                      .Add(new PlayerMovementHandlerSystem(contexts))
                      .Add(new PlayerAttackHandlerSystem(contexts))
                      .Add(new PlayerAbilityHandlerSystem(contexts))
                      .Add(new ParentsSystems(contexts))
                      .Add(new AISystems(contexts))
                      .Add(new MovementSystems(contexts))
                      .Add(new GlobalTransformSystem(contexts))
                      .Add(new ShootingSystems(contexts))
                      .Add(new UpdatePositionChunksSystem(contexts, chunks))
                      .Add(new CollisionSystems(contexts, chunks))
                      .Add(new EffectsSystems(contexts))
                      .Add(new TimeSystems(contexts))
                      .Add(new UpdatePossibleKillersSystem(contexts, possibleKillersInfo))

                      .Add(new PlayerExitSystem(contexts, matchModelArg.MatchId, playerDeathHandler, matchRemover))
                      .Add(new FinishMatchSystem(contexts, matchRemover, matchId))
                      .Add(new NetworkKillsSenderSystem(contexts, possibleKillersInfo, matchModelArg.MatchId, playerDeathHandler, udpSendUtils))

                      .Add(new DestroySystems(contexts))
                      // .Add(new MatchDebugSenderSystem(contexts, matchModelArg.MatchId, udpSendUtils))
                      .Add(new NetworkSenderSystems(contexts, matchModelArg.MatchId, udpSendUtils, playersViewAreas))
                      .Add(new MovingCheckerSystem(contexts))

                      .Add(new DeleteSystem(contexts))
                      .Add(new InputDeletingSystem(contexts))
                      .Add(new GameDeletingSystem(contexts))
            ;

            systems.ActivateReactiveSystems();
            systems.Initialize();
            gameStartTime = DateTime.UtcNow;
        }
        public Entity SetLogicSystems(Entitas.Systems newSystems)
        {
            if (hasLogicSystems)
            {
                throw new EntitasException("Could not set logicSystems!\n" + this + " already has an entity with LogicSystemsComponent!",
                                           "You should check if the pool already has a logicSystemsEntity before setting it or use pool.ReplaceLogicSystems().");
            }
            var entity = CreateEntity();

            entity.AddLogicSystems(newSystems);
            return(entity);
        }
    public TimeEntity SetLogicSystem(Entitas.Systems newSystem)
    {
        if (hasLogicSystem)
        {
            throw new Entitas.EntitasException("Could not set LogicSystem!\n" + this + " already has an entity with LogicSystemComponent!",
                                               "You should check if the context already has a logicSystemEntity before setting it or use context.ReplaceLogicSystem().");
        }
        var entity = CreateEntity();

        entity.AddLogicSystem(newSystem);
        return(entity);
    }
        public Entity SetEntitas(Entitas.Systems newPausableUpdateSystems, Entitas.Systems newUnpausableUpdateSystems, Entitas.Systems newPausableFixedUpdateSystems)
        {
            if (hasEntitas)
            {
                throw new EntitasException("Could not set entitas!\n" + this + " already has an entity with Heizhu.Common.Entitas.Components.Entitas.EntitasComponent!",
                                           "You should check if the pool already has a entitasEntity before setting it or use pool.ReplaceEntitas().");
            }
            var entity = CreateEntity();

            entity.AddEntitas(newPausableUpdateSystems, newUnpausableUpdateSystems, newPausableFixedUpdateSystems);
            return(entity);
        }
    public GameEntity SetLogicSystems(Entitas.Systems newSystems)
    {
        if (hasLogicSystems)
        {
            throw new Entitas.EntitasException("Could not set LogicSystems!\n" + this + " already has an entity with Entitas_Reactive_UI.Example.LogicSystemsComponent!",
                                               "You should check if the context already has a logicSystemsEntity before setting it or use context.ReplaceLogicSystems().");
        }
        var entity = CreateEntity();

        entity.AddLogicSystems(newSystems);
        return(entity);
    }
    public void ReplaceFutureLogicSystem(Entitas.Systems newSystem)
    {
        var entity = futureLogicSystemEntity;

        if (entity == null)
        {
            entity = SetFutureLogicSystem(newSystem);
        }
        else
        {
            entity.ReplaceFutureLogicSystem(newSystem);
        }
    }
Beispiel #22
0
    public void ReplaceLogicSystems(Entitas.Systems newSystems)
    {
        var entity = logicSystemsEntity;

        if (entity == null)
        {
            entity = SetLogicSystems(newSystems);
        }
        else
        {
            entity.ReplaceLogicSystems(newSystems);
        }
    }
Beispiel #23
0
    public void ReplaceLogicSystem(Entitas.Systems newValue)
    {
        var entity = logicSystemEntity;

        if (entity == null)
        {
            entity = SetLogicSystem(newValue);
        }
        else
        {
            entity.ReplaceLogicSystem(newValue);
        }
    }
Beispiel #24
0
 public ClientMatchSimulation(BattleUiController battleUiController, UdpSendUtils udpSendUtils,
                              BattleRoyaleClientMatchModel matchModel, PingStatisticsStorage pingStatisticsStorage)
 {
     this.battleUiController    = battleUiController;
     this.pingStatisticsStorage = pingStatisticsStorage;
     if (matchModel == null)
     {
         log.Error("Симуляция матча не запущена ");
         return;
     }
     systems = CreateSystems(udpSendUtils, matchModel, pingStatisticsStorage);
     systems.ActivateReactiveSystems();
     systems.Initialize();
 }
        public Entity ReplaceEntitas(Entitas.Systems newPausableUpdateSystems, Entitas.Systems newUnpausableUpdateSystems, Entitas.Systems newPausableFixedUpdateSystems)
        {
            var entity = entitasEntity;

            if (entity == null)
            {
                entity = SetEntitas(newPausableUpdateSystems, newUnpausableUpdateSystems, newPausableFixedUpdateSystems);
            }
            else
            {
                entity.ReplaceEntitas(newPausableUpdateSystems, newUnpausableUpdateSystems, newPausableFixedUpdateSystems);
            }

            return(entity);
        }
Beispiel #26
0
        private void Awake()
        {
            _services = new Services.Services
            {
                Logger                = new UnityDebugLogService(),
                ViewService           = new UnityViewService(),
                Time                  = new UnityTimeService(),
                Physics               = new UnityPhysicsService(),
                CoroutineDirector     = new UnityCoroutineDirectorService(this),
                CollidingViewRegister = new UnityCollidingViewRegister(),
                Identifiers           = new GameIdentifierService(),
                InputService          = new StandaloneInputService(),
            };

            Contexts contexts = Contexts.sharedInstance;

            _systems = new AllSystems(contexts, _services);
            _systems.Initialize();
        }
Beispiel #27
0
 private void OnEnable()
 {
     _systems = new GameSystems(Contexts.sharedInstance);
     _systems.Initialize();
 }
Beispiel #28
0
        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);
        }
Beispiel #29
0
 private void Awake() =>
 systems =
     new SimulationFeature(
         Contexts.sharedInstance.game,
         Contexts.sharedInstance.settings,
         Contexts.sharedInstance.statistics);
Beispiel #30
0
 private void Start()
 {
     _contexts = Contexts.sharedInstance;
     _systems  = CreateSystems(_contexts);
     InitWorld();
 }