コード例 #1
0
        public static Component Create(Entity behaviorTreeParent, HotfixComposite hotfixComposite)
        {
            try
            {
                var behaviorTreeConfig = (BehaviorTreeConfig)Game.Scene.GetComponent <ConfigComponent>().Get(typeof(BehaviorTreeConfig), hotfixComposite.behaviorTreeConfigID);

                var type = Type.GetType($"ETHotfix.{behaviorTreeConfig.ComponentName}");

                Component component = Game.ObjectPool.Fetch(type);

                ComponentWithId componentWithId = component as ComponentWithId;

                if (componentWithId != null)
                {
                    componentWithId.Id = component.InstanceId;
                }

                Game.EventSystem.Awake(component, behaviorTreeParent, hotfixComposite, behaviorTreeConfig);

                if (string.Equals(hotfixComposite.FriendlyName, "Hotfix Composite"))
                {
                    hotfixComposite.FriendlyName = behaviorTreeConfig.Name;
                }

                return(component);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }

            return(null);
        }
コード例 #2
0
ファイル: BehaviorTreeFactory.cs プロジェクト: x1766233/DCET
        public static Entity Create(Entity behaviorTreeParent, HotfixComposite hotfixComposite)
        {
            try
            {
                var behaviorTreeConfig = (BehaviorTreeConfig)Game.Scene.GetComponent <ConfigComponent>().Get(typeof(BehaviorTreeConfig), hotfixComposite.behaviorTreeConfigID);

                var type = Type.GetType($"DCET.Hotfix.{behaviorTreeConfig.ComponentName}");

                var component = Game.ObjectPool.Fetch(type);

                component.Domain = behaviorTreeParent.Domain;
                component.Id     = behaviorTreeParent.Id;

                Game.EventSystem.Awake(component, behaviorTreeParent, hotfixComposite, behaviorTreeConfig);

                if (string.Equals(hotfixComposite.FriendlyName, "Hotfix Composite"))
                {
                    hotfixComposite.FriendlyName = behaviorTreeConfig.Name;
                }

                return(component);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }

            return(null);
        }