private void BlockMoveAnimationReset(bool clearAnimation) { if (!IsFunctional) { return; } if (!EmiState.State.Compact && _subpartRotor == null) { Entity.TryGetSubpart("Rotor", out _subpartRotor); if (_subpartRotor == null) { return; } } else if (!EmiState.State.Compact) { if (_subpartRotor.Closed) { _subpartRotor.Subparts.Clear(); } Entity.TryGetSubpart("Rotor", out _subpartRotor); } if (clearAnimation) { RotationTime = 0; TranslationTime = 0; AnimationLoop = 0; EmissiveIntensity = 0; if (!EmiState.State.Compact) { var rotationMatrix = MatrixD.CreateRotationY(0); var matrix = rotationMatrix * MatrixD.CreateTranslation(0, 0, 0); _subpartRotor.PositionComp.LocalMatrix = matrix; _subpartRotor.SetEmissiveParts(PlasmaEmissive, Color.Transparent, 0); } else { MyCube.SetEmissiveParts(PlasmaEmissive, Color.Transparent, 0); } } if (Session.Enforced.Debug == 3) { Log.Line($"EmitterAnimationReset: [EmitterType: {Definition.Name} - Compact({EmiState.State.Compact})] - Tick:{_tick.ToString()} - EmitterId [{Emitter.EntityId}]"); } }
private void SetGyroSubpartEmissives(Color color, bool setGreen = false, bool setYellow = false, bool setRed = false) { GyroSubpart.SetEmissiveParts("Emissive", color, Gyro_block.GyroPower); EmissivesSetToGreen = setGreen; EmissivesSetToYellow = setYellow; EmissivesSetToRed = setRed; }
// Handle static color changes void CheckAndSetEmissives() { if (block.IsFunctional) { CurrentColor = ErrorColor; // Set to error color by default to easily spot an error. float mult = 1f; if (!block.IsWorking) { NeedsUpdate = MyEntityUpdateEnum.NONE; CurrentColor = NonWorkingColor; mult = ThrusterNotWorking_EmissiveMultiplier; } else if (block.Enabled) { CurrentColor = OnColor; mult = ThrusterOn_EmissiveMultiplier; } else { CurrentColor = OffColor; mult = ThrusterOff_EmissiveMultiplier; } block.SetEmissiveParts(EmissiveMaterialName, CurrentColor, mult); if (subpart != null) { subpart.SetEmissiveParts(EmissiveMaterialName, CurrentColor, mult); } } else { if (!ChangeColorByThrustOutput) { NeedsUpdate = MyEntityUpdateEnum.NONE; block.SetEmissiveParts(EmissiveMaterialName, NonFunctionalColor, ThrusterNonFunctional_EmissiveMultiplier); if (subpart != null) { subpart.SetEmissiveParts(EmissiveMaterialName, NonFunctionalColor, ThrusterNonFunctional_EmissiveMultiplier); } } } }
private void SetEmissiveColor(IMyCubeBlock block) { if (Gyro.MarkedForClose || !TryGetSubparts()) { return; } var emissiveColor = !Gyro.IsFunctional ? Color.Black : !Gyro.IsWorking ? RED : Override ? Color.Cyan : GREEN; SubpartCore.SetEmissiveParts(EMISSIVE_MATERIAL_NAME, emissiveColor, 1f); }
// Setters/Getters public void SetTurretLightColor(Color color) { Light_Color = color; //Logger.Instance.LogMessage("light: " + m_light_emmitter); if (m_light_emmitter != null) { m_light_emmitter.ReflectorColor = Light_Color; m_light_emmitter.UpdateLight(); } m_light_model?.SetEmissiveParts(m_EmissiveName, Light_Color, m_turret.IsWorking ? 1 : 0); PlayerInput.Instance.SaveTerminalValues(m_turret.EntityId); }
private void UpdateHealthColor(MyEntitySubpart shellSide) { shellSide.SetEmissiveParts(ShieldHealthEmissive, _activeColor, 100f); }
private void UpdateColor(MyEntitySubpart shellSide) { shellSide.SetEmissiveParts(ShieldEmissiveAlpha, _activeColor, 100f); }
public override void UpdateAfterSimulation() { base.UpdateAfterSimulation(); try { base.UpdateBeforeSimulation(); List <BeaconStorage> temp = store.ToList(); foreach (var beaconStorage in temp) { var entity = beaconStorage.Beacon as MyEntity; bool shouldSpin = beaconStorage.Beacon.IsWorking; // if block is functional and enabled and powered. if (beaconStorage.Beacon.CubeGrid == null && beaconStorage.Effect != null) { beaconStorage.Effect.Stop(); store.Remove(beaconStorage); } if (beaconStorage.Beacon == null || !beaconStorage.Beacon.Enabled || !beaconStorage.Beacon.IsWorking || !beaconStorage.Beacon.IsFunctional) { if (entity != null && entity.TryGetSubpart(SUBPART_NAME, out subpart)) { subpart.SetEmissiveParts("EmissiveSpotlight", Color.DarkRed, 1.0f); } if (beaconStorage.Effect != null) { beaconStorage.Effect.Stop(); } beaconStorage.Once = false; return; } if (!shouldSpin && Math.Abs(targetSpeedMultiplier) < 0.00001f) { return; } if (shouldSpin && targetSpeedMultiplier < 1) { targetSpeedMultiplier = Math.Min(targetSpeedMultiplier + ACCELERATE_PERCENT_PER_TICK, 1); } else if (!shouldSpin && targetSpeedMultiplier > 0) { targetSpeedMultiplier = Math.Max(targetSpeedMultiplier - DEACCELERATE_PERCENT_PER_TICK, 0); } var camPos = MyAPIGateway.Session.Camera.WorldMatrix.Translation; // local machine camera position if (Vector3D.DistanceSquared(camPos, beaconStorage.Beacon.GetPosition()) > MAX_DISTANCE_SQ) { return; } if (entity != null && entity.TryGetSubpart(SUBPART_NAME, out subpart)) // subpart does not exist when block is in build stage { if (subpartFirstFind) // first time the subpart was found { subpartFirstFind = false; subpartLocalMatrix = subpart.PositionComp.LocalMatrix; } if (targetSpeedMultiplier > 0) { subpartLocalMatrix *= Matrix.CreateFromAxisAngle(ROTATION_AXIS, MathHelper.ToRadians(targetSpeedMultiplier * DEGREES_PER_TICK)); subpartLocalMatrix = Matrix.Normalize(subpartLocalMatrix); // normalize to avoid any rotation inaccuracies over time resulting in weird scaling } subpart.PositionComp.LocalMatrix = subpartLocalMatrix; } if (subpart != null) { subpart.SetEmissiveParts("EmissiveSpotlight", Color.LimeGreen, beaconStorage.Beacon.Radius / 6000); } if (beaconStorage.Beacon.Radius < 600) { size = 0.75f; } else if (beaconStorage.Beacon.Radius > 600 && beaconStorage.Beacon.Radius < 3000) { size = beaconStorage.Beacon.Radius / 1000; } else { size = 3.0f; } if (!beaconStorage.Once) { MyParticleEffect e; MyParticlesManager.TryCreateParticleEffect("ExhaustElectricSmall", subpartLocalMatrix, out e); e.WorldMatrix = beaconStorage.Beacon.WorldMatrix; beaconStorage.Effect = e; beaconStorage.Once = true; beaconStorage.Effect.UserScale = size; beaconStorage.Effect.UserEmitterScale = size; beaconStorage.Effect.Play(); } if (beaconStorage.Effect != null) { beaconStorage.Effect.UserScale = size; beaconStorage.Effect.UserEmitterScale = size; beaconStorage.Effect.WorldMatrix = beaconStorage.Beacon.WorldMatrix; beaconStorage.Effect.Update(); } MyEntitySubpart subpart2; if (subpart != null && subpart.TryGetSubpart("Ring", out subpart2)) { beaconStorage.RingRotation -= 1; var rotationMatrix = Matrix.CreateRotationY((beaconStorage.Beacon.Radius / 600) * beaconStorage.RingRotation); subpart2.PositionComp.SetLocalMatrix(ref rotationMatrix, null, true); } } } catch (Exception ex) { MyLog.Default.WriteLine($"Error in Jump Inhibitor {ex}"); } }