public void TriggerCustomEvent2Component(Component.GComponent sender, int msg, object arg, [Editor.Editor_TypeFilterAttribute(typeof(Component.GComponent))] Type rcvCompType) { for (int i = 0; i < Components.Count; ++i) { var comp = Components[i]; if (comp.OnlyForGame && CIPlatform.Instance.PlayMode == CIPlatform.enPlayMode.Editor) { continue; } if (rcvCompType != null) { if (comp.GetType().IsSubclassOf(rcvCompType) == false && comp.GetType() != rcvCompType) { continue; } } if (comp.TriggerCustomEvent(sender, msg, arg) == true) { return; } } }
public override async Task <bool> LoadXnd(CRenderContext rc, GActor host, IComponentContainer hostContainer, XndNode node) { Host = host; if (false == await base.LoadXnd(rc, host, hostContainer, node)) { return(false); } var cpNodes = node.FindNode("CompChildren"); if (cpNodes != null) { Components.Clear(); var nodes = cpNodes.GetNodes(); foreach (var i in nodes) { var type = Rtti.RttiHelper.GetTypeFromSaveString(i.GetName()); if (type == null) { Profiler.Log.WriteLine(Profiler.ELogTag.Error, "ACC", $"Component {i.GetName()} is invalid"); continue; } Component.GComponent comp = Activator.CreateInstance(type) as Component.GComponent; if (false == await comp.LoadXnd(rc, Host, this, i)) { Profiler.Log.WriteLine(Profiler.ELogTag.Error, "ACC", $"Component {i.GetName()} load failed"); continue; } this.AddComponent(comp); } } return(true); }
public void RemoveComponent(Component.GComponent component) { if (Components.Contains(component)) { component.OnRemove(); component.Host = null; component.HostContainer = null; Components.Remove(component); } }
public void RemoveComponent(string specialName) { Component.GComponent old = FindComponentBySpecialName(specialName); if (old != null) { old.OnRemove(); old.Host = null; old.HostContainer = null; Components.Remove(old); } }
public Component.GComponent AddComponent(Component.GComponent comp) { if (!Components.Contains(comp)) { comp.Host = Host; comp.HostContainer = this; Components.Add(comp); comp.OnAdded(); return(null); } return(comp); }
public bool InsertComponent(int index, Component.GComponent comp) { if (!Components.Contains(comp)) { comp.Host = Host; comp.HostContainer = this; Components.Insert(index, comp); comp.OnAdded(); return(true); } else { return(false); } }
static void OnVisitComponent_SetPointLightsOnVisitComponent(Component.GComponent comp, object arg) { var meshComp = comp as Component.GMeshComponent; if (meshComp != null && meshComp.SceneMesh != null) { var actor = meshComp.Host; meshComp.SceneMesh.mMeshVars.SetPointLights(actor.AffectLights); return; } var skinMeshComp = comp as Component.GSubSkinComponent; if (skinMeshComp != null && skinMeshComp.SceneMesh != null) { var actor = skinMeshComp.Host; skinMeshComp.SceneMesh.mMeshVars.SetPointLights(actor.AffectLights); return; } }
public void TriggerCustomEvent(Component.GComponent sender, int msg, object arg) { if (mMcActorGetter != null) { if (mMcActorGetter.Get(OnlyForGame).OnTriggerCustomEvent(sender, msg, arg) == true) { return; } } for (int i = 0; i < Components.Count; ++i) { var comp = Components[i]; if (comp.OnlyForGame && CIPlatform.Instance.PlayMode == CIPlatform.enPlayMode.Editor) { continue; } if (comp.TriggerCustomEvent(sender, msg, arg) == true) { return; } } }
public virtual bool OnTriggerCustomEvent(Component.GComponent sender, int msg, object arg) { return(false); }