//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. } }
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. } }
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. } }
/// <summary> /// Create a RadarEquipment for an entity, with the specified definition and an owner block. /// </summary> public RadarEquipment(IMyEntity radarEntity, Definition radarDef, IMyCubeBlock relationsBlock) { this.Log = new Logger(() => RelationsBlock.CubeGrid.DisplayName, () => RelationsBlock.DisplayNameText, () => radarEntity.ToString()); this.Entity = radarEntity; this.RelationsBlock = relationsBlock; this.myDefinition = radarDef; Registrar.Add(radarEntity, this); PowerLevel_Current = PowerLevel_Target = this.myDefinition.MaxPowerLevel; byte detectionTypes = 0; if (myDefinition.Radar) { detectionTypes++; } if (myDefinition.PassiveDetect_Jamming > 0) { detectionTypes++; } if (myDefinition.PassiveDetect_Radar > 0) { detectionTypes++; } if (detectionTypes > 1) { detectedObjects_hash = new Dictionary <IMyEntity, DetectedInfo>(); } m_beaconLight = GetLight(); Log.DebugLog("Radar equipment initialized, power level: " + PowerLevel_Current, Logger.severity.INFO); }
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); }
// 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(); }
// Kills this missile. Must be called at her end (after explosion or timeout) public override void Close() { base.Close(); if (m_collidedEntity != null) { m_collidedEntity.OnClose -= m_collidedEntityClosedHandler; m_collidedEntity = null; } // Free the light if (m_light != null) { MyLights.RemoveLight(m_light); m_light = null; } // Stop thruster cue if ((m_thrusterCue != null) && (m_thrusterCue.Value.IsPlaying == true)) { m_thrusterCue.Value.Stop(SharpDX.XACT3.StopFlags.Immediate); } if (m_smokeEffect != null) { m_smokeEffect.Stop(); m_smokeEffect = null; } MyCannonShots.Remove(this); }
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); }
/* * public void OnMyShadowCheckEnable(MyGuiControlCheckbox sender) * { * foreach (MyPrefabLight prefabLight in m_prefabLights) * { * MyLight myLight = prefabLight.GetLight(); * * if (sender == m_spotLightShadowCheckbox) * { * myLight.ShadowsEnabled = sender.Checked; * } * * prefabLight.OnWorldPositionChanged(this); * prefabLight.UpdateEffect(); * } * OnComponentChange(null); * } */ void OnComponentChange(MyGuiControlSlider sender) { foreach (MyPrefabLight prefabLight in m_prefabLights) { MyLight light = prefabLight.GetLight(); Color tmpColor = new Color(); tmpColor.R = (byte)m_pointNormalLightColorSlider[0].GetValue(); tmpColor.G = (byte)m_pointNormalLightColorSlider[1].GetValue(); tmpColor.B = (byte)m_pointNormalLightColorSlider[2].GetValue(); light.Color = tmpColor.ToVector4(); tmpColor.R = (byte)m_specularLightColorSlider[0].GetValue(); tmpColor.G = (byte)m_specularLightColorSlider[1].GetValue(); tmpColor.B = (byte)m_specularLightColorSlider[2].GetValue(); light.SpecularColor = tmpColor.ToVector3(); light.Falloff = m_pointFallOffSlider.GetValue(); // allowed values 0.1f-5.0f light.Range = m_pointRangeSlider.GetValue(); // allowed values 0.0f-MyLightsConstants.MAX_POINTLIGHT_RADIUS light.Intensity = prefabLight.m_IntensityMax = m_pointIntensitySlider.GetValue(); // allowed values 0.0f-10.0f light.PointLightOffset = m_pointOffsetSlider.GetValue(); tmpColor.R = (byte)m_spotNormalLightColorSlider[0].GetValue(); tmpColor.G = (byte)m_spotNormalLightColorSlider[1].GetValue(); tmpColor.B = (byte)m_spotNormalLightColorSlider[2].GetValue(); light.ReflectorColor = tmpColor.ToVector4(); light.ReflectorFalloff = m_spotFallOffSlider.GetValue(); // allowed values 0.1f-5.0f light.ReflectorRange = m_spotRangeSlider.GetValue(); // allowed values 0.0f-MyLightsConstants.MAX_SPOTLIGHT_RANGE light.ReflectorIntensity = prefabLight.ReflectorIntensityMax = m_spotIntensitySlider.GetValue(); // allowed values 0.0f-10.0f light.ReflectorConeDegrees = m_spotAngleSlider.GetValue(); // allowed values 0.0f-MyLightsConstants.MAX_SPOTLIGHT_ANGLE light.ShadowDistance = m_spotLightShadowDistance.GetValue(); prefabLight.FlashOffset = m_flashOffsetSlider.GetValue(); } }
public void RestoreOriginalValues() { if (m_originalValues != null) { for (int i = 0; i < m_originalValues.Count; i++) { MyLightProperties originalValue = m_originalValues[i]; MyLight light = m_prefabLights[i].GetLight(); light.Color = originalValue.Color; light.SpecularColor = originalValue.SpecularColor; light.Falloff = originalValue.FallOff; light.Range = originalValue.Range; light.Intensity = originalValue.Intensity; light.PointLightOffset = originalValue.PointLightOffSet; light.ReflectorColor = originalValue.ReflectorColor; light.ReflectorFalloff = originalValue.ReflectorFallOff; light.ReflectorRange = originalValue.ReflectorRange; light.ReflectorIntensity = originalValue.ReflectorIntensity; light.ReflectorConeDegrees = originalValue.ReflectorConeDegrees; light.LightType = originalValue.LightType; m_prefabLights[i].FlashOffset = originalValue.FlashOffset; originalValue.PrefabLight.OnWorldPositionChanged(this); } } }
private void InitializeValues(MyPrefabLight prefabLight) { MyLight light = prefabLight.GetLight(); m_pointNormalLightColorSlider[0].SetNormalizedValue(light.Color.X); m_pointNormalLightColorSlider[1].SetNormalizedValue(light.Color.Y); m_pointNormalLightColorSlider[2].SetNormalizedValue(light.Color.Z); m_specularLightColorSlider[0].SetNormalizedValue(light.SpecularColor.X); m_specularLightColorSlider[1].SetNormalizedValue(light.SpecularColor.Y); m_specularLightColorSlider[2].SetNormalizedValue(light.SpecularColor.Z); m_pointFallOffSlider.SetValue(light.Falloff); m_pointRangeSlider.SetValue(light.Range); m_pointIntensitySlider.SetValue(light.Intensity); m_pointOffsetSlider.SetValue(light.PointLightOffset); m_spotNormalLightColorSlider[0].SetNormalizedValue(light.ReflectorColor.X); m_spotNormalLightColorSlider[1].SetNormalizedValue(light.ReflectorColor.Y); m_spotNormalLightColorSlider[2].SetNormalizedValue(light.ReflectorColor.Z); m_spotFallOffSlider.SetValue(light.ReflectorFalloff); m_spotRangeSlider.SetValue(light.ReflectorRange); m_spotIntensitySlider.SetValue(light.ReflectorIntensity); m_spotAngleSlider.SetValue(light.ReflectorConeDegrees); m_pointLightCheckbox.Checked = (light.LightType & MyLight.LightTypeEnum.PointLight) != 0; m_hemisphereLightCheckbox.Checked = (light.LightType & MyLight.LightTypeEnum.Hemisphere) != 0; m_spotLightCheckbox.Checked = (light.LightType & MyLight.LightTypeEnum.Spotlight) != 0; m_spotLightShadowDistance.SetValue(light.ShadowDistance); m_flashOffsetSlider.SetValue(prefabLight.FlashOffset); m_effectComboBox.SelectItemByIndex((int)prefabLight.Effect); SetComponentsVisibility(); }
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 StartEffect() { StopEffect(); MyParticlesManager.TryCreateParticleEffect((int)EffectId, out m_toolEffect); m_toolEffectLight = CreatePrimaryLight(); UpdateEffect(); }
// 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); }
// ------------------------------------------------------------------------------------------------ #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; }
void StartSecondaryEffect() { StopSecondaryEffect(); MyParticlesManager.TryCreateParticleEffect((int)SecondaryEffectId, out m_toolSecondaryEffect); m_toolEffectLight = CreateSecondaryLight(); UpdateEffect(); }
public override void Close() { // Free the light if (m_light != null) { MyLights.RemoveLight(m_light); m_light = null; } // Stop sound cues if ((m_grindingCue != null) && (m_grindingCue.Value.IsPlaying == true)) { m_grindingCue.Value.Stop(SharpDX.XACT3.StopFlags.Immediate); } if ((m_grindingReleaseCue != null) && (m_grindingReleaseCue.Value.IsPlaying == true)) { m_grindingReleaseCue.Value.Stop(SharpDX.XACT3.StopFlags.Immediate); } if ((m_tubeMovingCue != null) && (m_tubeMovingCue.Value.IsPlaying == true)) { m_tubeMovingCue.Value.Stop(SharpDX.XACT3.StopFlags.Immediate); } CloseEffect(); base.Close(); }
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(); }
public void CleanLights() { if (this.m_light != null) { MyLights.RemoveLight(this.m_light); this.m_light = null; } if (this.m_flareLeft != null) { MyLights.RemoveLight(this.m_flareLeft); this.m_flareLeft = null; } if (this.m_flareRight != null) { MyLights.RemoveLight(this.m_flareRight); this.m_flareRight = null; } using (List <MyJetpackThrust> .Enumerator enumerator = this.m_jetpackThrusts.GetEnumerator()) { while (enumerator.MoveNext()) { MyLights.RemoveLight(enumerator.Current.Light); } } this.m_jetpackThrusts.Clear(); }
public void CleanLight() { if (m_light != null) { MyLights.RemoveLight(m_light); m_light = null; } }
public void Close() { if (Light != null) { MyLights.RemoveLight(Light); Light = null; } }
public MyLightGlare(MyLight light) { m_parent = light; m_occlusionBox = new BoundingBox(); m_occlusionQuery = MyOcclusionQueries.Get(); m_measurementQuery = MyOcclusionQueries.Get(); }
public static MyLight getInstance() { if (instance == null) { instance = new MyLight(); } return(instance); }
protected override void StartEffects() { StopEffects(); MyParticlesManager.TryCreateParticleEffect((int)PARTICLE_EFFECT, out m_particleEffect); UpdateParticleMatrix(); m_effectLight = CreateEffectLight(); }
public static void ToggleLight(MyLight light) { if (light != null) { light.LightOn = !light.LightOn; light.UpdateLight(); } }
public void CleanLight() { if (this.m_light != null) { MyLights.RemoveLight(this.m_light); this.m_light = null; } }
public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid) { MyBeaconDefinition blockDefinition = base.BlockDefinition as MyBeaconDefinition; if (blockDefinition.EmissiveColorPreset == MyStringHash.NullOrEmpty) { blockDefinition.EmissiveColorPreset = MyStringHash.GetOrCompute("Beacon"); } MyResourceSinkComponent component = new MyResourceSinkComponent(1); component.Init(MyStringHash.GetOrCompute(blockDefinition.ResourceSinkGroup), 0.02f, new Func <float>(this.UpdatePowerInput)); base.ResourceSink = component; this.RadioBroadcaster = new MyRadioBroadcaster(blockDefinition.MaxBroadcastRadius / 10f); MyObjectBuilder_Beacon beacon = (MyObjectBuilder_Beacon)objectBuilder; if (beacon.BroadcastRadius > 0f) { this.RadioBroadcaster.BroadcastRadius = beacon.BroadcastRadius; } this.RadioBroadcaster.BroadcastRadius = MathHelper.Clamp(this.RadioBroadcaster.BroadcastRadius, 1f, blockDefinition.MaxBroadcastRadius); this.HudText.Clear(); if (beacon.HudText != null) { this.HudText.Append(beacon.HudText); } base.Init(objectBuilder, cubeGrid); component.IsPoweredChanged += new Action(this.Receiver_IsPoweredChanged); component.Update(); MyRadioBroadcaster radioBroadcaster = this.RadioBroadcaster; radioBroadcaster.OnBroadcastRadiusChanged = (Action)Delegate.Combine(radioBroadcaster.OnBroadcastRadiusChanged, new Action(this.OnBroadcastRadiusChanged)); this.m_largeLight = cubeGrid.GridSizeEnum == MyCubeSize.Large; this.m_light = MyLights.AddLight(); if (this.m_light != null) { this.m_light.Start(this.DisplayNameText); this.m_light.Range = this.m_largeLight ? 2f : 0.3f; this.m_light.GlareOn = false; this.m_light.GlareQuerySize = this.m_largeLight ? 1.5f : 0.3f; this.m_light.GlareQueryShift = this.m_largeLight ? 1f : 0.2f; this.m_light.GlareType = MyGlareTypeEnum.Normal; this.m_light.GlareMaxDistance = GLARE_MAX_DISTANCE; MyDefinitionId id = new MyDefinitionId(typeof(MyObjectBuilder_FlareDefinition), blockDefinition.Flare); MyFlareDefinition definition = MyDefinitionManager.Static.GetDefinition(id) as MyFlareDefinition; this.m_flare = definition ?? new MyFlareDefinition(); this.m_light.GlareIntensity = this.m_flare.Intensity; this.m_light.GlareSize = this.m_flare.Size; this.m_light.SubGlares = this.m_flare.SubGlares; } this.m_lightPositionOffset = this.m_largeLight ? new Vector3(0f, base.CubeGrid.GridSize * 0.3f, 0f) : Vector3.Zero; this.UpdateLightPosition(); this.m_restartTimeMeasure = false; this.AnimationRunning = true; base.SlimBlock.ComponentStack.IsFunctionalChanged += new Action(this.ComponentStack_IsFunctionalChanged); base.IsWorkingChanged += new Action <MyCubeBlock>(this.MyBeacon_IsWorkingChanged); base.ShowOnHUD = false; this.UpdateText(); }
public void Close() { m_explosionCue = null; if (m_light != null) { MyLights.RemoveLight(m_light); m_light = null; } }
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(); }
private IEnumerator RenderPic() { // 5s后执行 因为有些力的关系需要计算清楚 yield return(new WaitForSeconds(5)); // 冻结位置 // ------ float minX, maxX; FreezeRigidbody(out minX, out maxX); // 加载摄像机 // ------ GameObject cameraObj; cameraObj = Instantiate(MyCamera.getInstance().GetCamera()) as GameObject; float tag = Random.Range(-1.0f, 1.0f); if (tag >= 0) { cameraObj.transform.position = new Vector3(Mathf.Round((maxX - minX) / 2), Random.Range(20.0f, 30.0f), Random.Range(-85.0f, -55.0f)); cameraObj.transform.Rotate(Random.Range(0.0f, 25.0f), Random.Range(-20.0f, 20.0f), 0.0f); } else { cameraObj.transform.position = new Vector3(Mathf.Round((maxX - minX) / 2), Random.Range(20.0f, 30.0f), Random.Range(65.0f, 55.0f)); cameraObj.transform.Rotate(Random.Range(0.0f, 25.0f), Random.Range(160.0f, 200.0f), 0.0f); } // 加载灯光 // ------ GameObject lightObj; lightObj = Instantiate(MyLight.getInstance().GetLight()) as GameObject; lightObj.transform.position = new Vector3(Random.Range(-40.0f, 40.0f), 60.0f, 0.0f); // meanless lightObj.transform.Rotate(new Vector3(Random.Range(20.0f, 60.0f), Random.Range(0.0f, 180.0f), 0.0f)); // 1s后执行 是为了触发BVisible yield return(new WaitForSeconds(1)); // 存储物体坐标 // ------ SaveScreenCoordinate(ref cameraObj); // 等待渲染线程结束 yield return(new WaitForEndOfFrame()); // 存储截屏 // ------ SaveScreenPic(); // 销毁物体 // ------ DestoryModels(ref lightObj, ref cameraObj); }
public override void UpdateBeforeSimulation() { base.UpdateBeforeSimulation(); if (m_elapsedMiliseconds > MyIlluminatingShellsConstants.MAX_LIVING_TIME + MyIlluminatingShellsConstants.DIYNG_TIME) { if (m_particleEffect != null) { m_particleEffect.Stop(); m_particleEffect = null; } // Free the light if (m_light != null) { MyLights.RemoveLight(m_light); m_light = null; } MarkForClose(); } // Update light position if (m_light != null) { // Aggro near bots if (m_light.LightOn) { if (this.WorldMatrix.Translation != m_previousPosition) { MyLine line = new MyLine(m_previousPosition, WorldMatrix.Translation); MyDangerZones.Instance.Notify(line, OwnerEntity); } } if ((m_elapsedMiliseconds > MyIlluminatingShellsConstants.MAX_LIVING_TIME) && (m_elapsedMiliseconds < MyIlluminatingShellsConstants.MAX_LIVING_TIME + MyIlluminatingShellsConstants.DIYNG_TIME)) { m_light.LightOn = MyMwcUtils.GetRandomBool(2); m_particleEffect.UserScale = m_light.LightOn ? 1.0f : 0.001f; } m_light.SetPosition(GetPosition()); m_light.Color = MyIlluminatingShellsConstants.LIGHT_COLOR; m_light.Range = MyIlluminatingShellsConstants.LIGHT_RADIUS; } }
// 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 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; } }
// 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 public override void Close() { UpdateTarget(null); base.Close(); this.Physics.Clear(); 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 thruster cue if ((m_thrusterCue != null) && (m_thrusterCue.Value.IsPlaying == true)) { m_thrusterCue.Value.Stop(SharpDX.XACT3.StopFlags.Immediate); } m_thrusterCue = null; }
// 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(); }
// When tube is inside miner ship, default status void StartInsideShip() { CurrentState = MyHarvestingDeviceEnum.InsideShip; StopTubeMovingCue(); if (m_light != null) MyLights.RemoveLight(m_light); m_light = null; }