Pro_Unit

LoadGameplayState_Resolved

May 17th, 2021 (edited)
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. using System.Collections.Generic;
  2.  
  3. namespace AnimalSimulator.Infrastructure.States
  4. {
  5.     using Gameplay.Services;
  6.     using Services;
  7.     using Services.Gameplay;
  8.     using Services.Inputs;
  9.     using UI.Services;
  10.     public class LoadGameplayState : IPayloadedState<ServicesContainer>
  11.     {
  12.         private readonly GameStateMachine _stateMachine;
  13.  
  14.         public LoadGameplayState(GameStateMachine gameStateMachine) =>
  15.             _stateMachine = gameStateMachine;
  16.  
  17.         public void Enter(ServicesContainer gameplayContainer)
  18.         {
  19.             // Initialize Services
  20.             var initializes = new List<IInitialized>()
  21.             {
  22.                 gameplayContainer.Single<IGameplayCameraService>(),
  23.                 gameplayContainer.Single<IPlayerService>(),
  24.                 gameplayContainer.Single<IIslandsService>(),
  25.                 gameplayContainer.Single<IGameplayUIService>(),
  26.                 gameplayContainer.Single<IInputService>()
  27.             };
  28.  
  29.             foreach (var initialized in initializes)
  30.                 initialized.Initialize();
  31.  
  32.             // Next State
  33.             _stateMachine.Enter<GameLoopState>();
  34.         }
  35.  
  36.         public void Exit() { }
  37.     }
  38. }
Add Comment
Please, Sign In to add comment