Ejemplo n.º 1
0
        public override void LoadDetectorsFromModel()
        {
            base.m_detectors.Clear();
            this.m_detectorInteractiveObjects.Clear();
            if (this.m_detectorPhysics != null)
            {
                this.m_detectorPhysics.Close();
            }
            MyRenderComponentBase base2 = base.Container.Get <MyRenderComponentBase>();

            if (base2.GetModel() != null)
            {
                foreach (KeyValuePair <string, MyModelDummy> pair in base2.GetModel().Dummies)
                {
                    string dummyName = pair.Key.ToLower();
                    if (dummyName.StartsWith("detector_") && (dummyName.Length > "detector_".Length))
                    {
                        char[]   separator = new char[] { '_' };
                        string[] strArray  = dummyName.Split(separator);
                        if (strArray.Length >= 2)
                        {
                            this.AddDetector(strArray[1], dummyName, pair.Value);
                        }
                    }
                }
            }
            if (this.m_detectorInteractiveObjects.Count > 0)
            {
                this.RecreatePhysics();
            }
        }
Ejemplo n.º 2
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;
     }
 }
Ejemplo n.º 3
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;
     }
 }
Ejemplo n.º 4
0
 void Components_ComponentAdded(Type t, MyEntityComponentBase c)
 {
     if ((typeof(MyPhysicsComponentBase)).IsAssignableFrom(t))
     {
         m_physics = c as MyPhysicsBody;
     }
     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 MyNullPositionComponent();
         }
     }
     else if ((typeof(MyHierarchyComponentBase)).IsAssignableFrom(t))
     {
         m_hierarchy = c as MyHierarchyComponentBase;
     }
     else if ((typeof(MyRenderComponentBase)).IsAssignableFrom(t))
     {
         m_render = c as MyRenderComponentBase;
         if (m_render == null)
         {
             Render = new MyNullRenderComponent();
         }
     }
 }
Ejemplo n.º 5
0
 public static unsafe void CalculateBlockDepthBias(this MyRenderComponent renderComponent, MyCubeBlock block)
 {
     if (block.Hierarchy != null)
     {
         MyCompoundCubeBlock entity = block.Hierarchy.Parent.Entity as MyCompoundCubeBlock;
         if (entity != null)
         {
             bool *flagPtr = (bool *)stackalloc byte[0x40];
             foreach (MySlimBlock block3 in entity.GetBlocks())
             {
                 if (block3.FatBlock == null)
                 {
                     continue;
                 }
                 if (!ReferenceEquals(block3.FatBlock, block))
                 {
                     MyRenderComponentBase render = block3.FatBlock.Render;
                     if (render != null)
                     {
                         *((sbyte *)(flagPtr + render.DepthBias)) = 1;
                     }
                 }
             }
             int     num          = 0;
             MyModel modelStorage = renderComponent.ModelStorage as MyModel;
             if (modelStorage != null)
             {
                 Vector3 center = modelStorage.BoundingSphere.Center;
                 MatrixI matrix = new MatrixI(block.SlimBlock.Orientation);
                 Vector3 result = new Vector3();
                 Vector3.Transform(ref center, ref matrix, out result);
                 if (result.LengthSquared() > 0.5f)
                 {
                     num = (Math.Abs(result.X) <= Math.Abs(result.Y)) ? ((Math.Abs(result.Z) <= Math.Abs(result.Y)) ? ((result.Y > 0f) ? 6 : 8) : ((result.Z > 0f) ? 10 : 12)) : ((Math.Abs(result.X) <= Math.Abs(result.Z)) ? ((result.Z > 0f) ? 10 : 12) : ((result.X > 0f) ? 2 : 4));
                 }
             }
             for (int i = num; i < 0x40; i++)
             {
                 if (*(((byte *)(flagPtr + i))) == 0)
                 {
                     renderComponent.DepthBias = (byte)i;
                     return;
                 }
             }
         }
     }
 }
Ejemplo n.º 6
0
 void Components_ComponentRemoved(Type t, MyEntityComponentBase 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;
     }
 }
Ejemplo n.º 7
0
 void Components_ComponentAdded(Type t, MyEntityComponentBase 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;
     }
 }
Ejemplo n.º 8
0
 void Components_ComponentAdded(Type t, MyEntityComponentBase c)
 {
     if ((typeof(MyPhysicsComponentBase)).IsAssignableFrom(t))
         m_physics = c as MyPhysicsBody;
     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 MyNullPositionComponent();
     }
     else if ((typeof(MyHierarchyComponentBase)).IsAssignableFrom(t))
         m_hierarchy = c as MyHierarchyComponentBase;
     else if ((typeof(MyRenderComponentBase)).IsAssignableFrom(t))
     {
         m_render = c as MyRenderComponentBase;
         if (m_render == null)
             Render = new MyNullRenderComponent();
     }
 }