public BehaviourTree Create(IServicesInjector gamePlayDependencies) { var tree = new TBehaviourTree(); tree.LoadTree(); var nodes = tree.TreeNodes.ToList(); var localInjector = TorqueGamesInjector.GetEmpty(); var localLinker = localInjector.GetLinker(); foreach (var node in nodes) { node.Init(gamePlayDependencies); } foreach (var node in nodes) { node.WriteLocalDependencies(localLinker); } foreach (var node in nodes) { node.ReadLocalDependencies(localInjector); } foreach (var node in nodes) { node.StartGame(); } return(tree); }
public override void WriteDependencies(IDependencyLinker linker, IServicesInjector gamePlayServices) { _camera = GetComponent <Camera>(); linker .LinkInterface <ICameraBinder>() .WithGivenInstance(this); }
private void LoadGameSession(IServicesInjector services) { var gameSession = services.Get <IGameSession>(); if (gameCharacterPrefab == null) { gameCharacterPrefab = gameSession.PrefabToSpawn; } CurrentCharacter = Instantiate(gameCharacterPrefab, transform, false); CurrentCharacter.transform.position = transformData.position; CurrentCharacter.transform.rotation = transformData.rotation; CurrentCharacter.SetupData(gameSession.InstanceData, services); transformData.gameObject.SetActive(false); }
public virtual Task StartGame(IServicesInjector services) { if (Components.Count != arrayTasks.Length) { arrayTasks = new Task[Components.Count]; } var i = 0; foreach (var gameComponent in Components) { arrayTasks[i] = gameComponent.StartGame(services); i++; } return(Task.WhenAll(arrayTasks)); }
public static IServiceCollection AddEventBus <TConfiguration>(this IServiceCollection services, Assembly assemblyToScan, Action <TConfiguration> configure = null) where TConfiguration : IConfiguration, new() { TConfiguration configuration = new TConfiguration(); configure?.Invoke(configuration); ISettings settings = configuration.BuildSettings(); IServicesInjector injector = CreateServiceInjector <TConfiguration>(); injector.AddPersistentConnection(services, settings); injector.AddSubscriptionManager(services); injector.AddEventBus(services, settings); injector.AddHandlers(services, assemblyToScan); return(services); }
public virtual void Init(IServicesInjector gamePlayServices) { }
public override async Task StartGame(IServicesInjector services) { await CurrentCharacter.StartGame(services); CurrentCharacter.gameObject.SetActive(true); }
public override void EarlyInitialization(IServicesInjector gamePlayServices) { CurrentCharacter.EarlyInitialization(gamePlayServices); }
public override void WriteDependencies(IDependencyLinker linker, IServicesInjector services) { _linker = linker; LoadGameSession(services); CurrentCharacter.WriteDependencies(_linker, services); }
public override void WriteDependencies(IDependencyLinker linker, IServicesInjector externalDependencies) { linker.LinkInterface <IPlayerBinder>().WithGivenInstance(this); }
public abstract void SetupData(ICharacterInstanceData data, IServicesInjector gamePlayInjector);
public void SetupData(IServicesInjector injector, TorqueGamesInjector playerInjector) { GamePlayDependencies = injector; InitializeLocalDependencies(playerInjector); }
public virtual void WriteDependencies(IDependencyLinker linker, IServicesInjector externalDependencies) { }
public void ReadLocalDependencies(IServicesInjector localDependencies) { }
public override void EarlyInitialization(IServicesInjector gamePlayServices) { model = gamePlayServices.Get <IPlayerAnimatorModel>(); }
public override void EarlyInitialization(IServicesInjector gamePlayServices) { Camera = gamePlayServices.Get <ICameraBinder>().GetCamera(); PlayerBinder = gamePlayServices.Get <IPlayerBinder>(); }
public override void EarlyInitialization(IServicesInjector gamePlayServices) { PlayerAimHelper = gamePlayServices.Get <IPlayerAimHelper>(); model = gamePlayServices.Get <IPlayerMovementModel>(); //rb = gamePlayServices.Get<PlayerBinder>().Rigidbody; }
public CharacterFactory(IServicesInjector gameInjector, IDependencyLinker gamePlayLinker) { _gameInjector = gameInjector; _gamePlayLinker = gamePlayLinker; }
public virtual Task StartGame(IServicesInjector services) => Task.CompletedTask;
public virtual void EarlyInitialization(IServicesInjector gamePlayServices) { }