diff --git a/Utility Mods/SCDefenseBlocks/Data/Scripts/OneFuckingFolderDeeper/FieldGenerator/FieldGenerator_Core.cs b/Utility Mods/SCDefenseBlocks/Data/Scripts/OneFuckingFolderDeeper/FieldGenerator/FieldGenerator_Core.cs index fa4f8d219..4a248ef40 100644 --- a/Utility Mods/SCDefenseBlocks/Data/Scripts/OneFuckingFolderDeeper/FieldGenerator/FieldGenerator_Core.cs +++ b/Utility Mods/SCDefenseBlocks/Data/Scripts/OneFuckingFolderDeeper/FieldGenerator/FieldGenerator_Core.cs @@ -29,6 +29,7 @@ public class FieldGenerator : MyGameLogicComponent, IMyEventProxy { private IMyCubeBlock Block; private readonly bool IsServer = MyAPIGateway.Session.IsServer; + private readonly bool IsDedicated = MyAPIGateway.Utilities.IsDedicated; public readonly Guid SettingsID = new Guid("7A7AC398-FAE3-44E5-ABD5-8AE49434DDF6"); private Generator_Settings Config = FieldGenerator_Config.Config; @@ -133,9 +134,10 @@ public override void UpdateOnceBeforeFrame() Stability.ValueChanged += Stability_ValueChanged; } - if (!IsServer) + if (!IsDedicated) { GridStopped.ValueChanged += OnGridStopValueChange; + Block.IsWorkingChanged += Block_IsWorkingChanged; } NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME; @@ -173,22 +175,17 @@ public override void UpdateAfterSimulation() } } - if (SiegeMode.Value && !GridStopped.Value) + if (!IsDedicated) { - if (!SlowdownActive.Value) + if (SiegeMode.Value && !GridStopped.Value && !SlowdownActive.Value && IsClientInShip()) { BlockSoundPair = new MySoundPair("FieldGen_Brake"); + BlockSoundEmitter.SetPosition(Block.Position); BlockSoundEmitter?.PlaySound(BlockSoundPair, false, false, true, true, false, null, true); SlowdownActive.Value = true; } } - if (_cachedState != Block.IsWorking) - { - _cachedState = Block.IsWorking; - Block_IsWorkingChanged(); - } - if (MyAPIGateway.Session.GameplayFrameCounter % 60 == 0) { if (Block.IsWorking) @@ -298,10 +295,11 @@ public override void Close() Stability.ValueChanged -= Stability_ValueChanged; } - if (!IsServer) + if (!IsDedicated) { GridStopped.ValueChanged -= OnGridStopValueChange; - } + Block.IsWorkingChanged -= Block_IsWorkingChanged; + } Block = null; } @@ -440,18 +438,25 @@ private void OnGridStopValueChange(MySync obj) Block.CubeGrid.Physics.LinearVelocity = Vector3.Zero; } - private void Block_IsWorkingChanged() - { - if (!Block.IsWorking) + private void Block_IsWorkingChanged(IMyCubeBlock block) + { + if (IsClientInShip()) { - BlockSoundPair = Block.IsFunctional ? BlockSoundPair = new MySoundPair("FieldGen_Offline") : BlockSoundPair = new MySoundPair("FieldGen_Damaged"); - BlockSoundEmitter?.PlaySound(BlockSoundPair, false, false, true, true, false, null, true); + if (!block.IsWorking) + { + BlockSoundPair = block.IsFunctional ? BlockSoundPair = new MySoundPair("FieldGen_Offline") : BlockSoundPair = new MySoundPair("FieldGen_Damaged"); + BlockSoundEmitter.SetPosition(Block.Position); + BlockSoundEmitter?.PlaySound(BlockSoundPair, false, false, true, true, false, null, true); + } + else + { + BlockSoundPair = block.SlimBlock.IsFullIntegrity ? BlockSoundPair = new MySoundPair("FieldGen_PowerRestored") : BlockSoundPair = new MySoundPair("FieldGen_DamagedRepaired"); + BlockSoundEmitter.SetPosition(block.Position); + BlockSoundEmitter?.PlaySound(BlockSoundPair, false, false, true, true, false, null, true); + } } else - { - BlockSoundPair = Block.SlimBlock.IsFullIntegrity ? BlockSoundPair = new MySoundPair("FieldGen_PowerRestored") : BlockSoundPair = new MySoundPair("FieldGen_DamagedRepaired"); - BlockSoundEmitter?.PlaySound(BlockSoundPair, false, false, true, true, false, null, true); - } + return; } #endregion @@ -526,32 +531,17 @@ private void SiegeEmergencyStop() if (Block.CubeGrid.Physics == null) return; + // Linear Drag float elapsed = _stopTickCounter / 60f; - float maxTime = 10f; - - float minForce = 1000000f; - float maxForce = 120000000f; - - float timeScale = MathHelper.Clamp(elapsed / maxTime, 0f, 1f); - float forceMagnitude = MathHelper.Lerp(minForce, maxForce, timeScale); + float timeScale = MathHelper.Clamp(elapsed / 10f, 0f, 1f); + float forceMagnitude = MathHelper.Lerp(1000000f, 120000000f, timeScale); Vector3 direction = Vector3.Normalize(Block.CubeGrid.Physics.LinearVelocity); Vector3 linearDrag = -direction * forceMagnitude; Block.CubeGrid.Physics.AddForce(MyPhysicsForceType.APPLY_WORLD_FORCE, linearDrag, null, null); - if (Block.CubeGrid.Physics.LinearVelocity.LengthSquared() < 25f || elapsed >= maxTime) // 5 m/s squared = 25 - { - Block.CubeGrid.Physics.LinearVelocity = Vector3D.Zero; - GridStopped.Value = true; - SlowdownActive.Value = false; - _stopTickCounter = -1; - angularAxis1 = null; - angularAxis2 = null; - return; - } - - // ----- ANGULAR DRAG ----- + // Angular Drag if (angularAxis1 == null) { angularAxis1 = GetRandomUnitVector(); @@ -566,15 +556,23 @@ private void SiegeEmergencyStop() angularAxis2 = candidate; } - float targetAngularAccel = 0.1f; - Vector3 torqueDirection = new Vector3(0,0,0); - + Vector3 torqueDirection = new Vector3(0, 0, 0); torqueDirection += angularAxis1.Value; torqueDirection += angularAxis2.Value; - Vector3 angularImpulse = torqueDirection * targetAngularAccel / 60f; + Block.CubeGrid.Physics.AngularVelocity += torqueDirection * 0.1f / 60f; - Block.CubeGrid.Physics.AngularVelocity += angularImpulse; + // Finish if under 5m/s + if (Block.CubeGrid.Physics.LinearVelocity.LengthSquared() < 25f || elapsed >= 10f) // 5 m/s squared = 25 + { + Block.CubeGrid.Physics.LinearVelocity = Vector3D.Zero; + GridStopped.Value = true; + SlowdownActive.Value = false; + _stopTickCounter = -1; + angularAxis1 = null; + angularAxis2 = null; + return; + } } Vector3 GetRandomUnitVector() @@ -731,11 +729,11 @@ public float CalculatePowerDraw() public float CheckPowerDraw(float fieldValue) { - float maxPossibleFieldPowerV = Config.PerModuleAmount * Config.MaxModuleCount; - float clampedFieldPowerV = MathHelper.Clamp(fieldValue, 0, maxPossibleFieldPowerV); - float tV = clampedFieldPowerV / maxPossibleFieldPowerV; + float maxPossibleFieldPower = Config.PerModuleAmount * Config.MaxModuleCount; + float clampedFieldPower = MathHelper.Clamp(fieldValue, 0, maxPossibleFieldPower); + float t = clampedFieldPower / maxPossibleFieldPower; - return Config.MinPowerDraw + tV * (Config.MaxPowerDraw - Config.MinPowerDraw); + return Config.MinPowerDraw + t * (Config.MaxPowerDraw - Config.MinPowerDraw); } public float CheckPowerGeneration() diff --git a/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin.mwm b/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin.mwm index ce8a808ec..f1e63db3f 100644 Binary files a/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin.mwm and b/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin.mwm differ diff --git a/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_BS1.mwm b/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_BS1.mwm new file mode 100644 index 000000000..6827f2cc6 Binary files /dev/null and b/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_BS1.mwm differ diff --git a/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_BS1_LOD1.mwm b/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_BS1_LOD1.mwm index e51e1fcd6..8a3a34aa1 100644 Binary files a/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_BS1_LOD1.mwm and b/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_BS1_LOD1.mwm differ diff --git a/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_BS2.mwm b/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_BS2.mwm new file mode 100644 index 000000000..12fd386a6 Binary files /dev/null and b/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_BS2.mwm differ diff --git a/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_BS3.mwm b/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_BS3.mwm new file mode 100644 index 000000000..d67cd727c Binary files /dev/null and b/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_BS3.mwm differ diff --git a/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_LOD1.mwm b/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_LOD1.mwm index 142b55a3f..6b515c9f2 100644 Binary files a/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_LOD1.mwm and b/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_LOD1.mwm differ diff --git a/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_LOD2.mwm b/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_LOD2.mwm index 95b41cc11..380387308 100644 Binary files a/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_LOD2.mwm and b/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_LOD2.mwm differ diff --git a/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_LOD3.mwm b/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_LOD3.mwm index 1bc83a779..f086148ab 100644 Binary files a/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_LOD3.mwm and b/Weapon Mods/Anomaly_Solaris_Hypernautics/Models/Starcore/muzzled_coil_odin_LOD3.mwm differ