コード例 #1
0
        public static Component Create(Entity behaviorTreeParent, HotfixConditional hotfixConditional)
        {
            try
            {
                var behaviorTreeConfig = (BehaviorTreeConfig)Game.Scene.GetComponent <ConfigComponent>().Get(typeof(BehaviorTreeConfig), hotfixConditional.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, hotfixConditional, behaviorTreeConfig);

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

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

            return(null);
        }
コード例 #2
0
        public static Entity Create(Entity behaviorTreeParent, HotfixConditional hotfixConditional)
        {
            try
            {
                var behaviorTreeConfig = (BehaviorTreeConfig)Game.Scene.GetComponent <ConfigComponent>().Get(typeof(BehaviorTreeConfig), hotfixConditional.behaviorTreeConfigID);

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

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

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

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

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

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

            return(null);
        }