コード例 #1
0
        public TComponent Add <TComponent>() where TComponent : class, IStateComponent, new()
        {
            var comp = new TComponent();

            _components.Add(typeof(TComponent), comp);
            return(comp);
        }
コード例 #2
0
        public TComponent instantiate <TComponent>() where TComponent : MonoBehaviour
        {
            GameObject game_object = get_from_pool();
            TComponent component   = game_object.GetComponent <TComponent>();

            return(component);
        }
コード例 #3
0
ファイル: Prefab.cs プロジェクト: Vorlias/Andromeda
        /// <summary>
        /// Creates a prefab with the specified component
        /// </summary>
        /// <typeparam name="TComponent">The component</typeparam>
        /// <returns>A prefab with the specified component</returns>
        public static Prefab Create <TComponent>() where TComponent : IComponent, new()
        {
            Prefab     pfb = Create();
            TComponent tc  = pfb.original.AddComponent <TComponent>();

            return(pfb);
        }
コード例 #4
0
            public void Execute([ReadOnly] DynamicBuffer <TSnapshot> snapshots, ref TComponent component, ref Predicted <TSnapshot> predictedData, ref GhostPredictedComponent globalPredicted)
            {
                snapshots.GetDataAtTick(targetTick, out var snapshotData);

                var lastPredictedTickInst = lastPredictTick;

                if (lastPredictedTickInst == 0 || predictedData.AppliedTick != snapshotData.Tick)
                {
                    lastPredictedTickInst = snapshotData.Tick;
                }
                else if (!SequenceHelpers.IsNewer(lastPredictedTickInst, snapshotData.Tick))
                {
                    lastPredictedTickInst = snapshotData.Tick;
                }
                if (minPredictedTick[ThreadIndex] == 0 || SequenceHelpers.IsNewer(minPredictedTick[ThreadIndex], lastPredictedTickInst))
                {
                    minPredictedTick[ThreadIndex] = lastPredictedTickInst;
                }

                predictedData = new Predicted <TSnapshot> {
                    AppliedTick = snapshotData.Tick, PredictionStartTick = lastPredictedTickInst
                };
                globalPredicted.AppliedTick         = predictedData.AppliedTick;
                globalPredicted.PredictionStartTick = predictedData.PredictionStartTick;

                if (lastPredictedTickInst != snapshotData.Tick)
                {
                    return;
                }

                snapshotData.SynchronizeTo(ref component, jobData);
            }
コード例 #5
0
        public TComponent Page <TComponent>()
            where TComponent : BasePage, new()
        {
            var page = new TComponent();

            page.Init(this);
            return(page);
        }
コード例 #6
0
ファイル: Entity.cs プロジェクト: tatelax/LazyECS
        /// <summary>
        /// Add component by type
        /// </summary>
        /// <typeparam name="TComponent">Component type</typeparam>
        /// <returns></returns>
        public TComponent Add <TComponent>() where TComponent : IComponent, new()
        {
            TComponent component = new TComponent();

            Components.Add(component.GetType(), component);

            OnComponentAdded?.Invoke(this, component);
            return(component);
        }
コード例 #7
0
        public void RemoveComponent <TComponent>() where TComponent : class, T
        {
            TComponent component = this.GetComponent <TComponent>();

            if ((object)component == null)
            {
                return;
            }
            this.RemoveComponent((T)component);
        }
コード例 #8
0
            public SelectionData(TData _data, TComponent _item, bool _isSelected = false)
            {
                data = _data;
                item = _item;

                this._isSelected = !_isSelected;
                isSelected       = _isSelected;

                _item.SetData(_data);
            }
コード例 #9
0
        public TComponent AddComponent <TComponent>() where TComponent : IComponent
        {
            if (Entity.HasComponent <TComponent>())
            {
                return(Entity.GetComponent <TComponent>());
            }
            TComponent component = (TComponent)_resolver.Container.Resolve(typeof(TComponent));

            Entity.AddComponent <TComponent>(component);
            return(component);
        }
コード例 #10
0
        /// <summary>
        /// Add an entity that has the specified component in it
        /// </summary>
        /// <typeparam name="TComponent">The component</typeparam>
        /// <returns></returns>
        public TComponent Add <TComponent>() where  TComponent : IComponent, new()
        {
            Entity entity = new Entity();

            entity.Name = typeof(TComponent).Name;

            TComponent com = entity.AddComponent <TComponent>();

            entity.SetParent(this);
            return(com);
        }
コード例 #11
0
ファイル: Entity.cs プロジェクト: nikkiwritescode/ECS
        public IComponent GetComponent <TComponent>()
            where TComponent : IComponent
        {
            TComponent match = Components.OfType <TComponent>().FirstOrDefault();

            if (match != null)
            {
                return((TComponent)match);
            }

            throw new Exception();
            //component does not exist
        }
コード例 #12
0
ファイル: Entity.cs プロジェクト: ulisses177/Work
        /// <summary>
        /// Ajoute un composant à l'entité. Si l'entité dispose déjà du composant, retourne null </summary>
        /// <param name="componentToAdd"></param>
        /// <returns></returns>
        public TComponent AddComponent(TComponent componentToAdd)
        {
            foreach (TComponent component in m_components)
            {
                if (component.Type == componentToAdd.Type)
                {
                    return(null);
                }
            }

            m_components.Add(componentToAdd);
            componentToAdd.Attach(this);
            return(componentToAdd);
        }
コード例 #13
0
ファイル: GameObject.cs プロジェクト: swordlegend/uberstrok
        public TComponent AddComponent <TComponent>() where TComponent : Component, new()
        {
            var type = typeof(TComponent);

            if (_components.ContainsKey(type))
            {
                throw new InvalidOperationException("Component already exists.");
            }

            var component = new TComponent();

            component._gameObject = this;
            _components.Add(type, component);
            return(component);
        }
コード例 #14
0
ファイル: GridRow.cs プロジェクト: lambertj/BELLATRIX
        public IEnumerable <TComponent> GetCells <TComponent>()
            where TComponent : Component, new()
        {
            var listOfElements = new List <TComponent>();
            var cells          = GetCells().ToList();

            for (int columnIndex = 0; columnIndex < cells.Count; columnIndex++)
            {
                var        cell    = cells[columnIndex];
                TComponent element = new TComponent();
                if (cell.CellControlComponentType == null)
                {
                    listOfElements.Add(cell.As <TComponent>());
                }
                else
                {
                    var repo = new ComponentRepository();
                    element = repo.CreateComponentWithParent(cell.CellControlBy, cell.WrappedElement, typeof(TComponent), false);
                    listOfElements.Add(element);
                }
            }

            return(listOfElements);
        }
コード例 #15
0
 /// <summary>
 /// Initializes a new <see cref="TNewComboBox"/>
 /// </summary>
 /// <param name="AOwner">The owner component</param>
 public TNewComboBox(TComponent AOwner) : base(AOwner)
 {
 }
コード例 #16
0
 /// <summary>
 /// Inno Setup <a href="https://jrsoftware.org/ishelp/index.php?topic=scriptclasses">Documentation</a>
 /// </summary>
 public new static TUIStateForm CreateNew(TComponent AOwner) => null;
コード例 #17
0
 /// <summary>
 /// Initializes a new <see cref="TDownloadWizardPage"/>
 /// </summary>
 /// <param name="AOwner">The owner component</param>
 public TDownloadWizardPage(TComponent AOwner) : base(AOwner)
 {
 }
コード例 #18
0
 /// <summary>
 /// Inno Setup <a href="https://jrsoftware.org/ishelp/index.php?topic=scriptclasses">Documentation</a>
 /// </summary>
 public static TForm CreateNew(TComponent AOwner) => null;
コード例 #19
0
 /// <summary>
 /// Initializes a new <see cref="TForm"/>
 /// </summary>
 /// <param name="AOwner">The owner component</param>
 public TForm(TComponent AOwner) : base(AOwner)
 {
 }
コード例 #20
0
 /// <summary>
 /// Initializes a new <see cref="TNewListBox"/>
 /// </summary>
 /// <param name="AOwner">The owner component</param>
 public TNewListBox(TComponent AOwner) : base(AOwner)
 {
 }
コード例 #21
0
 /// <summary>
 /// Initializes a new <see cref="TNewNotebookPage"/>
 /// </summary>
 /// <param name="AOwner">The owner component</param>
 public TNewNotebookPage(TComponent AOwner) : base(AOwner)
 {
 }
コード例 #22
0
 /// <summary>
 /// Initializes a new <see cref="TNewButton"/>
 /// </summary>
 /// <param name="AOwner">The owner component</param>
 public TNewButton(TComponent AOwner) : base(AOwner)
 {
 }
コード例 #23
0
 /// <summary>
 /// Initializes a new <see cref="TWizardPage"/>
 /// </summary>
 /// <param name="AOwner">The owner component</param>
 public TWizardPage(TComponent AOwner) : base(AOwner)
 {
 }
コード例 #24
0
        public TComponent Get <TComponent>()
        {
            TComponent result = kernel.Get <TComponent>();

            return(result);
        }
コード例 #25
0
 /// <summary>
 /// Initializes a new <see cref="TOutputProgressWizardPage"/>
 /// </summary>
 /// <param name="AOwner">The owner component</param>
 public TOutputProgressWizardPage(TComponent AOwner) : base(AOwner)
 {
 }
コード例 #26
0
 /// <summary>
 /// Initializes a new <see cref="TCustomCheckBox"/>
 /// </summary>
 /// <param name="AOwner">The owner component</param>
 public TCustomCheckBox(TComponent AOwner) : base(AOwner)
 {
 }
コード例 #27
0
 /// <summary>
 /// Initializes a new <see cref="TGraphicControl"/>
 /// </summary>
 /// <param name="AOwner">The owner component</param>
 public TGraphicControl(TComponent AOwner) : base(AOwner)
 {
 }
コード例 #28
0
 /// <summary>
 /// Initializes a new <see cref="TWizardForm"/>
 /// </summary>
 /// <param name="AOwner">The owner component</param>
 public TWizardForm(TComponent AOwner) : base(AOwner)
 {
 }
コード例 #29
0
 /// <summary>
 /// Initializes a new <see cref="TCustomComboBox"/>
 /// </summary>
 /// <param name="AOwner">The owner component</param>
 public TCustomComboBox(TComponent AOwner) : base(AOwner)
 {
 }
コード例 #30
0
 /// <summary>
 /// Initializes a new <see cref="TMemo"/>
 /// </summary>
 /// <param name="AOwner">The owner component</param>
 public TMemo(TComponent AOwner) : base(AOwner)
 {
 }