예제 #1
0
        protected void Internal_AddComponent(Actor actor, ObjectScript compScript)
        {
            //Does the component already exist on the actor?  If it does, just apply this script.
            string CompName = compScript.FindObjectName();

            if (CompName != null && actor.HasComponent(CompName))
            {
                compScript.ApplyToObject(actor.GetComponentByName(CompName));
                return;
            }

            //Otherwise we create the Component
            ActorComponent AC = compScript.CreateInstance <ActorComponent>();

            AC.Owner = actor;
            AC.Register();
        }
예제 #2
0
        public string FindObjectName()
        {
            ObjectScript SearchScript = this;
            string       FoundName    = ObjectName;

            while (FoundName == null)
            {
                SearchScript = SearchScript.ParentScript;
                if (SearchScript == null)
                {
                    return(null);
                }
                FoundName = SearchScript.ObjectName;
            }

            return(FoundName);
        }
예제 #3
0
        public Type FindNativeClass()
        {
            ObjectScript SearchScript     = this;
            Type         FoundNativeClass = NativeClass;

            while (FoundNativeClass == null)
            {
                SearchScript = SearchScript.ParentScript;
                if (SearchScript == null)
                {
                    return(null);
                }
                FoundNativeClass = SearchScript.NativeClass;
            }

            return(FoundNativeClass);
        }
예제 #4
0
        protected override void Internal_ApplyToObject(object obj)
        {
            base.Internal_ApplyToObject(obj);

            Actor actor = obj as Actor;

            if (JObject.ContainsKey(ComponentEntryName) && JObject[ComponentEntryName] is JArray)
            {
                JArray ComponetArray = JObject[ComponentEntryName] as JArray;
                foreach (JObject jo in ComponetArray)
                {
                    ObjectScript compscript = new ObjectScript()
                    {
                        JObject = jo
                    };

                    Internal_AddComponent(actor, compscript);
                }
            }
        }