public void shieldStuff() { try { points = TeaShieldBase.recharge(fBlock, max, fBlock.Enabled && sink.IsPowerAvailable(electricity, powerCalc())); sink.Update(); if (!fBlock.Enabled || !fBlock.IsFunctional || !sink.IsPowerAvailable(electricity, powerCalc())) { for (int i = 1; i < 9; i++) { sbBlock.SetEmissiveParts("Emissive" + i, Color.Red, i == 6 ? 1f : 0f); } } else { sbBlock.SetEmissiveParts("Emissive7", Color.Yellow, 0.25f); sbBlock.SetEmissiveParts("Emissive8", Color.White, 1f); var perc = points / max; var blinkCalc = (int)(perc * 5) + 1; if (perc < 0.99f) { if (++chargeBlink > blinkCalc) { chargeBlink = 0; blink = !blink; for (int i = 1; i < 5; i++) { sbBlock.SetEmissiveParts("Emissive" + i, colour(perc), i == lx ? 1f : 0f); } lx = lx == 4 ? 1 : lx + 1; } sbBlock.SetEmissiveParts("Emissive5", colour(perc), blink ? (1.3f - perc) : 0.1f); sbBlock.SetEmissiveParts("Emissive6", perc < 0.9f ? Color.Cyan : Color.Green, 1f); } else { for (int i = 1; i < 7; i++) { sbBlock.SetEmissiveParts("Emissive" + i, Color.Green, 1f); } } } fBlock.RefreshCustomInfo(); } catch (Exception ex) { Echo("IAShields threw exception", ex.ToString()); } }
public override void UpdateAfterSimulation() { try { if (npcCrewBlock.GetDiffuseColor() != Color.SteelBlue.ColorToHSV() && forceColor) { npcCrewBlock.CubeGrid.ColorBlocks(npcCrewBlock.SlimBlock.Position, npcCrewBlock.SlimBlock.Position, Color.SteelBlue.ColorToHSV()); } if (npcCrewBlock.IsWorking && npcCrewBlock.IsFunctional && Sink.IsPowerAvailable(GId, 0.01f)) { if (playAnimation) { MoveHead(); MoveLeftArm(); MoveRightArm(); MoveLCD(); MoveLCD2(); MoveLCD3(); } } } catch (Exception e) { MyVisualScriptLogicProvider.ShowNotificationToAll("Update Error" + e, 2500, "Red"); } }
private bool IsWorking() { if (_ublock.Closed || _ublock.MarkedForClose) { MarkForClose(); return(false); } return(_ublock.IsFunctional && _ublock.Enabled && _sink.IsPowerAvailable(Electricity, _maxrange / 5f)); }
bool IsWorking() { if (_imyUM.Closed || _imyUM.MarkedForClose) { MarkForClose(); return(false); } if (!_sink.IsPowerAvailable(Electricity, _power) && _imyUM.Enabled) { _timeOut = 0; _imyUM.Enabled = false; } return(_imyUM.IsFunctional && _imyUM.Enabled); }
public override void UpdateAfterSimulation10() { if (MyAPIGateway.Multiplayer.IsServer) { initializeGUI(); energySink.Update(); //MyAPIGateway.Utilities.ShowNotification(calcRequiredPower()+" for "+this); if (!energySink.IsPowerAvailable(MyResourceDistributorComponent.ElectricityId, calcRequiredPower())) { onEnergyLoss(); } } }
private float RequiredInputFunc() { if (!m_functionalBlock.Enabled || !CubeBlock.IsFunctional) { return(0f); } var powerneeded = m_powerConsumption * Heat / MaxHeat; if (m_resourceSink.IsPowerAvailable(m_electricityDefinition, powerneeded)) { m_powerAvailable = true; return(powerneeded); } else { m_powerAvailable = false; return(0f); } }
public override void UpdateBeforeSimulation() { // Ignore damaged or build progress hyper_blocks. Ignore ghost grids (projections). if (!hyperDriveBlock.IsFunctional || hyperDriveBlock.CubeGrid.Physics == null) { return; } _ticks++; _tick++; HyperFunctions.UpdateGridPower(); ResourceSink.Update(); hyperDriveBlock.RefreshCustomInfo(); if (!firstrun) { if (_ticks > 12) { HyperFunctions.RefreshLists(); HyperFunctions.Distance(); totalMass = Math.Sqrt(hyperDriveBlock.CubeGrid.Physics.Mass); totalMassF = (float)totalMass; HyperFunctions.curPDistF = (float)HyperFunctions.distance; MyAPIGateway.Parallel.StartBackground(HyperFunctions.BackGroundChecks); HyperFunctions._powerPercent = (HyperFunctions._maxPower * 0.6f); if (HyperFunctions.curPDistF < HyperFunctions.maxPDistF) { if (HyperFunctions._powerPercent >= 100f && HyperFunctions._powerPercent <= Maxhyper) { hyperFactor = HyperFunctions._powerPercent; float invSqr = (((HyperFunctions.maxPDistF * HyperFunctions.maxPDistF) / (HyperFunctions.curPDistF * HyperFunctions.curPDistF)) * 0.01f); if (invSqr < 0.95f) { hyperFactor = (hyperFactor - (hyperFactor * invSqr)); gravMsg = true; } else if (invSqr >= 0.95f) { hyperFactor = 0f; Engage_OnOff(); if (gravMsg) { var realPlayerIds = new List <long>(); DsUtilsStatic.GetRealPlayers(hyperDriveBlock.PositionComp.WorldVolume.Center, 500f, realPlayerIds); foreach (var id in realPlayerIds) { MyVisualScriptLogicProvider.ShowNotification("Gravity Field Interference: " + "Minimum Safe Distance - 200km", 19200, "Red", id); } gravMsg = false; } } } } else if (HyperFunctions.curPDistF > HyperFunctions.maxPDistF) { if (HyperFunctions._powerPercent >= 100f && HyperFunctions._powerPercent <= Maxhyper) { hyperFactor = HyperFunctions._powerPercent; } } //Convert Mass Double to non-Infinite Float// if (float.IsPositiveInfinity(totalMassF)) { totalMassF = float.MaxValue; } else if (float.IsNegativeInfinity(totalMassF)) { totalMassF = float.MinValue; } if (float.IsPositiveInfinity(HyperFunctions.curPDistF)) { HyperFunctions.curPDistF = float.MaxValue; } else if (float.IsNegativeInfinity(HyperFunctions.curPDistF)) { HyperFunctions.curPDistF = float.MinValue; } _ticks = 0; } if (MyAPIGateway.Session.IsServer) { if (ResourceSink.IsPowerAvailable(_electricity, HyperFunctions.PowerConsumption())) { BubbleFormed = true; _bubbleNotification = true; } else if (!ResourceSink.IsPowerAvailable(_electricity, HyperFunctions.PowerConsumption())) { BubbleFormed = false; } if (_tick > 10000) { _tick = 0; msgSent = false; } if (HyperFunctions.IsWorking() && hyperDriveBlock.CubeGrid.Physics.LinearVelocity.LengthSquared() >= 0f && HyperEngaged) { hyper = true; var grid = hyperDriveBlock.CubeGrid; //_minSpeed = hyperDriveBlock.CubeGrid.Physics.LinearVelocity.LengthSquared(); //if (_minSpeed >= 5000) //{ if (BubbleFormed && hyperDriveBlock.CubeGrid.Physics != null && hyperDriveBlock.CubeGrid.WorldMatrix != null && hyperDriveBlock.CubeGrid.WorldMatrix.Translation != null && warpTimer < 300) { //remoteControl; //hyperDriveBlock.SetLocalMatrix(hyperDriveBlock.LocalMatrix, shipForward); //hyperDriveBlock.CubeGrid.SetLocalMatrix(hyperDriveBlock.CubeGrid.LocalMatrix, hyperDriveBlock.Orientation.Forward); //var fwd = hyperDriveBlock.CubeGrid.LocalMatrix.GetDirectionVector(hyperDriveBlock.Orientation.Forward); from = hyperDriveBlock.WorldMatrix.Translation + hyperDriveBlock.WorldMatrix.Forward; // * 1d; to = hyperDriveBlock.WorldMatrix.Translation + hyperDriveBlock.WorldMatrix.Forward * 50d; var gridSpeed = hyperDriveBlock.CubeGrid.WorldMatrix; var gridTranslation = hyperDriveBlock.CubeGrid.WorldMatrix.Translation; var gPhysics = hyperDriveBlock.CubeGrid.Physics; var gameSteps = MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS; var predictedMatrix = hyperDriveBlock.CubeGrid.WorldMatrix; var multipler = 500; predictedMatrix.Translation = gridTranslation + gPhysics.GetVelocityAtPoint(gridTranslation) * gameSteps * multipler; //gPhysics.LinearVelocity = (fwd ); gPhysics.LinearVelocity = from - to; //object not set remoteControl.DampenersOverride = false; //grid.Physics.SetSpeeds(gPhysics.LinearVelocity, Vector3.Zero); gPhysics.AngularVelocity = Vector3D.Zero; grid.Teleport(predictedMatrix); gPhysics.AngularVelocity = Vector3D.Zero; warpTimer = (warpTimer + 1); if (warpTimer > 250 && fade) { fade = false; var realPlayerIds = new List <long>(); DsUtilsStatic.GetRealPlayers(hyperDriveBlock.PositionComp.WorldVolume.Center, 500f, realPlayerIds); foreach (var id in realPlayerIds) { //MyVisualScriptLogicProvider.ShowNotification("Jump Initialisation Success: " + "Maybe", 19200, "White", id); MyVisualScriptLogicProvider.ScreenColorFadingStart(0.25f, true); } } //var setSpeed = hyperDriveBlock.CubeGrid.Physics.LinearVelocity; //remoteControl.WorldMatrix.SetDirectionVector(remoteControl.Orientation.Forward, shipForward); /* Original Code * var gridSpeed = hyperDriveBlock.CubeGrid.WorldMatrix; * var gridTranslation = hyperDriveBlock.CubeGrid.WorldMatrix.Translation; * var gPhysics = hyperDriveBlock.CubeGrid.Physics; * var gameSteps = MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS; * var predictedMatrix = hyperDriveBlock.CubeGrid.WorldMatrix; * var multipler = WF_Scale; * predictedMatrix.Translation = gridTranslation + gPhysics.GetVelocityAtPoint(gridTranslation) * gameSteps * multipler; * gPhysics.AngularVelocity = Vector3D.Zero; * grid.Teleport(predictedMatrix); * gPhysics.AngularVelocity = Vector3D.Zero;*/ } //} else { hyper = false; warpTimer = 0; fade = true; var realPlayerIds = new List <long>(); DsUtilsStatic.GetRealPlayers(hyperDriveBlock.PositionComp.WorldVolume.Center, 500f, realPlayerIds); foreach (var id in realPlayerIds) { MyVisualScriptLogicProvider.ShowNotification("Jump Time: " + "Time to Jump to HyperSpace", 19200, "Red", id); MyVisualScriptLogicProvider.ScreenColorFadingStartSwitch(0.1f); } //Color White = new Color(); //White = Color.White; //MyVisualScriptLogicProvider.ScreenColorFadingSetColor(White); //MyVisualScriptLogicProvider.ScreenColorFadingStart(4, true); //MyVisualScriptLogicProvider.ScreenColorFadingStartSwitch(1); } } if (!BubbleFormed && hyperDriveBlock.Enabled && _tick > 16) { var realPlayerIds = new List <long>(); DsUtilsStatic.GetRealPlayers(hyperDriveBlock.PositionComp.WorldVolume.Center, 500f, realPlayerIds); foreach (var id in realPlayerIds) { MyVisualScriptLogicProvider.ShowNotification("hyper Field Collapse Imminent: " + "Emergency Shutdown" + "\nInsufficient Power - You require additional pylons.", 19200, "Red", id); } WF_Scale = 0f; hyper = false; hyperDriveBlock.Enabled = false; } if (!HyperFunctions.IsWorking() && hyper) { var realPlayerIds = new List <long>(); DsUtilsStatic.GetRealPlayers(hyperDriveBlock.PositionComp.WorldVolume.Center, 500f, realPlayerIds); foreach (var id in realPlayerIds) { MyVisualScriptLogicProvider.ShowNotification("hyper Drive Manually Disabled: Emergency Stop", 19200, "White", id); } WF_Scale = 0f; hyper = false; HyperFunctions.EmergencyStop(); } if (hyper) { if (WF_Scale < hyperFactor && WF_Scale >= 0f) { float WF_CurveM = (hyperFactor - hyperFactor * 0.05f); if (WF_Scale < WF_CurveM) { WF_Curve = (hyperFactor * 0.0001f); WF_Scale = (WF_Curve + (WF_Scale + (WF_Scale * 0.0025f))); } else if (WF_Scale > WF_CurveM) { WF_Scale = hyperFactor; } } else if (WF_Scale > hyperFactor && WF_Scale >= 0f) { float WF_CurveP = (hyperFactor * 0.05f + hyperFactor); if (WF_Scale > WF_CurveP) { WF_Scale--; } if (WF_Scale < WF_CurveP) { WF_Scale = hyperFactor; } } else if (WF_Scale == hyperFactor && WF_Scale > 0.1f) { if (hyperFactor > 30f && hyper && !msgSent) { var realPlayerIds = new List <long>(); DsUtilsStatic.GetRealPlayers(hyperDriveBlock.PositionComp.WorldVolume.Center, 500f, realPlayerIds); foreach (var id in realPlayerIds) { MyVisualScriptLogicProvider.ShowNotification("Target hyper Achieved", 19200, "White", id); msgSent = true; } } } else if (WF_Scale < 0f) { hyperFactor = (hyperFactor * -1f); WF_Scale = hyperFactor; hyper = false; } } if (!hyper) { emitter.StopSound(false, true); if (WF_Scale <= 0f) { hyperFactor = 0f; WF_Scale = hyperFactor; HyperEngaged = false; } else if (WF_Scale > 0f) { hyperFactor = 0f; WF_Scale = hyperFactor; HyperEngaged = false; } } } } }
public static bool IsWorking() { return(HyperDriveLogic.hyperDriveBlock.IsFunctional && HyperDriveLogic.hyperDriveBlock.Enabled && ResourceSink.IsPowerAvailable(_electricity, MinimumPowertoActivate())); }