void container_ComponentRemoved(Type type, MyEntityComponentBase comp)
 {
     if (type == typeof(MySyncComponentBase))
         m_syncObject = null;
     else if (type == typeof(MyPhysicsComponentBase))
         m_physics = null;
     else if (type == typeof(MyHierarchyComponentBase))
         m_hierarchy = null;
 }
Example #2
0
 public override void OnAddedToContainer()
 {
     base.OnAddedToContainer();
     m_syncObject                = Container.Get <MySyncComponentBase>();
     m_physics                   = Container.Get <MyPhysicsComponentBase>();
     m_hierarchy                 = Container.Get <MyHierarchyComponentBase>();
     Container.ComponentAdded   += container_ComponentAdded;
     Container.ComponentRemoved += container_ComponentRemoved;
 }
 void container_ComponentAdded(Type type, MyEntityComponentBase 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 override void OnAddedToContainer()
 {
     base.OnAddedToContainer();
     m_syncObject = Container.Get<MySyncComponentBase>();
     m_physics = Container.Get<MyPhysicsComponentBase>();
     m_hierarchy = Container.Get<MyHierarchyComponentBase>();
     Container.ComponentAdded += container_ComponentAdded;
     Container.ComponentRemoved += container_ComponentRemoved;
 }
Example #5
0
 void container_ComponentRemoved(Type type, MyEntityComponentBase comp)
 {
     if (type == typeof(MySyncComponentBase))
     {
         m_syncObject = null;
     }
     else if (type == typeof(MyPhysicsComponentBase))
     {
         m_physics = null;
     }
     else if (type == typeof(MyHierarchyComponentBase))
     {
         m_hierarchy = null;
     }
 }
Example #6
0
 void container_ComponentAdded(Type type, MyEntityComponentBase 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;
     }
 }
Example #7
0
 void Components_ComponentRemoved(Type t, MyEntityComponentBase c)
 {
     // TODO: see comment at Components_ComponentAdded
     if ((typeof(MyPhysicsComponentBase)).IsAssignableFrom(t))
         m_physics = null;
     else if ((typeof(MySyncComponentBase)).IsAssignableFrom(t))
         m_syncObject = null;
     else if ((typeof(MyGameLogicComponent)).IsAssignableFrom(t))
         m_gameLogic = null;
     else if ((typeof(MyPositionComponentBase)).IsAssignableFrom(t))
         PositionComp = new VRage.Game.Components.MyNullPositionComponent();
     else if ((typeof(MyHierarchyComponentBase)).IsAssignableFrom(t))
         m_hierarchy = null;
     else if ((typeof(MyRenderComponentBase)).IsAssignableFrom(t))
     {
         Render = new VRage.Game.Components.MyNullRenderComponent();
     }
     else if ((typeof(MyInventoryBase)).IsAssignableFrom(t))
     {
         OnInventoryComponentRemoved(c as MyInventoryBase);
     }
 }
Example #8
0
 void Components_ComponentAdded(Type t, MyEntityComponentBase c)
 {
     // TODO: this has to be refactored because it is very dangerous - each component member set here can be overwritten with new one of the same base type
     // (assume more than one GameLogicComponent), components should support aggregates (parameter can be added to MyComponentTypeAttribute).
     if ((typeof(MyPhysicsComponentBase)).IsAssignableFrom(t))
         m_physics = c as MyPhysicsComponentBase;
     else if ((typeof(MySyncComponentBase)).IsAssignableFrom(t))
         m_syncObject = c as MySyncComponentBase;
     else if ((typeof(MyGameLogicComponent)).IsAssignableFrom(t))
         m_gameLogic = c as MyGameLogicComponent;
     else if ((typeof(MyPositionComponentBase)).IsAssignableFrom(t))
     {
         m_position = c as MyPositionComponentBase;
         if (m_position == null)
             PositionComp = new VRage.Game.Components.MyNullPositionComponent();
     }
     else if ((typeof(MyHierarchyComponentBase)).IsAssignableFrom(t))
         m_hierarchy = c as MyHierarchyComponent<MyEntity>;
     else if ((typeof(MyRenderComponentBase)).IsAssignableFrom(t))
     {
         m_render = c as MyRenderComponentBase;
         if (m_render == null)
             Render = new VRage.Game.Components.MyNullRenderComponent();
     }
     else if ((typeof(MyInventoryBase)).IsAssignableFrom(t))
     {
         OnInventoryComponentAdded(c as MyInventoryBase);
     }
 }
 public void Unregister(MyPhysicsComponentBase component)
 {
     m_physicsComponents.Remove(component);
 }
 public void Register(MyPhysicsComponentBase component)
 {
     m_physicsComponents.Add(component);
 }
 public void Weld(MyPhysicsComponentBase other, bool recreateShape = true)
 {
     Weld(other as MyPhysicsBody, recreateShape);
 }