public void Resolve()
    {
        _dependencies        = FindDependencies();
        _dependencyContainer = new DependencyContainer();
        foreach (var dependencyReference in _dependencies)
        {
            _dependencyContainer.AddDependency(new DependencyReference(dependencyReference.Name, dependencyReference.Reference));
        }
        //Debug.Log("non serializable refs " + NonSerializableRefs);
        foreach (var dependencyReference in NonSerializableRefs)
        {
            _dependencyContainer.AddDependency(dependencyReference);
        }

        var rootSceneObjects = Enumerable.Range(0, SceneManager.sceneCount)
                               .Select(sceneIndex => SceneManager.GetSceneAt(sceneIndex))
                               .Where(scene => scene.isLoaded)
                               .SelectMany(scene => scene.GetRootGameObjects());

        foreach (var sceneObject in rootSceneObjects)
        {
            //Debug.Log("resolving for " + sceneObject);
            Resolve(sceneObject);
        }
    }
예제 #2
0
    private void Awake()
    {
        var inputMapping = PilotInput.Bindings.DefaultXbox360Mapping.Value;

        _pilotActionMap = PilotInput.ActionMap.Create(
            new ActionMapConfig <WingsuitAction> {
            ControllerId  = new ControllerId.XInput((PlayerIndex)_controllerId),
            InputSettings = InputSettings.Default,
            InputMapping  = inputMapping
        }, _gameClock);

        _pilotPool = new ObjectPool <GameObject>(() => _pilot);

        var container = new DependencyContainer();

        container.AddDependency("eventSystem", _eventSystem);
        container.AddDependency("windManager", _windManager);
        container.AddDependency("actionMap", new Ref <PilotActionMap>(_pilotActionMap));
        container.AddDependency("gameClock", _gameClock);
        container.AddDependency("fixedClock", _fixedClock);

        DependencyInjector.Default.Inject(_pilot, container);

        _originalTransform = _pilot.transform.MakeImmutable();

        _pooledPilot = _pilotPool.Take();
    }
예제 #3
0
 public CommandInterpreter(IContentComparer judge, IStudentsRepository repository, IDirectoryManager IOManager)
 {
     this.container = new DependencyContainer(typeof(InjectAttribute));
     container.AddDependency <IContentComparer, IContentComparer>(judge);
     container.AddDependency <IStudentsRepository, IStudentsRepository>(repository);
     container.AddDependency <IDirectoryManager, IDirectoryManager>(IOManager);
 }
예제 #4
0
        void Awake()
        {
            // TODO Re-use DependencyContainer
            var diContainer = new DependencyContainer();

            diContainer.AddDependency("objectMessagePools", ObjectMessagePools.Value);
            var objectMessageRouter = new ObjectMessageRouter(MessageTypes.ObjectMessageTypes, gameObject);

            diContainer.AddDependency("localObjectMessageSender", new LocalObjectMessageSender(objectMessageRouter));
            DependencyInjector.Default.Inject(this.gameObject, diContainer);
            (ObjectRole.Authority | ObjectRole.Owner).ApplyTo(this.gameObject);
        }
예제 #5
0
        static void Main(string[] args)
        {
            ITypeProvider provider  = new TypeProvider();
            IParser       parser    = new AttributeParser();
            IContainer    container = new DependencyContainer(parser, provider);

            container.AddDependency(typeof(ITypeProvider), provider);
            container.AddDependency(typeof(IParser), parser);
            container.AddDependency(typeof(IContainer), container);

            MarketApplication application = new MarketApplication(provider, parser, container);

            application.Run();
        }
예제 #6
0
        static void Main(string[] args)
        {
            var diContainer = new DependencyContainer();

            diContainer.AddDependency <IFactory <IWeapon>, WeaponFactory>(new WeaponFactory());
            diContainer.AddDependency <IFactory <IGem>, GemFactory>(new GemFactory());
            diContainer.AddDependency <IList <IWeapon>, List <IWeapon> >(new List <IWeapon>());
            diContainer.AddDependency <IPrintLocation, ConsolePrinter>(new ConsolePrinter());
            diContainer.AddDependency <IMetadataController, MetadataController>(new MetadataController());

            var commandInterpreter = new CommandInterpreter(diContainer);

            var engine = new Engine(commandInterpreter);

            engine.Start();
        }
        void Awake()
        {
            _json = new JsonSerializer();
            if (!File.Exists(DiscoveredSpawnpointsPath.Value))
            {
                _discoveredSpawnpoints = ImmutableList.Create <string>();
                _json.SerializeToFile(DiscoveredSpawnpointsPath.Value, _discoveredSpawnpoints);
            }
            else
            {
                _discoveredSpawnpoints = _json.DeserializeFromFile <IImmutableList <string> >(DiscoveredSpawnpointsPath.Value);
            }

            var spawnpointDependencyContainer = new DependencyContainer();

            foreach (var spawnpointDependency in _spawnpointDependencies)
            {
                spawnpointDependencyContainer.AddDependency(spawnpointDependency.name, spawnpointDependency);
            }
            for (int i = 0; i < _spawnpoints.Count; i++)
            {
                var spawnpoint = _spawnpoints[i];
                DependencyInjector.Default.Inject(spawnpoint.gameObject, spawnpointDependencyContainer);
                spawnpoint.IsDiscovered = _discoveredSpawnpoints.Contains(spawnpoint.Id) || spawnpoint.IsDiscovered;
                spawnpoint.OnDiscover  += () => OnSpawnpointDiscovered(spawnpoint);
            }
        }
예제 #8
0
    public IEnumerator <WaitCommand> Respawn(SpawnpointLocation spawnpoint)
    {
        if (!_isRespawning)
        {
            _isRespawning = true;

            if (_currentPlayer != null && _currentPlayer.GameObject.activeInHierarchy)
            {
                _currentPlayer = null;
                _wingsuit      = null;
            }

            var networkSystems = _activeNetwork.NetworkSystems;

            if (_onReplicatedObjectAdded == null)
            {
                _onReplicatedObjectAdded = new Event(networkSystems.ObjectStore, "ObjectAdded");
            }
            // Wait until a player has been created by the replicated object store
            var asyncPlayer = AsyncResult <ReplicatedObject> .SingleResultFromEvent(
                _onReplicatedObjectAdded,
                IsOwnedPilot);

            var respawnRequest = networkSystems.MessagePool.GetMessage <GameMessages.RespawnPlayerRequest>();
            respawnRequest.Content.Spawnpoint = spawnpoint.AsWingsuitLocation();
            respawnRequest.Content.InputPitch = _playerActionMap.V.PollAxis(WingsuitAction.Pitch) +
                                                _playerActionMap.V.PollMouseAxis(WingsuitAction.Pitch);
            respawnRequest.Content.InputRoll = _playerActionMap.V.PollAxis(WingsuitAction.Roll) +
                                               _playerActionMap.V.PollMouseAxis(WingsuitAction.Roll);
            _activeNetwork.SendToAuthority(respawnRequest);

            yield return(asyncPlayer.WaitUntilReady);

            _currentPlayer = asyncPlayer.Result;

            var playerDeps = new DependencyContainer();
            playerDeps.AddDependency("gameClock", _gameClock);
            DependencyInjector.Default.Inject(_currentPlayer.GameObject, playerDeps, overrideExisting: true);

            _wingsuit = _currentPlayer.GameObject.GetComponent <Wingsuit>();
            _wingsuit.AlphaManager.SetAlpha(1f);

//            if (_activeNetwork.AuthorityConnectionId != ConnectionId.Self)
//            {
//                SwitchToActiveMount();
//            }
//            else
//            {
//                Debug.Log("Ain't gonna switch no mount for yourself yo, you be dedicated!");
//            }


            if (_gameSettingsProvider != null)
            {
                ApplySettings(_gameSettingsProvider.ActiveSettings);
            }

            var pilot = _currentPlayer.GameObject.GetComponent <Wingsuit>();
            _eventSystem.Emit(new Events.PlayerSpawned(pilot));

            _isRespawning = false;
        }
    }
예제 #9
0
 public CommandInterpreter(IRepository repository, IUnitFactory unitFactory)
 {
     iocc = new DependencyContainer();
     iocc.AddDependency <IRepository, UnitRepository>(repository as UnitRepository);
     iocc.AddDependency <IUnitFactory, UnitFactory>(unitFactory as UnitFactory);
 }