Beispiel #1
0
        private void InitInternal()
        {
            base.Init(null, m_definition.Model, null, null);
            Render.ColorMaskHsv = m_definition.ColorHSV;
            Render.Transparency = 0.25f;
            Render.AddRenderObjects();

            List <MyTextureChange> textureChanges = new List <MyTextureChange>();

            textureChanges.Add(new MyTextureChange {
                TextureName = m_definition.ColorMetalTexture, MaterialSlot = "ColorMetalTexture"
            });
            textureChanges.Add(new MyTextureChange {
                TextureName = m_definition.AddMapsTexture, MaterialSlot = "AddMapsTexture"
            });

            VRageRender.MyRenderProxy.ChangeMaterialTexture(Render.RenderObjectIDs[0], "BotFlag", textureChanges); // TODO: change the material name

            m_localActivationMatrix = MatrixD.CreateScale(this.PositionComp.LocalAABB.HalfExtents * 2.0f) * MatrixD.CreateTranslation(this.PositionComp.LocalAABB.Center);

            var shape       = new HkBoxShape(m_localActivationMatrix.Scale);
            var physicsBody = new MyPhysicsBody(this, RigidBodyFlag.RBF_DISABLE_COLLISION_RESPONSE);

            Physics = physicsBody;
            physicsBody.CreateFromCollisionObject(shape, Vector3.Zero, WorldMatrix, null, MyPhysics.CollisionLayers.ObjectDetectionCollisionLayer);
            physicsBody.Enabled = true;

            Components.Add <MyPlaceArea>(new MySpherePlaceArea(10.0f, m_definition.Id.SubtypeId)); // TODO: Add radius to the definition

            AddHudMarker();
        }
Beispiel #2
0
        private void InitInternal()
        {
            base.Init(null, m_definition.Model, null, null);
            Render.ColorMaskHsv = m_definition.ColorHSV;
            Render.Transparency = 0.25f;
            Render.AddRenderObjects();

            List <MyTextureChange> textureChanges = new List <MyTextureChange>();

            textureChanges.Add(new MyTextureChange {
                TextureName = m_definition.ColorMetalTexture, MaterialSlot = "ColorMetalTexture"
            });
            textureChanges.Add(new MyTextureChange {
                TextureName = m_definition.AddMapsTexture, MaterialSlot = "AddMapsTexture"
            });

            VRageRender.MyRenderProxy.ChangeMaterialTexture(Render.RenderObjectIDs[0], "BotFlag", textureChanges); // TODO: change the material name

            m_localActivationMatrix = MatrixD.CreateScale(this.PositionComp.LocalAABB.HalfExtents * 2.0f) * MatrixD.CreateTranslation(this.PositionComp.LocalAABB.Center);

            var shape = new HkBoxShape(m_localActivationMatrix.Scale);

            Physics = new MyPhysicsBody(this, RigidBodyFlag.RBF_DISABLE_COLLISION_RESPONSE);
            Physics.CreateFromCollisionObject(shape, Vector3.Zero, WorldMatrix, null, MyPhysics.ObjectDetectionCollisionLayer);
            Physics.Enabled = true;

            Components.Add <MyPlaceArea>(new MySpherePlaceArea(10.0f, m_definition.Id.SubtypeId)); // TODO: Add radius to the definition

            MyHud.LocationMarkers.RegisterMarker(this, new MyHudEntityParams()
            {
                FlagsEnum             = MyHudIndicatorFlagsEnum.SHOW_TEXT,
                Text                  = m_definition.DisplayNameEnum.HasValue ? MyTexts.Get(m_definition.DisplayNameEnum.Value) : new StringBuilder(),
                TargetMode            = MyRelationsBetweenPlayerAndBlock.Neutral,
                MaxDistance           = 200.0f,
                MustBeDirectlyVisible = true
            });
        }
Beispiel #3
0
        public virtual void UpdateVisual()
        {
            Matrix orientation;
            var    currModel = SlimBlock.CalculateCurrentModel(out orientation);

            if (Model != null && Model.AssetName != currModel || Render.ColorMaskHsv != SlimBlock.ColorMaskHSV || Render.Transparency != SlimBlock.Dithering)
            {
                Render.ColorMaskHsv = SlimBlock.ColorMaskHSV;
                Render.Transparency = SlimBlock.Dithering;

                Vector3D position       = WorldMatrix.Translation;
                MatrixD  newWorldMatrix = orientation * CubeGrid.WorldMatrix;
                newWorldMatrix.Translation = position;

                WorldMatrix = newWorldMatrix;

                RefreshModels(currModel, null);

                Render.RemoveRenderObjects();
                Render.AddRenderObjects();
                ReloadDetectors();
                OnModelChange();
            }
        }