Example #1
0
 void Components_ComponentRemoved(Type t, Sandbox.Common.Components.MyComponentBase c)
 {
     if (t == typeof(MyPhysicsComponentBase))
     {
         m_physics = null;
     }
     else if (t == typeof(MySyncComponentBase))
     {
         m_syncObject = null;
     }
     else if (t == typeof(MyGameLogicComponent))
     {
         m_gameLogic = null;
     }
     else if (t == typeof(MyPositionComponentBase))
     {
         m_position = null;
     }
     else if (t == typeof(MyHierarchyComponentBase))
     {
         m_hierarchy = null;
     }
     else if (t == typeof(MyRenderComponentBase))
     {
         m_render = null;
     }
 }
Example #2
0
 void Components_ComponentAdded(Type t, Sandbox.Common.Components.MyComponentBase c)
 {
     if (t == typeof(MyPhysicsComponentBase))
     {
         m_physics = c as MyPhysicsBody;
     }
     else if (t == typeof(MySyncComponentBase))
     {
         m_syncObject = c as MySyncComponentBase;
     }
     else if (t == typeof(MyGameLogicComponent))
     {
         m_gameLogic = c as MyGameLogicComponent;
     }
     else if (t == typeof(MyPositionComponentBase))
     {
         m_position = c as MyPositionComponentBase;
     }
     else if (t == typeof(MyHierarchyComponentBase))
     {
         m_hierarchy = c as MyHierarchyComponentBase;
     }
     else if (t == typeof(MyRenderComponentBase))
     {
         m_render = c as MyRenderComponentBase;
     }
 }
 void container_ComponentRemoved(Type type, MyComponentBase comp)
 {
     if (type == typeof(MySyncComponentBase))
         m_syncObject = null;
     else if (type == typeof(MyPhysicsComponentBase))
         m_physics = null;
     else if (type == typeof(MyHierarchyComponentBase))
         m_hierarchy = null;
 }
 void container_ComponentAdded(Type type, MyComponentBase comp)
 {
     if (type == typeof(MySyncComponentBase))
         m_syncObject = comp as MySyncComponentBase;
     else if (type == typeof(MyPhysicsComponentBase))
         m_physics = comp as MyPhysicsComponentBase;
     else if (type == typeof(MyHierarchyComponentBase))
         m_hierarchy = comp as MyHierarchyComponentBase;
 }
        public void Add <T>(MyComponentBase component) where T : MyComponentBase
        {
#if DEBUG
            using (Stats.Generic.Measure("ComponentContainer.Add", VRage.Stats.MyStatTypeEnum.Counter, 1000, numDecimals: 3))
                using (Stats.Generic.Measure("ComponentContainer.AddMs", VRage.Stats.MyStatTypeEnum.Max, 1000, numDecimals: 3))
#endif
            {
                Type t = typeof(T);
                Remove <T>();
                if (component != null)
                {
                    m_components[t] = component;
                    component.OnAddedToContainer(this);
                    var handle = ComponentAdded;
                    if (handle != null)
                    {
                        handle(t, component);
                    }
                }
            }
        }
Example #6
0
 void Components_ComponentAdded(Type arg1, MyComponentBase arg2)
 {
     if (arg1 == typeof(MyGameLogicComponent))
         m_debrisLogic = arg2 as MyDebrisBaseLogic;
 }