예제 #1
0
 public static void RemoveLight(MyLight light)
 {
     if (light != null)
     {
         light.Clear();
         m_preallocatedLights.Deallocate(light);
     }
 }
예제 #2
0
 public static void RemoveLight(MyLight light)
 {
     if (light != null)
     {
         light.Clear();
         m_preallocatedLights.Deallocate(light);
     }
 }        
예제 #3
0
        public static void RemoveLight(MyLight light)
        {
            if (light != null)
            {
                light.Clear();

                //by Gregory: added null check happened once when unloading session
                if (m_preallocatedLights != null)
                {
                    m_preallocatedLights.Deallocate(light);
                }
            }
        }        
예제 #4
0
        public static void RemoveLight(MyLight light)
        {
            if (light != null)
            {
                light.Clear();

                //by Gregory: added null check happened once when unloading session
                if (m_preallocatedLights != null)
                {
                    m_preallocatedLights.Deallocate(light);
                }
            }
        }
        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;
        }
예제 #6
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;
        }
예제 #7
0
        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;
        }
예제 #8
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;
            }

        }
예제 #9
0
        protected override void StartEffects()
        {
            StopEffects();
            MyParticlesManager.TryCreateParticleEffect((int)PARTICLE_EFFECT, out m_particleEffect1);
            MyParticlesManager.TryCreateParticleEffect((int)PARTICLE_EFFECT, out m_particleEffect2);
            UpdateParticleMatrices();

            m_effectLight = CreateEffectLight();
        }
예제 #10
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);
        }
예제 #11
0
 protected abstract void InitLight(MyLight light, Vector4 color, float radius, float falloff);
예제 #12
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            var sinkComp = new MyResourceSinkComponent();
            sinkComp.Init(
                BlockDefinition.ResourceSinkGroup,
                BlockDefinition.RequiredPowerInput,
                () => (Enabled && IsFunctional) ? ResourceSink.MaxRequiredInput : 0f);
            sinkComp.IsPoweredChanged += Receiver_IsPoweredChanged;
            ResourceSink = sinkComp;

            base.Init(objectBuilder, cubeGrid);
            this.IsLargeLight = cubeGrid.GridSizeEnum == MyCubeSize.Large;

            var builder = (MyObjectBuilder_LightingBlock)objectBuilder;
            MyModel lightModel = VRage.Game.Models.MyModels.GetModelOnlyDummies(BlockDefinition.Model);
            foreach (var pair in lightModel.Dummies)
            {
                if (!pair.Key.ToLower().Contains("light"))
                    continue;

                m_lightLocalPosition = pair.Value.Matrix.Translation;
                break;
            }

            Vector4 color = (builder.ColorAlpha == -1)
                ? LightColorDef
                : new Vector4(builder.ColorRed, builder.ColorGreen, builder.ColorBlue, builder.ColorAlpha);

            float radius = RadiusBounds.Clamp((builder.Radius == -1f) ? RadiusBounds.Default : builder.Radius);
            float falloff = FalloffBounds.Clamp(builder.Falloff);

            m_blinkIntervalSeconds.Value = BlinkIntervalSecondsBounds.Clamp((builder.BlinkIntervalSeconds == -1f) ? BlinkIntervalSecondsBounds.Default : builder.BlinkIntervalSeconds);

            m_blinkLength.Value = BlinkLenghtBounds.Clamp((builder.BlinkLenght == -1f) ? BlinkLenghtBounds.Default : builder.BlinkLenght);

            m_blinkOffset.Value = BlinkOffsetBounds.Clamp((builder.BlinkOffset == -1f) ? BlinkOffsetBounds.Default : builder.BlinkOffset);

            m_intesity.Value = IntensityBounds.Clamp((builder.Intensity == -1f) ? IntensityBounds.Default : builder.Intensity);


            m_positionDirty = true;
            m_light = MyLights.AddLight();
            InitLight(m_light, color, radius, falloff);
            
            m_light.ReflectorRange = ShortReflectorRangeDef;
            m_light.Range = radius;
            m_light.PointLightOffset = 0.5f;
            m_light.ReflectorOn = false;
            m_light.LightOn = false;
            m_light.GlareOn = false;
            
            UpdateIntensity();
            UpdateLightPosition();

            NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME | MyEntityUpdateEnum.BEFORE_NEXT_FRAME | MyEntityUpdateEnum.EACH_100TH_FRAME;
            Render.NeedsDrawFromParent = true;

			
			AddDebugRenderComponent(new MyDebugRenderComponentDrawPowerReciever(ResourceSink, this));
			ResourceSink.Update();
            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;
            IsWorkingChanged += CubeBlock_OnWorkingChanged;
        }
        public void CleanLights()
        {
            if (m_light != null)
            {
                MyLights.RemoveLight(m_light);
                m_light = null;
            }
            if (m_leftGlare != null)
            {
                MyLights.RemoveLight(m_leftGlare);
                m_leftGlare = null;
            }
            if (m_rightGlare != null)
            {
                MyLights.RemoveLight(m_rightGlare);
                m_rightGlare = null;
            }

            foreach (var thrust in m_jetpackThrusts)
            {
                MyLights.RemoveLight(thrust.Light);
            }
            m_jetpackThrusts.Clear();
        }
        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;

            MyCharacterBone leftGlareBone = null;
            if (definition.LeftLightBone != String.Empty) leftGlareBone = m_character.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_character.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;
            }
        }
예제 #15
0
        //  Kills this missile. Must be called at her end (after explosion or timeout)
        //  This method must be called when this object dies or is removed
        //  E.g. it removes lights, sounds, etc
        protected override void Closing()
        {
            base.Closing();

            if (this.Physics != null)
            {
                MyMissiles.Remove(this);
            }

            if (m_collidedEntity != null)
            {
                m_collidedEntity.OnClose -= m_collidedEntity_OnClose;
                m_collidedEntity = null;
            }

            if (m_smokeEffect != null)
            {
                m_smokeEffect.Stop();
                m_smokeEffect = null;
            }

            //  Free the light
            if (m_light != null)
            {
                MyLights.RemoveLight(m_light);
                m_light = null;
            }

            //  Stop cue (needed because sound is looping)
            m_soundEmitter.StopSound(true);
        }      
예제 #16
0
        public void Close()
        {
            if (m_light != null)
            {
                MyLights.RemoveLight(m_light);
                m_light = null;
            }

            m_soundEmitter.StopSound(true);
        }
예제 #17
0
        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            base.Init(objectBuilder, cubeGrid);

            BlockDefinition = (MyThrustDefinition)base.BlockDefinition;

            var builder = (MyObjectBuilder_Thrust)objectBuilder;

            ThrustColor = BlockDefinition.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 = ThrustColor;
            m_light.GlareMaterial = BlockDefinition.FlameGlareMaterial;
            m_light.GlareQuerySize = BlockDefinition.FlameGlareQuerySize;

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

            m_light.Start(MyLight.LightTypeEnum.PointLight, 1);
            SyncObject = new MySyncThruster(this);

            UpdateDetailedInfo();

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

            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,
            };

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

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

            m_thrustComponent = entityThrustComponent;
        }
예제 #18
0
 protected override void StopEffects()
 {
     if (m_particleEffect1 != null)
     {
         m_particleEffect1.Stop();
         m_particleEffect1 = null;
     }
     if (m_particleEffect2 != null)
     {
         m_particleEffect2.Stop();
         m_particleEffect2 = null;
     }
     if (m_effectLight != null)
     {
         MyLights.RemoveLight(m_effectLight);
         m_effectLight = null;
     }
 }
예제 #19
0
 protected override void StopEffects()
 {
     m_wantsToGrind = false;
     StopSparks();
     if (m_effectLight != null)
     {
         MyLights.RemoveLight(m_effectLight);
         m_effectLight = null;
     }
 }
예제 #20
0
        void StartInternal()
        {
            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyExplosion.StartInternal");

            m_velocity = m_explosionInfo.Velocity;
            m_explosionSphere = m_explosionInfo.ExplosionSphere;

            if (m_explosionInfo.PlaySound)
            {
                //  Play explosion sound
                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Sound");
                PlaySound();
                VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
            }

            //  Light of explosion
            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Light");
            m_light = MyLights.AddLight();
            if (m_light != null)
            {
                m_light.Start(MyLight.LightTypeEnum.PointLight, m_explosionSphere.Center, MyExplosionsConstants.EXPLOSION_LIGHT_COLOR, 1, Math.Min((float)m_explosionSphere.Radius * 8.0f, MyLightsConstants.MAX_POINTLIGHT_RADIUS));
                m_light.Intensity = 2.0f;
                m_light.Range = Math.Min((float)m_explosionSphere.Radius * 3.0f, MyLightsConstants.MAX_POINTLIGHT_RADIUS);

            } 
            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();

            // Particles
            if (m_explosionInfo.CreateParticleEffect)
            {
                CreateParticleEffectInternal();
            }

            m_explosionTriggered = false;

            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
        }
예제 #21
0
        void StartInternal()
        {
            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyExplosion.StartInternal");

            if (m_soundEmitter == null)
                m_soundEmitter = new MyEntity3DSoundEmitter(null);

            m_velocity = m_explosionInfo.Velocity;
            m_explosionSphere = m_explosionInfo.ExplosionSphere;

            if (m_explosionInfo.PlaySound)
            {
                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Sound");
                //  Play explosion sound
                PlaySound();
                VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
            }

            VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Light");
            //  Light of explosion
            m_light = MyLights.AddLight();
            if (m_light != null)
            {
                m_light.Start(MyLight.LightTypeEnum.PointLight, m_explosionSphere.Center, MyExplosionsConstants.EXPLOSION_LIGHT_COLOR, 1, Math.Min((float)m_explosionSphere.Radius * 8.0f, MyLightsConstants.MAX_POINTLIGHT_RADIUS));
                m_light.Intensity = 2.0f;
                m_light.Range = Math.Min((float)m_explosionSphere.Radius * 3.0f, MyLightsConstants.MAX_POINTLIGHT_RADIUS);

            } 
            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();

            MyParticleEffectsIDEnum newParticlesType;

            switch (m_explosionInfo.ExplosionType)
            {
                case MyExplosionTypeEnum.MISSILE_EXPLOSION:
                    newParticlesType = MyParticleEffectsIDEnum.Explosion_Missile;
                    break;

                case MyExplosionTypeEnum.BOMB_EXPLOSION:
                    newParticlesType = MyParticleEffectsIDEnum.Explosion_Bomb;
                    break;

                case MyExplosionTypeEnum.AMMO_EXPLOSION:
                    newParticlesType = MyParticleEffectsIDEnum.Explosion_Ammo;
                    break;

                case MyExplosionTypeEnum.GRID_DEFORMATION:
                    newParticlesType = MyParticleEffectsIDEnum.Grid_Deformation;
                    break;

                case MyExplosionTypeEnum.GRID_DESTRUCTION:
                    newParticlesType = MyParticleEffectsIDEnum.Grid_Destruction;
                    break;

                case MyExplosionTypeEnum.WARHEAD_EXPLOSION_02:
                    newParticlesType = MyParticleEffectsIDEnum.Explosion_Warhead_02;
                    break;

                case MyExplosionTypeEnum.WARHEAD_EXPLOSION_15:
                    newParticlesType = MyParticleEffectsIDEnum.Explosion_Warhead_15;
                    break;

                case MyExplosionTypeEnum.WARHEAD_EXPLOSION_30:
                    newParticlesType = MyParticleEffectsIDEnum.Explosion_Warhead_30;
                    break;

                case MyExplosionTypeEnum.WARHEAD_EXPLOSION_50:
                    newParticlesType = MyParticleEffectsIDEnum.Explosion_Warhead_50;
                    break;

                default:
                    throw new System.NotImplementedException();
                    break;
            }

            if (m_explosionInfo.CreateParticleEffect)
            {
                VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("Particles");


                //  Explosion particles
                GenerateExplosionParticles(newParticlesType, m_explosionSphere, m_explosionInfo.ParticleScale);


                VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
            }

            m_explosionTriggered = false;

            VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock();
        }
예제 #22
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 ? 15f : 0.2f;
            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();
        }
        // ------------------------------------------------------------------------------------------------
        #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.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;
        }
 public void CleanLight()
 {
     if (m_light != null)
     {
         MyLights.RemoveLight(m_light);
         m_light = null;
     }
 }
        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;
            }
        }