Exemple #1
0
 public void RegisterComponent(CEntityComponent component)
 {
     if (!m_components.Contains(component))
     {
         m_components.Add(component);
     }
 }
Exemple #2
0
        public CEntityComponent AddComponent(Type type, bool bAutoAttach, bool bInitComponent)
        {
            if (!type.IsSubclassOf(typeof(CEntityComponent)))
            {
                return(null);
            }

            CEntityComponent component = Activator.CreateInstance(type) as CEntityComponent;

            if (component != null)
            {
                component.RegisterComponent(this);
                m_guidToComponent.Add(component.ComponentGuid, component);

                if (bAutoAttach && component is CSceneComponent sceneComponent)
                {
                    AttachComponent(sceneComponent);
                }

                if (bInitComponent)
                {
                    component.Init();
                }

                return(component);
            }

            return(null);
        }
Exemple #3
0
        public void UnregisterComponent(CEntityComponent component)
        {
            m_components.Remove(component);

            if (m_rootComponent == component)
            {
                Detach();
                m_rootComponent = null;
            }
        }
 public SEntityComponentId(CEntityComponent component, bool bOverrideComponent = false)
 {
     if (bOverrideComponent)
     {
         OverrideComponent = component;
         EntityId          = SEntityId.Invalid;
         ComponentId       = 0;
     }
     else
     {
         EntityId          = new SEntityId(component.Owner.Id);
         ComponentId       = component.Id;
         OverrideComponent = null;
     }
 }
 private static string GetComponentName(CEntityComponent component)
 {
     return(component.GetType().Name.Substring(1) + ++component.m_owner.ComponentCounter);
 }