コード例 #1
0
 public void RegisterComponent(CEntityComponent component)
 {
     if (!m_components.Contains(component))
     {
         m_components.Add(component);
     }
 }
コード例 #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);
        }
コード例 #3
0
        public void UnregisterComponent(CEntityComponent component)
        {
            m_components.Remove(component);

            if (m_rootComponent == component)
            {
                Detach();
                m_rootComponent = null;
            }
        }
コード例 #4
0
 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;
     }
 }
コード例 #5
0
 private static string GetComponentName(CEntityComponent component)
 {
     return(component.GetType().Name.Substring(1) + ++component.m_owner.ComponentCounter);
 }