コード例 #1
0
 public ViewInstanceProvider(PoolableView proto,
                             IInstantiator instantiator, Transform parent = null)
 {
     this.proto        = proto;
     this.parent       = parent;
     this.instantiator = instantiator;
 }
コード例 #2
0
    /// <summary>
    /// Instantiates an object of type T.
    /// </summary>
    private T CreateItem()
    {
        if (m_instantiator == null)
        {
            Debug.Log("No instantiator!");
        }

        if (m_instantiator == null)
        {
            if (m_prefab)
            {
                m_instantiator = new PrefabInstantiator(m_prefab);
            }
            else
            {
                Debug.LogWarning("Pool<" + typeof(T) + "> instantiation behaviour is undefined. You might need to call SetInstantiator on the pool object if it has been deserialized.");
                return(null);
            }
        }

        T t = m_instantiator.Create();

        if (m_parent != null)
        {
            t.transform.SetParent(m_parent, false);
        }

        t.name = t.name.Substring(0, t.name.Length - "(Clone)".Length) + " " + (m_reserveList.Count + m_activeList.Count).ToString();

        return(t);
    }
コード例 #3
0
        public static NetReflectorTypeTable CreateDefault(IInstantiator instantiator)
        {
            NetReflectorTypeTable table = new NetReflectorTypeTable(instantiator);

            SetupDefaultTable(table);
            return(table);
        }
コード例 #4
0
        public EnemyEntity InstantiateEnemy(EnemyType enemyType, IInstantiator instantiator, Vector3 position,
                                            Quaternion rotation, Transform parent = null)
        {
            var enemyObject = GetAsset <GameObject>(assetCache.GetEnemyAsset(enemyType));

            return(Instantiate <EnemyEntity>(instantiator, enemyObject, position, rotation, parent));
        }
コード例 #5
0
        public ProjectileMb InstantiateProjectile(IInstantiator instantiator, Vector3 position,
                                                  Quaternion rotation, Transform parent = null)
        {
            var projectileAsset = GetAsset <GameObject>(assetCache.GetProjectileAsset());

            return(Instantiate <ProjectileMb>(instantiator, projectileAsset, position, rotation, parent));
        }
コード例 #6
0
 public PlayersManagementController(IUnityGameObjectProxy unityGameObjectProxy, IUnityObjectProxy unityObjectProxy, IUnityDebugProxy unityDebugProxy, IInstantiator container)
 {
     this.unityGameObjectProxy = unityGameObjectProxy;
     this.unityObjectProxy     = unityObjectProxy;
     this.unityDebugProxy      = unityDebugProxy;
     this.container            = container;
 }
コード例 #7
0
        public PlayerEntity InstantiatePlayer(IInstantiator instantiator, Vector3 position, Quaternion rotation,
                                              Transform parent = null)
        {
            var playerObject = GetAsset <GameObject>(assetCache.GetPlayerAsset());

            return(Instantiate <PlayerEntity>(instantiator, playerObject, position, rotation, parent));
        }
コード例 #8
0
        protected PooledInjectableViewResolverSystem(IPoolManager poolManager, IEventSystem eventSystem, IInstantiator instantiator)
        {
            PoolManager  = poolManager;
            Instantiator = instantiator;
            EventSystem  = eventSystem;

            PrefabTemplate = ResolvePrefabTemplate();
        }
コード例 #9
0
 public static bool CanInstantiate(this IInstantiator instantiator, Type concreteType)
 {
     return(instantiator.CanInstantiate(new InjectionContext
     {
         Container = instantiator.Container,
         DeclaringType = concreteType,
     }));
 }
コード例 #10
0
        public ProjectileSpawner(IInstantiator instantiator, IProjectileFactory projectileFactory, SignalBus signalBus)
        {
            this.projectileFactory = projectileFactory;
            this.instantiator      = instantiator;
            this.signalBus         = signalBus;

            SubscribeToDestroySignal();
        }
コード例 #11
0
 public void Construct(IScreenRegistry screenRegistry,
                       IInstantiator instantiator,
                       IAciEventManager eventManager)
 {
     m_ScreenRegistry = screenRegistry;
     m_EventManager   = eventManager;
     m_Instantiator   = instantiator;
 }
コード例 #12
0
 public EnemySpawnController(IInstantiator instantiator,
                             SpawnZone spawnzone, WorldData worldData)
 {
     _instantiator = instantiator;
     _spawnzone    = spawnzone;
     _spawns       = worldData.Spawns.OrderBy(x => x.secondsTillSpawn).ToList();
     _nextSpawn    = _spawns[_nextSpawnId].secondsTillSpawn;
 }
コード例 #13
0
ファイル: Scope.cs プロジェクト: tylike/Excess
        private IInstantiator getInstantiator()
        {
            if (_instantiator == null)
            {
                _instantiator = get <IInstantiator>();
            }

            return(_instantiator);
        }
コード例 #14
0
 public static T InstantiatePrefabForComponent <T>(
     this IInstantiator instantiator,
     T prefab
     ) where T : Component
 {
     return(instantiator.InstantiatePrefabForComponent <T>(
                prefab.gameObject
                ));
 }
コード例 #15
0
 public PrefabToLocationService(IInstantiator instantiator,
                                PrefabsInstaller prefabs,
                                List <IPrefabToLocationContract> contracts,
                                IComponentProvisionService componentProvisionService)
 {
     _instantiator = instantiator;
     _contracts    = contracts;
     _prefabsMap   = prefabs;
     _componentProvisionService = componentProvisionService;
 }
        public BuiltInCollectionsObjectContextFactory(IInstantiator instantiator, IObjectContextFactory recursionFactory)
        {
            if (instantiator == null)
                throw new ArgumentNullException("instantiator");
            if (recursionFactory == null)
                throw new ArgumentNullException("recursionFactory");

            _recursionFactory = recursionFactory;
            _instantiator = instantiator;
        }
コード例 #17
0
ファイル: Viewer.cs プロジェクト: UnityProjIT/UnInventory
        public static Viewer Create <T>(IDatabaseNotifier databaseNotifier, IDatabaseReadOnly readOnlyDatabase,
                                        IInstantiator instantiator, IPositionsManager positioner, IBindComponentToDataDbRead bindComponentToDataDbRead)
            where T : Viewer, new()
        {
            var viewer = new T();

            viewer.Init(databaseNotifier, readOnlyDatabase, instantiator, positioner, bindComponentToDataDbRead);
            viewer.Subscribe();
            return(viewer);
        }
コード例 #18
0
        protected EnemySpawner(EnemyType handledType, IInstantiator instantiator, IEnemiesFactory enemiesFactory,
                               SignalBus signalBus)
        {
            this.enemiesFactory = enemiesFactory;
            this.instantiator   = instantiator;
            this.signalBus      = signalBus;
            this.handledType    = handledType;

            SubscribeToDestroySignal();
        }
コード例 #19
0
ファイル: Viewer.cs プロジェクト: UnityProjIT/UnInventory
 protected virtual void Init([NotNull] IDatabaseNotifier databaseNotifier, IDatabaseReadOnly readOnlyDatabase,
                             [NotNull] IInstantiator instantiator,
                             [NotNull] IPositionsManager positioner,
                             [NotNull] IBindComponentToDataDbRead bindComponentToDataDbRead)
 {
     _notifier                  = databaseNotifier ?? throw new ArgumentNullException(nameof(databaseNotifier));
     _readOnlyDatabase          = readOnlyDatabase;
     _instantiator              = instantiator ?? throw new ArgumentNullException(nameof(instantiator));
     _positioner                = positioner ?? throw new ArgumentNullException(nameof(positioner));
     _bindComponentToDataDbRead = bindComponentToDataDbRead;
 }
コード例 #20
0
 ExplosionViewResolver(
     IPoolManager poolManager,
     IEventSystem eventSystem,
     IInstantiator instantiator
     ) : base(
         poolManager,
         eventSystem,
         instantiator
         )
 {
     ViewPool.PreAllocate(20);
 }
コード例 #21
0
        private T Instantiate <T>(IInstantiator instantiator, GameObject prefab, Vector3 position, Quaternion rotation,
                                  Transform parent = null)
        {
            T component = default;

            if (prefab != null && instantiator != null)
            {
                component = instantiator.InstantiatePrefabForComponent <T>(prefab, position, rotation, parent);
            }

            return(component);
        }
コード例 #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Injector"/> class.
 /// </summary>
 /// <param name="instantiator">Instantiator for creation of new object instances</param>
 /// <param name="modules">Collection of binding modules backing this injector</param>
 /// <param name="debug">Enable for debug mode, which includes additional logging</param>
 public Injector(IInstantiator instantiator, IEnumerable <IModule> modules, bool debug = false)
 {
     _instance     = this;
     _instantiator = instantiator;
     _debug        = debug;
     _binder       = new Binder(_debug);
     // Allow injection of the Injector and Instantiator
     _binder.Install(new InjectorModule(this, instantiator));
     _binder.Install(modules);
     _binder.Configure();
     ConstructEagerSingletons();
 }
コード例 #23
0
        public void Init(GameObject dataEntityStandardPrefab)
        {
            DataEntityStandardPrefab = dataEntityStandardPrefab;

            LoadBasic();
            Commands = LoadCommandsFactory();
            BindDataEntitiesToPrefabs();
            BindPrimaryCommandsToExecute();
            Instantiator            = LoadInstantiator();
            CommandPrimaryExtension = LoadCommandPrimaryExtension();
            LoadBindComponentToDataDbReadAndWrite();
            Viewer = LoadViewer();
        }
コード例 #24
0
        public CachingObjectContextFactory(IInstantiator instantiator, IObjectContextInfoFactory objectContextInfoFactory, IObjectContextFactory recursionFactory)
        {
            if (instantiator == null)
                throw new ArgumentNullException("instantiator");
            if (objectContextInfoFactory == null)
                throw new ArgumentNullException("objectContextInfoFactory");
            if (recursionFactory == null)
                throw new ArgumentNullException("recursionFactory");

            _instantiator = instantiator;
            _objectContextInfoFactory = objectContextInfoFactory;
            _recursionFactory = recursionFactory;
        }
コード例 #25
0
        public Container(IContainer parent, IBinder binder, IResolver resolver, IInjector injector, IInstantiator instantiator)
        {
            this.parent       = parent;
            this.binder       = binder ?? new Binder(this);
            this.resolver     = resolver ?? new Resolver(this);
            this.injector     = injector ?? new Injector(this);
            this.instantiator = instantiator ?? new Instantiator(this);

            Binder.Bind(GetType(), typeof(IContainer)).ToInstance(this);
            Binder.Bind(this.binder.GetType(), typeof(IBinder)).ToInstance(this.binder);
            Binder.Bind(this.resolver.GetType(), typeof(IResolver)).ToInstance(this.resolver);
            Binder.Bind(this.injector.GetType(), typeof(IInjector)).ToInstance(this.injector);
            Binder.Bind(this.instantiator.GetType(), typeof(IInstantiator)).ToInstance(this.instantiator);
        }
コード例 #26
0
        public HitScoreViewResolver(
            IPoolManager poolManager,
            IEventSystem eventSystem,
            IInstantiator instantiator
            ) : base(
                poolManager,
                eventSystem,
                instantiator
                )
        {
            _canvas = GameObject.Find("Canvas");

            ViewPool.PreAllocate(10);
        }
コード例 #27
0
ファイル: ConcurrentObjects.cs プロジェクト: afrog33k/Excess
        public Node(int threads, IDictionary <string, Spawner> types, IDictionary <string, ConcurrentObject> singletons)
        {
            _threads      = threads;
            _types        = types;
            _instantiator = new Instantiator(this);
            _singletons   = singletons;
            foreach (var singleton in singletons)
            {
                singleton.Value.startRunning(this, new object[] { });
            }

            Debug.Assert(_threads > 0);
            createThreads(_threads);
        }
コード例 #28
0
ファイル: Container.cs プロジェクト: Magicolo/PseudoFramework
        public Container(IContainer parent, IBinder binder, IResolver resolver, IInjector injector, IInstantiator instantiator)
        {
            this.parent = parent;
            this.binder = binder ?? new Binder(this);
            this.resolver = resolver ?? new Resolver(this);
            this.injector = injector ?? new Injector(this);
            this.instantiator = instantiator ?? new Instantiator(this);

            Binder.Bind(GetType(), typeof(IContainer)).ToInstance(this);
            Binder.Bind(this.binder.GetType(), typeof(IBinder)).ToInstance(this.binder);
            Binder.Bind(this.resolver.GetType(), typeof(IResolver)).ToInstance(this.resolver);
            Binder.Bind(this.injector.GetType(), typeof(IInjector)).ToInstance(this.injector);
            Binder.Bind(this.instantiator.GetType(), typeof(IInstantiator)).ToInstance(this.instantiator);
        }
コード例 #29
0
    /// <summary>
    /// Create a pool container. Pools reduce instantiation by storing references to inactive
    /// Components. You can also provide a transform to parent the instantiated objects,
    /// and an initial capacity of prefabs to instantiate as active.
    /// </summary>
    public Pool(IInstantiator <T> instantiator, IActivator <T> activator, Transform parent = null, int preloadCount = -1)
    {
        SetInstantiator(instantiator);
        SetActivator(activator);
        m_parent = parent;

        m_reserveList = new List <T>(Mathf.Max(preloadCount, 0));
        m_activeList  = new List <T>(Mathf.Max(preloadCount, 0));

        if (preloadCount > 0)
        {
            AddToReserve(preloadCount);
        }
    }
コード例 #30
0
 public ThreadedConcurrentApp(FactoryMap types           = null,
                              IInstantiator instantiator = null,
                              int threadCount            = 1,
                              bool blockUntilNextEvent   = true,
                              ThreadPriority priority    = ThreadPriority.Normal,
                              int stopCount = 1) : base(types, instantiator)
 {
     _threadCount = threadCount;
     _priority    = priority;
     _stopCount   = stopCount;
     if (blockUntilNextEvent)
     {
         _blockUntilNextEvent = new ManualResetEvent(false);
     }
 }
コード例 #31
0
ファイル: ViewHandler.cs プロジェクト: yy1985710/ecsrx
        protected ViewHandler(IPoolManager poolManager, IEventSystem eventSystem, IInstantiator instantiator)
        {
            PoolManager  = poolManager;
            EventSystem  = eventSystem;
            Instantiator = instantiator;

            _viewCache = new Dictionary <Guid, GameObject>();

            _destructionSubscription = EventSystem.Receive <ComponentRemovedEvent>()
                                       .Where(x => x.Component is ViewComponent && _viewCache.ContainsKey(x.Entity.Id))
                                       .Subscribe(x =>
            {
                var view = _viewCache[x.Entity.Id];
                _viewCache.Remove(x.Entity.Id);
                DestroyView(view);
            });
        }
コード例 #32
0
        public NavigationComponent(NavMeshAgent agent, IEnumerable <DestinationPoint> destinationPoints,
                                   Transform mainTransform, Transform syncTransform, HealthController healthController,
                                   WinLoseController winLoseController, GameObject hitEffect, IInstantiator instantiator)
        {
            _agent             = agent;
            _mainTransform     = mainTransform;
            _syncTransform     = syncTransform;
            _healthController  = healthController;
            _winLoseController = winLoseController;
            _hitEffect         = hitEffect;
            _instantiator      = instantiator;

            var random = new System.Random();

            _destination = destinationPoints.OrderBy(x => random.Next()).First();
            mainTransform.LookAt(_destination.transform.position);
        }
コード例 #33
0
ファイル: AppOpenTk.cs プロジェクト: MeltyPlayer/FinCSharp
        public AppOpenTk()
        {
            new DiscardableNodeFactoryImpl(
                root => this.rootDiscardableNode_ = root);

            this.Audio          = new AudioOpenTk(this.rootDiscardableNode_);
            this.Instantiator   = new InstantiatorImpl(this.rootDiscardableNode_);
            this.windowManager_ =
                new WindowManagerOpenTk(this, this.rootDiscardableNode_);

            this.root_ = this.Instantiator.NewRoot();

            var settings = Settings.Load();

            this.ticker_ =
                RecurrentCaller.FromFrequency(settings.Framerate,
                                              this.CompileTick_());
        }
コード例 #34
0
		protected internal AbstractComponentTuplizer(Mapping.Component component)
		{
			propertySpan = component.PropertySpan;
			getters = new IGetter[propertySpan];
			setters = new ISetter[propertySpan];

			bool foundCustomAccessor = false;
			int i = 0;
			foreach (Mapping.Property prop in component.PropertyIterator)
			{
				getters[i] = BuildGetter(component, prop);
				setters[i] = BuildSetter(component, prop);
				if (!prop.IsBasicPropertyAccessor)
				{
					foundCustomAccessor = true;
				}
				i++;				
			}
			if (log.IsDebugEnabled)
			{
				log.DebugFormat("{0} accessors found for component: {1}", foundCustomAccessor ? "Custom" : "No custom",
				                component.ComponentClassName);
			}
			hasCustomAccessors = foundCustomAccessor;

			// Only to be secure that we can access to every things
			string[] getterNames = new string[propertySpan];
			string[] setterNames = new string[propertySpan];
			System.Type[] propTypes = new System.Type[propertySpan];
			for (int j = 0; j < propertySpan; j++)
			{
				getterNames[j] = getters[j].PropertyName;
				setterNames[j] = setters[j].PropertyName;
				propTypes[j] = getters[j].ReturnType;
			}

			instantiator = BuildInstantiator(component);
		}
コード例 #35
0
ファイル: ShipStateDead.cs プロジェクト: Aszan/Zenject
 public ShipStateDead(Settings settings, Ship ship, IInstantiator gameObjectCreator)
     : base(ship)
 {
     _settings = settings;
     _gameObjectCreator = gameObjectCreator;
 }
コード例 #36
0
        /// <summary> Constructs a new AbstractEntityTuplizer instance. </summary>
        /// <param name="entityMetamodel">The "interpreted" information relating to the mapped entity. </param>
        /// <param name="mappingInfo">The parsed "raw" mapping data relating to the given entity. </param>
        public AbstractEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappingInfo)
        {
            this.entityMetamodel = entityMetamodel;

            if (!entityMetamodel.IdentifierProperty.IsVirtual)
            {
                idGetter = BuildPropertyGetter(mappingInfo.IdentifierProperty, mappingInfo);
                idSetter = BuildPropertySetter(mappingInfo.IdentifierProperty, mappingInfo);
            }
            else
            {
                idGetter = null;
                idSetter = null;
            }

            propertySpan = entityMetamodel.PropertySpan;

            getters = new IGetter[propertySpan];
            setters = new ISetter[propertySpan];

            bool foundCustomAccessor = false;
            int i = 0;
            foreach (Mapping.Property property in mappingInfo.PropertyClosureIterator)
            {
                getters[i] = BuildPropertyGetter(property, mappingInfo);
                setters[i] = BuildPropertySetter(property, mappingInfo);
                if (!property.IsBasicPropertyAccessor)
                    foundCustomAccessor = true;
                i++;
            }
            if (log.IsDebugEnabled)
            {
                log.DebugFormat("{0} accessors found for entity: {1}", foundCustomAccessor ? "Custom" : "No custom",
                                mappingInfo.EntityName);
            }
            hasCustomAccessors = foundCustomAccessor;

            instantiator = BuildInstantiator(mappingInfo);

            if (entityMetamodel.IsLazy)
            {
                /* NH Different implementation
                 * When we are using an interface we need to use the interface itself to have
                 * the getter and setter of the identifier to prevent proxy initialization.
                 * The BasicLazyInitializer use method.Equals to recognize the the identifier setter.
                 */
                IGetter pidGetter = idGetter;
                ISetter pidSetter = idSetter;
                if (mappingInfo.HasIdentifierProperty && mappingInfo.ProxyInterface != null)
                {
                    pidGetter = mappingInfo.IdentifierProperty.GetGetter(mappingInfo.ProxyInterface);
                    pidSetter = mappingInfo.IdentifierProperty.GetSetter(mappingInfo.ProxyInterface);
                }
                proxyFactory = BuildProxyFactory(mappingInfo, pidGetter, pidSetter);
                /*******************************************************************************/
                if (proxyFactory == null)
                {
                    entityMetamodel.IsLazy = false;
                }
            }
            else
            {
                proxyFactory = null;
            }

            Mapping.Component mapper = mappingInfo.IdentifierMapper;
            identifierMapperType = mapper == null ? null : (IAbstractComponentType)mapper.Type;
        }
コード例 #37
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PlanetSystemSpawner"/> class.
        /// </summary>
        /// <param name="instantiator">The instantiator.</param>
        /// <param name="initialPlanetSystemPosition">The initial planet system position.</param>
        /// <param name="characterPlanetSystemPrefab">The character planet system prefab.</param>
        /// <param name="comicPlanetSystemPrefab">The comic planet system prefab.</param>
        /// <param name="creatorPlanetSystemPrefab">The creator planet system prefab.</param>
        /// <param name="eventPlanetSystemPrefab">The event planet system prefab.</param>
        /// <param name="seriesPlanetSystemPrefab">The series planet system prefab.</param>
        /// <param name="spawnSphereRadius">The spawn sphere radius.</param>
        /// <param name="planetSystemSize">The planet system size.</param>
        /// <param name="planetSize">The planet size.</param>
        /// <param name="mainCamera">The main camera.</param>
        public PlanetSystemSpawner(
            IInstantiator instantiator,
            Vector3 initialPlanetSystemPosition,
            GameObject characterPlanetSystemPrefab,
            GameObject comicPlanetSystemPrefab,
            GameObject creatorPlanetSystemPrefab,
            GameObject eventPlanetSystemPrefab,
            GameObject seriesPlanetSystemPrefab,           
            int spawnSphereRadius,
            float planetSystemSize,
            Vector3 planetSize,
            Camera mainCamera)
        {
            this.instantiator = instantiator;

            this.initialPlanetSystemPosition = initialPlanetSystemPosition;

            this.characterPlanetSystemPrefab = characterPlanetSystemPrefab;
            this.comicPlanetSystemPrefab = comicPlanetSystemPrefab;
            this.creatorPlanetSystemPrefab = creatorPlanetSystemPrefab;
            this.eventPlanetSystemPrefab = eventPlanetSystemPrefab;
            this.seriesPlanetSystemPrefab = seriesPlanetSystemPrefab;

            this.spawnSphereRadius = spawnSphereRadius;
            this.planetSystemSize = planetSystemSize;
            this.planetSize = planetSize;
            this.mainCamera = mainCamera;
        }
コード例 #38
0
		public NetReflectorTypeTable(IInstantiator instantiator)
		{
			this.instantiator = instantiator;
			InvalidNode = new InvalidNodeEventHandler(NullHandler);
		}
コード例 #39
0
		public static NetReflectorTypeTable CreateDefault(IInstantiator instantiator)
		{
			NetReflectorTypeTable table = new NetReflectorTypeTable(instantiator);
			SetupDefaultTable(table);
			return table;
		}
コード例 #40
0
 public ValueInjectorUnFlattenMapper(LazyService<IMapper> mapper, IInstantiator instantiator)
 {
     this.lazyMapper = mapper;
     this.instantiator = instantiator;
 }
コード例 #41
0
		public XmlTypeSerialiser(Type type, ReflectorTypeAttribute attribute, IInstantiator instantiator)
		{
			this.type = type;
			this.attribute = attribute;
			this.instantiator = instantiator;
		}
コード例 #42
0
		public IXmlSerialiser CreateSerialiser(Type type, IInstantiator instantiator)
		{
			return new XmlTypeSerialiser(type, this, instantiator);
		}
コード例 #43
0
		public XmlMemberSerialiser(ReflectorMember member, ReflectorPropertyAttribute attribute)
		{
			this.member = member;
			this.attribute = attribute;
			this.instantiator = new DefaultInstantiator();
		}