Example #1
0
        public void OnMyCheckEnable(MyGuiControlCheckbox sender)
        {
            foreach (MyPrefabLight prefabLight in m_prefabLights)
            {
                MyLight myLight      = prefabLight.GetLight();
                float   oldIntensity = myLight.Intensity; // Keep old intensity, because Start() will reset it to 1

                MyGuiControlCheckbox  other;
                MyLight.LightTypeEnum lightType;

                if (sender == m_pointLightCheckbox)
                {
                    other     = m_hemisphereLightCheckbox;
                    lightType = MyLight.LightTypeEnum.PointLight;
                }
                else if (sender == m_hemisphereLightCheckbox)
                {
                    other     = m_pointLightCheckbox;
                    lightType = MyLight.LightTypeEnum.Hemisphere;
                }
                else  // (sender == m_spotLightCheckbox)
                {
                    other     = null;
                    lightType = MyLight.LightTypeEnum.Spotlight;
                }

                if (sender.Checked)
                {
                    myLight.Start(lightType | myLight.LightType, myLight.Falloff);
                    myLight.GlareOn = true;
                    if (other != null)
                    {
                        other.Checked = false;                 // only one of Point and Hemisphere can be checked
                    }
                }
                else
                {
                    myLight.Start((~lightType & myLight.LightType), myLight.Falloff);
                    myLight.GlareOn = true;
                }



                myLight.Intensity = oldIntensity; // Set previous intensity

                prefabLight.OnWorldPositionChanged(this);
                prefabLight.UpdateEffect();
            }
            OnComponentChange(null);
        }
        public void InitLight(MyCharacterDefinition definition)
        {
            m_light = MyLights.AddLight();

            m_light.Start(MyLight.LightTypeEnum.PointLight | MyLight.LightTypeEnum.Spotlight, 0.5f);

            /// todo: defaults should be supplied from Environemnt.sbc
            m_light.GlossFactor        = 0;
            m_light.DiffuseFactor      = 3.14f;
            m_light.UseInForwardRender = true;
            m_light.LightOwner         = MyLight.LightOwnerEnum.SmallShip;
            m_light.ShadowDistance     = 20;
            m_light.ReflectorFalloff   = 10;

            m_light.ReflectorTexture         = "Textures\\Lights\\dual_reflector_2.dds";
            m_light.ReflectorColor           = MyCharacter.REFLECTOR_COLOR;
            m_light.ReflectorConeMaxAngleCos = MyCharacter.REFLECTOR_CONE_ANGLE;
            m_light.ReflectorRange           = MyCharacter.REFLECTOR_RANGE;
            m_light.ReflectorGlossFactor     = MyCharacter.REFLECTOR_GLOSS_FACTOR;
            m_light.ReflectorDiffuseFactor   = MyCharacter.REFLECTOR_DIFFUSE_FACTOR;
            m_light.Color         = MyCharacter.POINT_COLOR;
            m_light.SpecularColor = new Vector3(MyCharacter.POINT_COLOR_SPECULAR);
            m_light.Range         = MyCharacter.POINT_LIGHT_RANGE;

            m_skinnedEntity.AnimationController.FindBone(definition.LeftLightBone, out m_leftLightIndex);

            m_skinnedEntity.AnimationController.FindBone(definition.RightLightBone, out m_rightLightIndex);
        }
Example #3
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            base.Init(objectBuilder, cubeGrid);

            m_thrustDefinition = (MyThrustDefinition)BlockDefinition;

            var builder = (MyObjectBuilder_Thrust)objectBuilder;

            m_thrustColor = m_thrustDefinition.FlameIdleColor;

            ThrustOverride = builder.ThrustOverride;

            LoadDummies();

            m_light = MyLights.AddLight();
            m_light.ReflectorDirection = WorldMatrix.Forward;
            m_light.ReflectorUp        = WorldMatrix.Up;
            m_light.ReflectorRange     = 1;
            m_light.Color          = m_thrustColor;
            m_light.GlareMaterial  = m_thrustDefinition.FlameGlareMaterial;
            m_light.GlareQuerySize = m_thrustDefinition.FlameGlareQuerySize;

            m_glareSize = m_thrustDefinition.FlameGlareSize;
            m_maxBillboardDistanceSquared = m_thrustDefinition.FlameVisibilityDistance * m_thrustDefinition.FlameVisibilityDistance;
            m_maxLightDistanceSquared     = m_maxBillboardDistanceSquared / 100;

            m_light.Start(MyLight.LightTypeEnum.PointLight, 1);
            SyncObject = new MySyncThruster(this);
        }
Example #4
0
        // ------------------------------------------------------------------------------------------------
        #region Light
        public void InitLight(bool isLightOn)
        {
            m_light = MyLights.AddLight();
            m_light.Start(MyLight.LightTypeEnum.Spotlight, 1.5f);
            m_light.ShadowDistance     = 20;
            m_light.ReflectorFalloff   = 5;
            m_light.LightOwner         = MyLight.LightOwnerEnum.SmallShip;
            m_light.UseInForwardRender = true;
            m_light.ReflectorTexture   = "Textures\\Lights\\dual_reflector_2.dds";
            m_light.Range = 2;

            m_light.ReflectorRange         = MyCharacter.REFLECTOR_RANGE;
            m_light.ReflectorColor         = MyCharacter.REFLECTOR_COLOR;
            m_light.ReflectorIntensity     = MyCharacter.REFLECTOR_INTENSITY;
            m_light.ReflectorGlossFactor   = MyCharacter.REFLECTOR_GLOSS_FACTOR;
            m_light.ReflectorDiffuseFactor = MyCharacter.REFLECTOR_DIFFUSE_FACTOR;
            m_light.Color         = MyCharacter.POINT_COLOR;
            m_light.SpecularColor = new Vector3(MyCharacter.POINT_COLOR_SPECULAR);
            m_light.Intensity     = MyCharacter.POINT_LIGHT_INTENSITY;
            // Reflector Range now very far
            m_light.UpdateReflectorRangeAndAngle(MyCharacter.REFLECTOR_CONE_ANGLE, MyCharacter.REFLECTOR_RANGE * REFLECTOR_RANGE_MULTIPLIER);

            m_light.LightOn     = isLightOn;
            m_light.ReflectorOn = isLightOn;
        }
Example #5
0
        protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
        {
            m_prefabLightConfig = prefabConfig as MyPrefabConfigurationLight;
            MyMwcObjectBuilder_PrefabLight objectBuilderLight = objectBuilder as MyMwcObjectBuilder_PrefabLight;

            m_light = MyLights.AddLight();

            m_light.LightType = (MyLight.LightTypeEnum)objectBuilderLight.LightType;

            m_light.Start(m_light.LightType, 1);
            m_light.UseInForwardRender = true;


            //grab first dummy and set it as point source
            //since we dont support yet more lights in one prefab. add just the first one
            MyModel model = MyModels.GetModelOnlyDummies(m_prefabLightConfig.ModelLod0Enum);

            m_pointLocalMatrix = Matrix.Identity;
            bool dummyFound = false;

            foreach (KeyValuePair <string, MyModelDummy> pair in model.Dummies)
            {
                if (pair.Key.StartsWith("Dummy", StringComparison.InvariantCultureIgnoreCase))
                {
                    m_pointLocalMatrix = pair.Value.Matrix;
                    dummyFound         = true;
                    break;
                }
            }
            Debug.Assert(dummyFound, "Dummy 'POINT_LIGHT_POS' not found in light prefab model: " + model.AssetName);

            m_light.Color              = objectBuilderLight.PointColor;
            m_light.ReflectorColor     = objectBuilderLight.SpotColor;
            m_light.Falloff            = objectBuilderLight.PointFalloff;
            m_light.ReflectorFalloff   = objectBuilderLight.SpotFalloff;
            m_IntensityMax             = m_light.Intensity = objectBuilderLight.PointIntensity;
            m_light.ReflectorIntensity = ReflectorIntensityMax = objectBuilderLight.SpotIntensity;
            m_light.ReflectorRange     = MathHelper.Clamp(objectBuilderLight.SpotRange, 1, MyLightsConstants.MAX_SPOTLIGHT_RANGE);
            m_light.Range              = MathHelper.Clamp(objectBuilderLight.PointRange, 1, MyLightsConstants.MAX_POINTLIGHT_RADIUS);
            m_light.PointLightOffset   = objectBuilderLight.PointOffset;
            this.FlashOffset           = objectBuilderLight.FlashOffset;

            //to add reflector range to builders
            m_light.SpecularColor        = objectBuilderLight.PointSpecular;
            m_light.ReflectorConeDegrees = objectBuilderLight.SpotAgle;
            m_effect = objectBuilderLight.Effect;
            //m_light.LightOn = true;
            m_lastBlickChange = MyMinerGame.TotalGamePlayTimeInMilliseconds;

            // here set the properties of glare for the prefab light
            m_light.GlareOn         = true;
            m_light.Glare.Type      = MyLightGlare.GlareTypeEnum.Normal;
            m_light.Glare.QuerySize = .8f;
            m_light.ShadowDistance  = objectBuilderLight.ShadowsDistance;
            m_light.Glare.Intensity = m_light.Intensity;
            UpdateEffect();

            CastShadows = false;
            UpdateLightWorldMatrix();
        }
Example #6
0
        public NaniteBeaconEffect(MyCubeBlock owner, Vector3 localOffset, Vector4 color)
        {
            m_owner       = owner as IMyFunctionalBlock;
            m_localOffset = localOffset;
            m_color       = color;

            m_light = MyLights.AddLight();

            //m_light.Start(color, 2f, 4f, "NaniteBeacon");
            m_light.Start(color, 2f, "NaniteBeacon");
            m_light.GlareType      = VRageRender.Lights.MyGlareTypeEnum.Normal;
            m_light.GlareOn        = true;
            m_light.GlareQuerySize = 1;
            m_light.GlareIntensity = 0.5f;

            var flareId = new MyDefinitionId(typeof(MyObjectBuilder_FlareDefinition), "BeaconSmall");
            var flare   = (MyFlareDefinition)MyDefinitionManager.Static.GetDefinition(flareId);

            m_light.GlareSize = flare.Size;
            m_light.SubGlares = flare.SubGlares;

            //m_light.GlareMaterial = "LightGlare";
            //m_light.GlareType = VRageRender.Lights.MyGlareTypeEnum.Normal;
            m_updateCount = 0;
        }
        void LightingHandler()
        {
            if (_light == null)
            {
                _light = new MyLight();

                //These control the light settings on spawn.
                var lightRange     = 2.5f;                                                           //Range of light
                var lightIntensity = 5.0f;                                                           //Light intensity
                var lightFalloff   = 0.5f;                                                           //Light falloff
                //var lightAdjustment = 0.0f;
                var lightPosition = block.WorldMatrix.Translation + block.WorldMatrix.Forward * 0.2; //Sets the light to the center of the block you are spawning it on, if you need it elsehwere you will need help.

                _light = MyLights.AddLight();                                                        //Ignore - adds the light to the games lighting system
                _light.Start(lightPosition, Color.Red, lightRange, "");                              // Ignore- Determines the lights position, initial color and initial range.
                _light.Intensity = lightIntensity;                                                   //Ignore - sets light intensity from above values.
                _light.Falloff   = lightFalloff;                                                     //Ignore - sets light fall off from above values.
                //_light.PointLightOffset = lightOffset; //Ignore - sets light offset from above values.
                _light.LightOn = true;                                                               //Ignore - turns light on
            }
            else
            {
                //_light.Intensity = 10 * ThrusterStrength;
                _light.Position = block.WorldMatrix.Translation + block.WorldMatrix.Forward; //Updates the lights position constantly. You'll need help if you want it somewhere else.
                _light.UpdateLight();                                                        //Ignore - tells the game to update the light.
            }
        }
Example #8
0
        //  When tube is ejecting and looking for voxels
        void StartFindingVoxel()
        {
            //  Else we normally start ejecting
            CurrentState        = MyHarvestingDeviceEnum.FindingVoxel;
            m_headPositionLocal = Vector3.Zero;
            StartTubeMovingCue();
            StopGrindingCue();

            if (m_light != null)
            {
                MyLights.RemoveLight(m_light);
            }
            m_light = null;

            //m_light = MyLights.AddLight();

            if (m_light != null)
            {
                var color = 5 * new Vector4(1, 0.3f, 0.3f, 1);
                m_light.Start(MyLight.LightTypeEnum.PointLight, color, 3, 10);
            }

            MyScriptWrapper.HarvesterUse();
            UpdateAfterSimulation();
        }
Example #9
0
        public static void CreateOrUpdateLight(MyEntity entity, MyLight light, Color color, Vector3D?originPoint = null)
        {
            var lightPosition  = originPoint ?? entity.WorldMatrix.Translation;
            var lightRange     = 1.5f;                   //Range of light
            var lightIntensity = 5.0f;                   //Light intensity
            var lightFalloff   = 1.5f;                   //Light falloff
            var lightOffset    = 0.5f;                   //Light offset

            if (light == null)                           //Ignore - checks if there is a light and if not makes it.
            {
                light = MyLights.AddLight();             //Ignore - adds the light to the games lighting system
                light.Start(lightPosition, color.ToVector4(), lightRange,
                            "");                         // Ignore- Determines the lights position, initial color and initial range.
                light.Intensity        = lightIntensity; //Ignore - sets light intensity from above values.
                light.Falloff          = lightFalloff;   //Ignore - sets light fall off from above values.
                light.PointLightOffset = lightOffset;    //Ignore - sets light offset from above values.
                light.LightOn          = true;           //Ignore - turns light on
            }
            else
            {
                // Updates the lights position constantly. You'll need help if you want it somewhere else.
                light.Position = lightPosition;
                light.UpdateLight(); //Ignore - tells the game to update the light.
            }
        }
        //public void LightingHandler(ref MyLight light, float positionOffset, float lightRange, Color color)
        void LightingHandler(ref MyLight light, Vector3D position, float lightRange, Color color, float falloff, float intensity, float mult)
        {
            if (light == null)
            {
                light = new MyLight();

                //These control the light settings on spawn.
                //var lightRange = 2.5f; //Range of light
                var lightIntensity = 5.0f;                         //Light intensity
                //var lightFalloff = 0.5f; //Light falloff
                var lightFalloff = falloff;                        //Light falloff
                //var lightAdjustment = 0.0f;
                var lightPosition = position;                      //Sets the light to the center of the block you are spawning it on, if you need it elsehwere you will need help.

                light = MyLights.AddLight();                       //Ignore - adds the light to the games lighting system
                light.Start(lightPosition, color, lightRange, ""); // Ignore- Determines the lights position, initial color and initial range.
                light.Intensity = lightIntensity;                  //Ignore - sets light intensity from above values.
                light.Falloff   = lightFalloff;                    //Ignore - sets light fall off from above values.
                //_light.PointLightOffset = lightOffset; //Ignore - sets light offset from above values.
                light.LightOn = true;                              //Ignore - turns light on
            }
            else
            {
                light.Intensity = intensity * mult;
                light.Position  = position; //Updates the lights position constantly. You'll need help if you want it somewhere else.
                light.UpdateLight();        //Ignore - tells the game to update the light.
            }
        }
Example #11
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            base.Init(objectBuilder, cubeGrid);

            m_radioBroadcaster = new MyRadioBroadcaster(this, 10000, IsWorking);
            if (((MyObjectBuilder_Beacon)objectBuilder).BroadcastRadius != 0)
            {
                m_radioBroadcaster.BroadcastRadius = ((MyObjectBuilder_Beacon)objectBuilder).BroadcastRadius;
            }
            m_radioBroadcaster.OnBroadcastRadiusChanged += OnBroadcastRadiusChanged;

            m_largeLight = cubeGrid.GridSizeEnum == MyCubeSize.Large;

            m_light = MyLights.AddLight();

            m_light.Start(MyLight.LightTypeEnum.PointLight, 1.5f);
            m_light.LightOwner         = MyLight.LightOwnerEnum.SmallShip;
            m_light.UseInForwardRender = true;
            m_light.Range = 1;

            m_light.GlareOn        = true;
            m_light.GlareIntensity = m_largeLight ? 2 : 1;
            m_light.GlareQuerySize = m_largeLight ? 7.5f : 1.22f;
            m_light.GlareType      = VRageRender.Lights.MyGlareTypeEnum.Distant;
            m_light.GlareMaterial  = m_largeLight ? "GlareLsLight"
                                                 : "GlareSsLight";
            m_light.GlareMaxDistance = GLARE_MAX_DISTANCE;

            if (m_largeLight)
            {
                m_lightPositionOffset = new Vector3(0f, CubeGrid.GridSize * 0.5f, 0f);
            }
            else
            {
                m_lightPositionOffset = Vector3.Zero;
            }

            UpdateLightPosition();

            PowerReceiver = new MyPowerReceiver(
                MyConsumerGroupEnum.Utility,
                false,
                MyEnergyConstants.MAX_REQUIRED_POWER_BEACON,
                UpdatePowerInput);
            PowerReceiver.IsPoweredChanged += Receiver_IsPoweredChanged;
            PowerReceiver.Update();
            AddDebugRenderComponent(new MyDebugRenderComponentDrawPowerReciever(PowerReceiver, this));

            AnimationRunning = true;
            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;

            IsWorkingChanged += MyBeacon_IsWorkingChanged;

            ShowOnHUD = false;

            UpdateText();
        }
        protected virtual MyLight CreateSecondaryLight()
        {
            MyLight light = MyLights.AddLight();

            light.Start(MyLight.LightTypeEnum.PointLight, Vector3.Zero, SecondaryLightColor, SecondaryLightFalloff, SecondaryLightRadius);
            light.GlareMaterial  = "GlareWelder";
            light.GlareOn        = true;
            light.GlareQuerySize = 1;
            light.GlareType      = VRageRender.Lights.MyGlareTypeEnum.Normal;
            return(light);
        }
Example #13
0
 public MyPrefabLamp(Vector3 position, float radiusMin, float radiusMax, int timerForBlic)
 {
     Position     = position;
     RadiusMin    = radiusMin;
     RadiusMax    = radiusMax;
     TimerForBlic = timerForBlic;
     Light        = MyLights.AddLight();
     Light.Start(MyLight.LightTypeEnum.PointLight, position, Vector4.One, 1, radiusMin);
     Light.Intensity = 1;
     Light.LightOn   = true;
 }
Example #14
0
        private MyLight CreateEffectLight()
        {
            MyLight light = MyLights.AddLight();

            light.Start(MyLight.LightTypeEnum.PointLight, Vector3.Zero, new Vector4(1.0f, 0.8f, 0.6f, 1.0f), 2.0f, 10.0f);
            light.GlareMaterial  = "GlareWelder";
            light.GlareOn        = true;
            light.GlareQuerySize = 1;
            light.GlareType      = VRageRender.Lights.MyGlareTypeEnum.Normal;
            return(light);
        }
Example #15
0
 public void Start(float lightSize)
 {
     if (lightSize > 0)
     {
         Light       = MyLights.AddLight();
         Light.Color = Vector4.One;
         Light.Start(MyLight.LightTypeEnum.PointLight, 1.0f);
         Light.LightOn   = lightSize > 0;
         Light.Intensity = 10;
     }
 }
Example #16
0
        public void InitLight(MyCharacterDefinition definition)
        {
            m_light = MyLights.AddLight();

            m_lightGlareSize = definition.LightGlareSize;

            m_light.Start(MyLight.LightTypeEnum.PointLight | MyLight.LightTypeEnum.Spotlight, 1.5f);
            m_light.ShadowDistance     = 20;
            m_light.ReflectorFalloff   = 5;
            m_light.LightOwner         = MyLight.LightOwnerEnum.SmallShip;
            m_light.UseInForwardRender = true;
            m_light.ReflectorTexture   = definition.ReflectorTexture;
            m_light.Range       = 1;
            m_light.GlossFactor = 0;

            MyCharacterBone leftGlareBone = null;

            if (definition.LeftLightBone != String.Empty)
            {
                leftGlareBone = m_skinnedEntity.AnimationController.FindBone(definition.LeftLightBone, out m_leftLightIndex);
            }
            if (leftGlareBone != null)
            {
                m_leftGlare = MyLights.AddLight();
                m_leftGlare.Start(MyLight.LightTypeEnum.None, 1.5f);
                m_leftGlare.LightOn            = false;
                m_leftGlare.LightOwner         = MyLight.LightOwnerEnum.SmallShip;
                m_leftGlare.UseInForwardRender = false;
                m_leftGlare.GlareOn            = true;
                m_leftGlare.GlareQuerySize     = 0.2f;
                m_leftGlare.GlareType          = VRageRender.Lights.MyGlareTypeEnum.Directional;
                m_leftGlare.GlareMaterial      = definition.LeftGlare;
            }

            MyCharacterBone rightGlareBone = null;

            if (definition.RightLightBone != String.Empty)
            {
                rightGlareBone = m_skinnedEntity.AnimationController.FindBone(definition.RightLightBone, out m_rightLightIndex);
            }
            if (rightGlareBone != null)
            {
                m_rightGlare = MyLights.AddLight();
                m_rightGlare.Start(MyLight.LightTypeEnum.None, 1.5f);
                m_rightGlare.LightOn            = false;
                m_rightGlare.LightOwner         = MyLight.LightOwnerEnum.SmallShip;
                m_rightGlare.UseInForwardRender = false;
                m_rightGlare.GlareOn            = true;
                m_rightGlare.GlareQuerySize     = 0.2f;
                m_rightGlare.GlareType          = VRageRender.Lights.MyGlareTypeEnum.Directional;
                m_rightGlare.GlareMaterial      = definition.RightGlare;
            }
        }
        protected override void InitLight(MyLight light, Vector4 color, float radius, float falloff)
        {
            light.Start(MyLight.LightTypeEnum.PointLight, color, falloff, radius);

            light.ReflectorDirection = WorldMatrix.Forward;
            light.ReflectorUp        = WorldMatrix.Up;
            light.PointLightOffset   = 0.5f;

            light.GlareOn        = true;
            light.GlareIntensity = 0.4f;
            light.GlareQuerySize = 1;
            light.GlareMaterial  = BlockDefinition.LightGlare;
            light.GlareType      = VRageRender.Lights.MyGlareTypeEnum.Normal;
            light.GlareSize      = 0.327f;
        }
Example #18
0
        protected override void InitLight(MyLight light, Vector4 color, float radius, float falloff)
        {
            light.Start(MyLight.LightTypeEnum.PointLight | MyLight.LightTypeEnum.Spotlight, color, falloff, radius);

            light.ShadowDistance     = 20;
            light.LightOwner         = MyLight.LightOwnerEnum.SmallShip;
            light.UseInForwardRender = true;
            light.ReflectorTexture   = BlockDefinition.ReflectorTexture;
            light.ReflectorFalloff   = 5;

            light.GlareOn        = true;
            light.GlareIntensity = 1f;
            light.GlareQuerySize = GlareQuerySizeDef;
            light.GlareType      = VRageRender.Lights.MyGlareTypeEnum.Normal;
            light.GlareMaterial  = BlockDefinition.LightGlare;
            light.GlareSize      = ReflectorGlareSizeDef;
        }
        //  This method realy initiates/starts the missile
        //  IMPORTANT: Direction vector must be normalized!
        public void Start(Vector3 position, Vector3 initialVelocity, Vector3 direction, float impulseMultiplier, MyEntity owner)
        {
            base.Start(position, initialVelocity, direction, impulseMultiplier, owner, MyTextsWrapper.Get(MyTextsWrapperEnum.IlluminatingShellHud));

            this.Physics.AddForce(
                MyPhysicsForceType.APPLY_WORLD_IMPULSE_AND_WORLD_ANGULAR_IMPULSE,
                initialVelocity * 2,
                position,
                null);  //  Setting a torque here make trouble for recycled mines... so for now we don't use it. Maybe in future in other physics engine than JLX.

            m_light = MyLights.AddLight();
            if (m_light != null)
            {
                m_light.Start(MyLight.LightTypeEnum.PointLight, position, MyIlluminatingShellsConstants.LIGHT_COLOR, 1, MyIlluminatingShellsConstants.LIGHT_RADIUS);
            }

            m_particleEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.UniversalLauncher_IlluminatingShell);
            m_particleEffect.WorldMatrix = WorldMatrix;
        }
        //  This method realy initiates/starts the missile
        //  IMPORTANT: Direction vector must be normalized!
        public void Start(Vector3 position, Vector3 initialVelocity, Vector3 direction, float impulseMultiplier, MyEntity owner)
        {
            base.Start(position, initialVelocity, direction, impulseMultiplier, owner, MyTextsWrapper.Get(MyTextsWrapperEnum.IlluminatingShellHud));

            this.Physics.AddForce(
                MyPhysicsForceType.APPLY_WORLD_IMPULSE_AND_WORLD_ANGULAR_IMPULSE,
                initialVelocity * 2,
                position,
                null);  //  Setting a torque here make trouble for recycled mines... so for now we don't use it. Maybe in future in other physics engine than JLX.

            m_light = MyLights.AddLight();
            if (m_light != null)
            {
                m_light.Start(MyLight.LightTypeEnum.PointLight, position, MyIlluminatingShellsConstants.LIGHT_COLOR, 1, MyIlluminatingShellsConstants.LIGHT_RADIUS);
            }

            m_particleEffect             = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.UniversalLauncher_IlluminatingShell);
            m_particleEffect.WorldMatrix = WorldMatrix;
        }
Example #21
0
        private MyLight CreateFlare(string debugName)
        {
            MyLight light = MyLights.AddLight();

            if (light != null)
            {
                light.Start(base.Entity.DisplayName + " Reflector " + debugName + " Flare");
                light.ReflectorOn      = false;
                light.LightOn          = false;
                light.Color            = MyCharacter.POINT_COLOR;
                light.GlareOn          = true;
                light.GlareIntensity   = this.m_flareHeadlamp.Intensity;
                light.GlareSize        = this.m_flareHeadlamp.Size;
                light.SubGlares        = this.m_flareHeadlamp.SubGlares;
                light.GlareQuerySize   = 0.05f;
                light.GlareMaxDistance = 40f;
                light.GlareType        = MyGlareTypeEnum.Directional;
            }
            return(light);
        }
        private void SetRenderSetup()
        {
            m_setup.RenderTargets = new RenderTargetBinding[1];

            m_setup.DisabledModules.Add("Cockpit");
            m_setup.DisabledModules.Add("Cockpit glass");
            m_setup.DisabledModules.Add("Sun glow");
            m_setup.DisabledModules.Add("Sun glare and lens flare");
            m_setup.DisabledModules.Add("Update occlusions");
            m_setup.DisabledModules.Add("Transparent geometry");

            m_setup.SkippedRenderStages.Add(MyRenderStage.AlphaBlendPreHDR);
            m_setup.SkippedRenderStages.Add(MyRenderStage.AlphaBlend);
            m_setup.SkippedRenderStages.Add(MyRenderStage.DebugDraw);
            m_setup.SkippedRenderStages.Add(MyRenderStage.PrepareForDraw);

            m_setup.DisabledPostprocesses.Add("Flashes");
            m_setup.DisabledPostprocesses.Add("Volumetric SSAO 2");
            m_setup.DisabledPostprocesses.Add("Antialiasing");

            m_setup.BackgroundColor = new Color(0.17f, 0.18f, .25f, .5f);

            m_setup.EnableHDR                = false;
            m_setup.EnableSun                = true;
            m_setup.EnableSunShadows         = true;
            m_setup.EnableSmallLights        = true;
            m_setup.EnableDebugHelpers       = false;
            m_setup.EnableEnvironmentMapping = false;

            m_setup.RenderElementsToDraw            = new List <MyRender.MyRenderElement>();
            m_setup.TransparentRenderElementsToDraw = new List <MyRender.MyRenderElement>();
            m_setup.LightsToUse = new List <MyLight>();
            MyLight light = new MyLight();

            light.Start(MyLight.LightTypeEnum.PointLight, new Vector4(1, 0.95f, 0.8f, 1), 1, 119); // fill light
            m_setup.LightsToUse.Add(light);
            light = new MyLight();
            light.Start(MyLight.LightTypeEnum.PointLight, new Vector4(1, 0.9f, 0.6f, 1), 1, 119); // back light
            m_setup.LightsToUse.Add(light);
        }
        protected override void InitLight(MyLight light, Vector4 color, float radius, float falloff)
        {
            light.Start(MyLight.LightTypeEnum.PointLight | MyLight.LightTypeEnum.Spotlight, color, falloff, CubeGrid.GridScale * radius);

            /// todo: defaults should be supplied from Environemnt.sbc
            light.ShadowDistance       = 20;
            light.LightOwner           = MyLight.LightOwnerEnum.SmallShip;
            light.UseInForwardRender   = true;
            light.ReflectorTexture     = BlockDefinition.ReflectorTexture;
            light.Falloff              = 0.3f;
            light.GlossFactor          = 0;
            light.ReflectorGlossFactor = 0.65f;
            light.DiffuseFactor        = 3.14f;
            light.PointLightOffset     = 0.15f;

            light.GlareOn        = true;
            light.GlareIntensity = 1f;
            light.GlareQuerySize = GlareQuerySizeDef;
            light.GlareType      = VRageRender.Lights.MyGlareTypeEnum.Normal;
            light.GlareMaterial  = BlockDefinition.LightGlare;
            light.GlareSize      = ReflectorGlareSizeDef;
        }
Example #24
0
        private void MakeLight()
        {
            // light setup
            m_light_emmitter = new MyLight();
            m_light_emmitter.Start(m_light_model.PositionComp.GetPosition(), Light_Color, 0, m_turret.DisplayNameText);
            m_light_emmitter.CastShadows = true;
            m_light_emmitter.LightType   = MyLightType.SPOTLIGHT;
            m_light_emmitter.LightType   = MyLightType.SPOTLIGHT;
            m_light_emmitter.Position    = m_light_model.PositionComp.GetPosition() + m_light_model.PositionComp.GetOrientation().Forward *Light_Offset;

            /*m_light_emmitter.Falloff = 0.3f;
             * m_light_emmitter.GlossFactor = 1f;*/
            m_light_emmitter.ParentID = m_light_model.Render.GetRenderObjectID();

            /*m_light_emmitter.GlareOn = m_light_emmitter.LightOn;
             * m_light_emmitter.GlareQuerySize = GlareQuerySizeDef;
             * m_light_emmitter.GlareType = MyGlareTypeEnum.Directional;
             * m_light_emmitter.GlareSize = m_light_flare.Size;
             * m_light_emmitter.SubGlares = m_light_flare.SubGlares;*/

            //m_light_flare = MyDefinitionManager.Static.GetDefinition(new MyDefinitionId((MyObjectBuilderType)typeof(MyObjectBuilder_FlareDefinition), "NoFlare")) as MyFlareDefinition ?? new MyFlareDefinition();

            //m_light_emmitter.ReflectorTexture = m_light_cone_texture_path;
            m_light_emmitter.ReflectorGlossFactor = 1f;
            m_light_emmitter.ReflectorFalloff     = 0.3f;
            m_light_emmitter.ReflectorColor       = Light_Color;
            m_light_emmitter.ReflectorIntensity   = Light_Intensity;
            m_light_emmitter.ReflectorDirection   = m_light_model.PositionComp.GetOrientation().Forward;
            m_light_emmitter.ReflectorUp          = m_light_model.PositionComp.GetOrientation().Up;
            m_light_emmitter.ReflectorRange       = Light_Radius;

            m_light_emmitter.ReflectorOn = m_turret.IsWorking;
            m_light_emmitter.LightOn     = false;

            m_light_emmitter.UpdateLight();

            //m_light_model.Render.NeedsDrawFromParent = true;
        }
Example #25
0
        public static void Draw()
        {
            if (MyFakes.TEST_MISSION_1_ENABLED)
            {
                if (m_remainingPrimaryTargetsCounter == 0)
                {
                    if (m_russianDropZoneLight != null)
                    {
                        Vector3 dir = MyMwcUtils.Normalize(MyCamera.Position - RUSSIAN_DROP_ZONE_POSITION);

                        float timeBlic = MyMinerGame.TotalGamePlayTimeInMilliseconds % 980;
                        if (timeBlic > 250)
                        {
                            timeBlic = 980 - timeBlic;
                        }
                        timeBlic = MathHelper.Clamp(1 - timeBlic / 250, 0, 1);

                        float alpha = MathHelper.Lerp(0.1f, 0.6f, timeBlic);

                        m_dropZoneLightColor.W = alpha;
                        m_russianDropZoneLight.Start(MyLight.LightTypeEnum.PointLight, RUSSIAN_DROP_ZONE_POSITION, m_dropZoneLightColor, 1, 200);

                        float radius = MathHelper.Lerp(0.1f, 150f, timeBlic);

                        MyTransparentGeometry.AddPointBillboard(MyTransparentMaterialEnum.ReflectorGlareAlphaBlended, m_dropZoneLightColor,
                                                                RUSSIAN_DROP_ZONE_POSITION + dir * 5, radius, 0);
                    }
                    else
                    {
                        m_russianDropZoneLight = MyLights.AddLight();
                        if (m_russianDropZoneLight != null)
                        {
                            m_russianDropZoneLight.Start(MyLight.LightTypeEnum.PointLight, 1);
                        }
                    }
                }
            }
        }
Example #26
0
        private void InitLight()
        {
            m_pointLight = MyLights.AddLight();

            m_pointLight.LightType = MyLight.LightTypeEnum.PointLight;

            m_pointLight.Start(m_pointLight.LightType, 1);
            m_pointLight.UseInForwardRender = true;


            //grab first dummy and set it as point source
            //since we dont support yet more lights in one prefab. add just the first one
            MyModel model = MyModels.GetModelOnlyDummies(ModelLod0.ModelEnum);

            m_pointLocalMatrix = Matrix.CreateTranslation(model.BoundingSphere.Center);

            m_pointLight.Color            = new Vector4(1f, 0f, 0f, 1f);
            m_pointLight.ReflectorColor   = Vector4.Zero;
            m_pointLight.Falloff          = 0.1f;
            m_pointLight.ReflectorFalloff = 0.1f;
            m_intensityMax = m_pointLight.Intensity = 10f;
            m_pointLight.ReflectorIntensity = 1f;
            m_pointLight.ReflectorRange     = 1f;
            m_pointLight.Range            = 40f;
            m_pointLight.PointLightOffset = 0f;

            //to add reflector range to builders
            m_pointLight.SpecularColor        = new Vector3(1f, 0f, 0f);
            m_pointLight.ReflectorConeDegrees = 0.1f;
            m_lastBlickChange = MyMinerGame.TotalGamePlayTimeInMilliseconds;

            // here set the properties of glare for the prefab light
            m_pointLight.GlareOn         = true;
            m_pointLight.Glare.Type      = MyLightGlare.GlareTypeEnum.Distant;
            m_pointLight.Glare.QuerySize = .8f;
            UpdateLightWorldMatrix();
        }
Example #27
0
        //  This method realy initiates/starts the missile
        //  IMPORTANT: Direction vector must be normalized!
        public override void Start(Vector3D position, Vector3D initialVelocity, Vector3D direction, long owner)
        {
            m_collidedEntity = null;
            m_collisionPoint = null;
            m_maxTrajectory  = m_missileAmmoDefinition.MaxTrajectory;
            m_owner          = owner;

            m_isExploded = false;

            base.Start(position, initialVelocity, direction, owner);
            Physics.RigidBody.MaxLinearVelocity = m_missileAmmoDefinition.DesiredSpeed;

            m_explosionType = MyExplosionTypeEnum.MISSILE_EXPLOSION;

            MySoundPair shootSound = m_weaponDefinition.WeaponAmmoDatas[(int)MyAmmoType.Missile].ShootSound;

            if (shootSound != null)
            {
                //  Plays cue (looping)
                m_soundEmitter.PlaySingleSound(shootSound, true);
            }

            m_light = MyLights.AddLight();
            if (m_light != null)
            {
                m_light.Start(MyLight.LightTypeEnum.PointLight, (Vector3)PositionComp.GetPosition(), GetMissileLightColor(), 1, MyMissileConstants.MISSILE_LIGHT_RANGE);
            }

            if (MyParticlesManager.TryCreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_Missile, out m_smokeEffect))
            {
                var matrix = PositionComp.WorldMatrix;
                matrix.Translation                -= matrix.Forward * m_smokeEffectOffsetMultiplier;
                m_smokeEffect.WorldMatrix          = matrix;
                m_smokeEffect.AutoDelete           = false;
                m_smokeEffect.CalculateDeltaMatrix = true;
            }
        }
Example #28
0
        //  This method realy initiates/starts the missile
        //  IMPORTANT: Direction vector must be normalized!
        public virtual void Start(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum type, Vector3 position, Vector3 initialVelocity, Vector3 direction, Vector3 relativePos, MyEntity minerShip, MyEntity target, float customMaxDistance, bool isDummy, bool isLightWeight)
        {
            m_ammoProperties = MyAmmoConstants.GetAmmoProperties(type);
            m_missileType = type;
            m_isExploded = false;
            m_collidedEntity = null;
            m_collisionPoint = null;
            m_maxTrajectory = customMaxDistance > 0 ? customMaxDistance : m_ammoProperties.MaxTrajectory;
            IsDummy = isDummy;
            Faction = minerShip.Faction;

            Vector3? correctedDirection = null;
            if (MyGameplayConstants.GameplayDifficultyProfile.EnableAimCorrection)
            {
                if (minerShip == MinerWars.AppCode.Game.Managers.Session.MySession.PlayerShip)
                {
                    correctedDirection = MyEntities.GetDirectionFromStartPointToHitPointOfNearestObject(minerShip, position, m_ammoProperties.MaxTrajectory);
                }
            }

            if (correctedDirection != null)
                direction = correctedDirection.Value;

            base.Start(position, initialVelocity, direction, 0, minerShip);

            if (correctedDirection != null) //override the base class behaviour, update the missile direction
            {
                Matrix ammoWorld = minerShip.WorldMatrix;
                ammoWorld.Translation = position;
                ammoWorld.Forward = correctedDirection.Value;

                SetWorldMatrix(ammoWorld);
            }

            switch (m_missileType)
            {
                //just going forward (deprecated)
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic:
                    m_initTime = MyMissileConstants.MISSILE_INIT_TIME;
                    m_initDir = MyMissileConstants.MISSILE_INIT_DIR;
                    m_blendVelocities = MyMissileConstants.MISSILE_BLEND_VELOCITIES_IN_MILISECONDS;
                    m_missileTimeout = MyMissileConstants.MISSILE_TIMEOUT;
                    m_explosionType = MyExplosionTypeEnum.MISSILE_EXPLOSION;
                    break;
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_BioChem:
                    m_initTime = MyMissileConstants.MISSILE_INIT_TIME;
                    m_initDir = MyMissileConstants.MISSILE_INIT_DIR;
                    m_blendVelocities = MyMissileConstants.MISSILE_BLEND_VELOCITIES_IN_MILISECONDS;
                    m_missileTimeout = MyMissileConstants.MISSILE_TIMEOUT;
                    m_explosionType = MyExplosionTypeEnum.BIOCHEM_EXPLOSION;
                    break;
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_EMP:
                    m_initTime = MyMissileConstants.MISSILE_INIT_TIME;
                    m_initDir = MyMissileConstants.MISSILE_INIT_DIR;
                    m_blendVelocities = MyMissileConstants.MISSILE_BLEND_VELOCITIES_IN_MILISECONDS;
                    m_missileTimeout = MyMissileConstants.MISSILE_TIMEOUT;
                    m_explosionType = MyExplosionTypeEnum.EMP_EXPLOSION;
                    break;

                //Missile is guided to the nearest enemy in the radius
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Engine_Detection:

                //Missile is guided to the closest enemy in the visible spot
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Visual_Detection:

                //Missile is guided to actual selected target by smallship radar
                case MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Radar_Detection:
                    m_initDir.X = 5.0f * MathHelper.Clamp(relativePos.X, -1, 1);
                    m_blendVelocities = MyGuidedMissileConstants.MISSILE_BLEND_VELOCITIES_IN_MILISECONDS;
                    m_missileTimeout = MyGuidedMissileConstants.MISSILE_TIMEOUT;
                    m_turnSpeed = MyGuidedMissileConstants.MISSILE_TURN_SPEED;
                    m_explosionType = MyExplosionTypeEnum.MISSILE_EXPLOSION;
                    GuidedInMultiplayer = true;
                    break;
                default:
                    throw new NotImplementedException();
            }


            UpdateTarget(target);


            if (!isLightWeight)
            {
                //  Play missile thrust cue (looping)
                m_thrusterCue = MyAudio.AddCue3D(m_ammoProperties.ShotSound, GetPosition(), WorldMatrix.Forward, WorldMatrix.Up, m_initialVelocity);

                m_light = MyLights.AddLight();
                if (m_light != null)
                {
                    m_light.Start(MyLight.LightTypeEnum.PointLight, GetPosition(), MyMissileHelperUtil.GetMissileLightColor(), 1, MyMissileConstants.MISSILE_LIGHT_RANGE);
                }
            }

#if DEBUG_MISSILE
            m_trailDebug.Clear();
#endif

            if (m_missileType == MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic)
            {
                /*
                MyParticleEffect startEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_MissileStart);
                startEffect.WorldMatrix = WorldMatrix;
                 */
                m_smokeEffect = MyParticlesManager.CreateParticleEffect((int)MyParticleEffectsIDEnum.Smoke_Missile);
                m_smokeEffect.WorldMatrix = WorldMatrix;
                m_smokeEffect.AutoDelete = false;
            }
        }
Example #29
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            var beaconDefinition = BlockDefinition as MyBeaconDefinition;

            Debug.Assert(beaconDefinition != null);

            var sinkComp = new MyResourceSinkComponent();

            sinkComp.Init(
                MyStringHash.GetOrCompute(beaconDefinition.ResourceSinkGroup),
                MyEnergyConstants.MAX_REQUIRED_POWER_BEACON,
                UpdatePowerInput);

            ResourceSink = sinkComp;

            RadioBroadcaster = new MyRadioBroadcaster(10000);
            if (((MyObjectBuilder_Beacon)objectBuilder).BroadcastRadius != 0)
            {
                RadioBroadcaster.BroadcastRadius = ((MyObjectBuilder_Beacon)objectBuilder).BroadcastRadius;
            }

            base.Init(objectBuilder, cubeGrid);

            sinkComp.IsPoweredChanged += Receiver_IsPoweredChanged;
            sinkComp.Update();

            RadioBroadcaster.OnBroadcastRadiusChanged += OnBroadcastRadiusChanged;

            m_largeLight = cubeGrid.GridSizeEnum == MyCubeSize.Large;

            m_light = MyLights.AddLight();

            m_light.Start(MyLight.LightTypeEnum.PointLight, 1.5f);
            m_light.LightOwner         = m_largeLight ? MyLight.LightOwnerEnum.LargeShip : MyLight.LightOwnerEnum.SmallShip;
            m_light.UseInForwardRender = true;
            m_light.Range = 1;

            m_light.GlareOn        = true;
            m_light.GlareIntensity = m_largeLight ? 2 : 1;
            m_light.GlareQuerySize = m_largeLight ? 1.0f : 0.2f;
            m_light.GlareSize      = 1.0f;
            m_light.GlareType      = VRageRender.Lights.MyGlareTypeEnum.Distant;
            m_light.GlareMaterial  = m_largeLight ? "GlareLsLight"
                                                 : "GlareSsLight";
            m_light.GlareMaxDistance = GLARE_MAX_DISTANCE;

            if (m_largeLight)
            {
                m_lightPositionOffset = new Vector3(0f, CubeGrid.GridSize * 0.5f, 0f);
            }
            else
            {
                m_lightPositionOffset = Vector3.Zero;
            }

            UpdateLightPosition();


            AddDebugRenderComponent(new MyDebugRenderComponentDrawPowerReciever(ResourceSink, this));

            AnimationRunning = true;
            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;

            IsWorkingChanged += MyBeacon_IsWorkingChanged;

            ShowOnHUD = false;

            UpdateText();
        }
        public void InitLight(MyCharacterDefinition definition)
        {
            m_light = MyLights.AddLight();

            m_lightGlareSize = definition.LightGlareSize;

            m_light.Start(MyLight.LightTypeEnum.PointLight | MyLight.LightTypeEnum.Spotlight, 0.5f);

            /// todo: defaults should be supplied from Environemnt.sbc
            m_light.GlossFactor        = 0;
            m_light.DiffuseFactor      = 3.14f;
            m_light.UseInForwardRender = true;
            m_light.LightOwner         = MyLight.LightOwnerEnum.SmallShip;
            m_light.ShadowDistance     = 20;
            m_light.ReflectorFalloff   = 10;

            m_light.ReflectorTexture         = "Textures\\Lights\\dual_reflector_2.dds";
            m_light.ReflectorColor           = MyCharacter.REFLECTOR_COLOR;
            m_light.ReflectorConeMaxAngleCos = MyCharacter.REFLECTOR_CONE_ANGLE;
            m_light.ReflectorRange           = MyCharacter.REFLECTOR_RANGE;
            m_light.ReflectorGlossFactor     = MyCharacter.REFLECTOR_GLOSS_FACTOR;
            m_light.ReflectorDiffuseFactor   = MyCharacter.REFLECTOR_DIFFUSE_FACTOR;
            m_light.Color         = MyCharacter.POINT_COLOR;
            m_light.SpecularColor = new Vector3(MyCharacter.POINT_COLOR_SPECULAR);
            m_light.Range         = MyCharacter.POINT_LIGHT_RANGE;

            MyCharacterBone leftGlareBone = null;

            if (definition.LeftLightBone != String.Empty)
            {
                leftGlareBone = m_skinnedEntity.AnimationController.FindBone(definition.LeftLightBone, out m_leftLightIndex);
            }
            if (leftGlareBone != null)
            {
                m_leftGlare = MyLights.AddLight();
                m_leftGlare.Start(MyLight.LightTypeEnum.None, 1.5f);
                m_leftGlare.LightOn            = false;
                m_leftGlare.LightOwner         = MyLight.LightOwnerEnum.SmallShip;
                m_leftGlare.UseInForwardRender = false;
                m_leftGlare.GlareOn            = true;
                m_leftGlare.GlareQuerySize     = 0.2f;
                m_leftGlare.GlareType          = VRageRender.Lights.MyGlareTypeEnum.Directional;
                m_leftGlare.GlareMaterial      = definition.LeftGlare;
            }

            MyCharacterBone rightGlareBone = null;

            if (definition.RightLightBone != String.Empty)
            {
                rightGlareBone = m_skinnedEntity.AnimationController.FindBone(definition.RightLightBone, out m_rightLightIndex);
            }
            if (rightGlareBone != null)
            {
                m_rightGlare = MyLights.AddLight();
                m_rightGlare.Start(MyLight.LightTypeEnum.None, 1.5f);
                m_rightGlare.LightOn            = false;
                m_rightGlare.LightOwner         = MyLight.LightOwnerEnum.SmallShip;
                m_rightGlare.UseInForwardRender = false;
                m_rightGlare.GlareOn            = true;
                m_rightGlare.GlareQuerySize     = 0.2f;
                m_rightGlare.GlareType          = VRageRender.Lights.MyGlareTypeEnum.Directional;
                m_rightGlare.GlareMaterial      = definition.RightGlare;
            }
        }
Example #31
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            MyEntityThrustComponent entityThrustComponent;

            if (!cubeGrid.Components.TryGet(out entityThrustComponent))
            {
                entityThrustComponent = new MyThrusterBlockThrustComponent();

                entityThrustComponent.Init();
                cubeGrid.Components.Add <MyEntityThrustComponent>(entityThrustComponent);
            }

            m_thrustComponent = entityThrustComponent;

            BlockDefinition = (MyThrustDefinition)base.BlockDefinition;

            MyDefinitionId fuelId = new MyDefinitionId();

            if (!BlockDefinition.FuelConverter.FuelId.IsNull())
            {
                fuelId = BlockDefinition.FuelConverter.FuelId;
            }

            MyGasProperties fuelDef = null;

            if (MyFakes.ENABLE_HYDROGEN_FUEL)
            {
                MyDefinitionManager.Static.TryGetDefinition(fuelId, out fuelDef);
            }

            FuelDefinition = fuelDef ?? new MyGasProperties // Use electricity by default
            {
                Id            = MyResourceDistributorComponent.ElectricityId,
                EnergyDensity = 1f,
            };

            base.Init(objectBuilder, cubeGrid);



            var builder = (MyObjectBuilder_Thrust)objectBuilder;

            ThrustColor = BlockDefinition.FlameIdleColor;

            m_thrustOverride.Value = (builder.ThrustOverride * 100f) / BlockDefinition.ForceMagnitude;

            LoadDummies();
            NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;

            m_light = MyLights.AddLight();
            m_light.ReflectorDirection = WorldMatrix.Forward;
            m_light.ReflectorUp        = WorldMatrix.Up;
            m_light.ReflectorRange     = CubeGrid.GridScale;
            m_light.Color          = ThrustColor;
            m_light.GlareMaterial  = BlockDefinition.FlameGlareMaterial;
            m_light.GlareQuerySize = BlockDefinition.FlameGlareQuerySize * CubeGrid.GridScale;

            m_glareSize = BlockDefinition.FlameGlareSize * CubeGrid.GridScale;
            m_maxBillboardDistanceSquared = BlockDefinition.FlameVisibilityDistance * BlockDefinition.FlameVisibilityDistance;
            m_maxLightDistanceSquared     = m_maxBillboardDistanceSquared;

            m_light.Start(MyLight.LightTypeEnum.PointLight, 1);

            UpdateDetailedInfo();

            FuelConverterDefinition = !MyFakes.ENABLE_HYDROGEN_FUEL ? new MyFuelConverterInfo {
                Efficiency = 1.0f
            } : BlockDefinition.FuelConverter;

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
        }
        //  When tube is ejecting and looking for voxels
        void StartFindingVoxel()
        {
            //  Else we normally start ejecting
            CurrentState = MyHarvestingDeviceEnum.FindingVoxel;
            m_headPositionLocal = Vector3.Zero;
            StartTubeMovingCue();
            StopGrindingCue();

            if (m_light != null)
                MyLights.RemoveLight(m_light);
            m_light = null;

            //m_light = MyLights.AddLight();

            if (m_light != null)
            {
                var color = 5 * new Vector4(1, 0.3f, 0.3f, 1);
                m_light.Start(MyLight.LightTypeEnum.PointLight, color, 3, 10);
            }

            MyScriptWrapper.HarvesterUse();
            UpdateAfterSimulation();
        }
Example #33
0
        private void SetRenderSetup()
        {
            return;

            m_setup = new MyRender.MyRenderSetup();

            //m_setup.Fov = MathHelper.ToRadians(75);

            m_setup.CallerID = MyRenderCallerEnum.GUIPreview;

            m_setup.RenderTargets = new Texture[1];


            m_setup.EnabledModules = new HashSet <MyRenderModuleEnum>();
            m_setup.EnabledModules.Add(MyRenderModuleEnum.VoxelHand);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.Decals);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.CockpitWeapons);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.SectorBorder);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.DrawSectorBBox);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.DrawCoordSystem);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.Explosions);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.BackgroundCube);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.GPS);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.TestField);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.AnimatedParticles);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.Lights);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.TransparentGeometryForward);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.Projectiles);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.DebrisField);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.ThirdPerson);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.Editor);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.SolarObjects);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.SolarMapGrid);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.PrunningStructure);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.SunWind);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.IceStormWind);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.PrefabContainerManager);
            m_setup.EnabledModules.Add(MyRenderModuleEnum.PhysicsPrunningStructure);

            m_setup.EnabledRenderStages = new HashSet <MyRenderStage>();
            m_setup.EnabledRenderStages.Add(MyRenderStage.PrepareForDraw);
            m_setup.EnabledRenderStages.Add(MyRenderStage.Background);
            m_setup.EnabledRenderStages.Add(MyRenderStage.LODDrawStart);
            m_setup.EnabledRenderStages.Add(MyRenderStage.LODDrawEnd);
            m_setup.EnabledRenderStages.Add(MyRenderStage.AlphaBlendPreHDR);
            m_setup.EnabledRenderStages.Add(MyRenderStage.AlphaBlend);



            m_setup.EnabledPostprocesses = new HashSet <MyPostProcessEnum>();
            m_setup.EnabledPostprocesses.Add(MyPostProcessEnum.VolumetricSSAO2);
            m_setup.EnabledPostprocesses.Add(MyPostProcessEnum.HDR);


            //m_setup.BackgroundColor = new Color(0.17f, 0.18f, .25f, 0.0f);
            m_setup.BackgroundColor = new Color(Vector4.Zero);

            m_setup.EnableHDR                = false;
            m_setup.EnableSun                = true;
            m_setup.ShadowRenderer           = MyRender.GetShadowRenderer(); // Default shadow render
            m_setup.EnableSmallLights        = true;
            m_setup.EnableDebugHelpers       = false;
            m_setup.EnableEnvironmentMapping = false;
            m_setup.EnableOcclusionQueries   = false;

            m_setup.LodTransitionNear            = 20000;
            m_setup.LodTransitionFar             = 21000;
            m_setup.LodTransitionBackgroundStart = 50000;
            m_setup.LodTransitionBackgroundStart = 51000;

            m_setup.RenderElementsToDraw            = new List <MyRender.MyRenderElement>();
            m_setup.TransparentRenderElementsToDraw = new List <MyRender.MyRenderElement>();
            m_setup.LightsToUse = new List <MyLight>();
            var fillLight = new MyLight();

            fillLight.Start(MyLight.LightTypeEnum.PointLight, .5f * new Vector4(1, 0.95f, 0.8f, 1), 1, 119); // fill light
            m_setup.LightsToUse.Add(fillLight);
            var backLight = new MyLight();

            backLight.Start(MyLight.LightTypeEnum.PointLight, .5f * new Vector4(1, 0.9f, 0.9f, 1), 1, 119); // back light
            m_setup.LightsToUse.Add(backLight);
        }