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(); }
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); }
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); }
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); } } }