Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saltern updates & Medical Uniforms #348

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Content.Client/Weapons/Ranged/Systems/GunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Client.Weapons.Ranged.Components;
using Content.Shared.Camera;
using Content.Shared.CombatMode;
using Content.Shared.Mech.Components;
using Content.Shared.Weapons.Ranged;
using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Events;
Expand Down Expand Up @@ -141,6 +142,11 @@ public override void Update(float frameTime)

var entity = entityNull.Value;

if (TryComp<MechPilotComponent>(entity, out var mechPilot))
{
entity = mechPilot.Mech;
}

if (!TryGetGun(entity, out var gunUid, out var gun))
{
return;
Expand Down
1 change: 1 addition & 0 deletions Content.IntegrationTests/Tests/PostMapInitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public sealed class PostMapInitTest
"MeteorArena",
"NukieOutpost",
"Pebble", //DeltaV
"Saltern", //Syndicate Station
"Edge", //DeltaV
"Shoukou", //DeltaV
"Tortuga", //DeltaV
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
using Content.Server.Atmos.Components;
using Content.Shared.Atmos;
using Content.Shared.Audio;
using Content.Shared.Mobs.Components;
using Content.Shared.Physics;
using Robust.Shared.Audio;
using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Utility;

namespace Content.Server.Atmos.EntitySystems
Expand Down Expand Up @@ -51,8 +48,7 @@ private void UpdateHighPressure(float frameTime)
comp.Accumulator = 0f;
toRemove.Add(ent);

if (HasComp<MobStateComponent>(uid) &&
TryComp<PhysicsComponent>(uid, out var body))
if (TryComp<PhysicsComponent>(uid, out var body))
{
_physics.SetBodyStatus(body, BodyStatus.OnGround);
}
Expand All @@ -72,7 +68,7 @@ private void UpdateHighPressure(float frameTime)
}
}

private void AddMobMovedByPressure(EntityUid uid, MovedByPressureComponent component, PhysicsComponent body)
private void AddMovedByPressure(EntityUid uid, MovedByPressureComponent component, PhysicsComponent body)
{
if (!TryComp<FixturesComponent>(uid, out var fixtures))
return;
Expand Down Expand Up @@ -162,7 +158,7 @@ private void HighPressureMovements(Entity<GridAtmosphereComponent> gridAtmospher
(entity, pressureMovements),
gridAtmosphere.Comp.UpdateCounter,
tile.PressureDifference,
tile.PressureDirection, 0,
tile.PressureDirection,
tile.PressureSpecificTarget != null ? _mapSystem.ToCenterCoordinates(tile.GridIndex, tile.PressureSpecificTarget.GridIndices) : EntityCoordinates.Invalid,
gridWorldRotation,
xforms.GetComponent(entity),
Expand All @@ -183,12 +179,13 @@ private void ConsiderPressureDifference(GridAtmosphereComponent gridAtmosphere,
tile.PressureDirection = differenceDirection;
}

//The EE version of this function drops pressureResistanceProbDelta, since it's not needed. If you are for whatever reason calling this function
//And it isn't working, you've probably still got the ResistancePobDelta line included.
public void ExperiencePressureDifference(
Entity<MovedByPressureComponent> ent,
int cycle,
float pressureDifference,
AtmosDirection direction,
float pressureResistanceProbDelta,
EntityCoordinates throwTarget,
Angle gridWorldRotation,
TransformComponent? xform = null,
Expand All @@ -201,55 +198,34 @@ public void ExperiencePressureDifference(
if (!Resolve(uid, ref xform))
return;

// TODO ATMOS stuns?

var maxForce = MathF.Sqrt(pressureDifference) * 2.25f;
var moveProb = 100f;

if (component.PressureResistance > 0)
moveProb = MathF.Abs((pressureDifference / component.PressureResistance * MovedByPressureComponent.ProbabilityBasePercent) -
MovedByPressureComponent.ProbabilityOffset);

// Can we yeet the thing (due to probability, strength, etc.)
if (moveProb > MovedByPressureComponent.ProbabilityOffset && _robustRandom.Prob(MathF.Min(moveProb / 100f, 1f))
&& !float.IsPositiveInfinity(component.MoveResist)
&& (physics.BodyType != BodyType.Static
&& (maxForce >= (component.MoveResist * MovedByPressureComponent.MoveForcePushRatio)))
|| (physics.BodyType == BodyType.Static && (maxForce >= (component.MoveResist * MovedByPressureComponent.MoveForceForcePushRatio))))
if (physics.BodyType != BodyType.Static
&& !float.IsPositiveInfinity(component.MoveResist)
&& physics.Mass != 0)
{
if (HasComp<MobStateComponent>(uid))
{
AddMobMovedByPressure(uid, component, physics);
}
var moveForce = pressureDifference / physics.Mass;

if (maxForce > MovedByPressureComponent.ThrowForce)
if (moveForce > physics.Mass)
{
var moveForce = maxForce;
moveForce /= (throwTarget != EntityCoordinates.Invalid) ? SpaceWindPressureForceDivisorThrow : SpaceWindPressureForceDivisorPush;
moveForce *= MathHelper.Clamp(moveProb, 0, 100);

// Apply a sanity clamp to prevent being thrown through objects.
var maxSafeForceForObject = SpaceWindMaxVelocity * physics.Mass;
moveForce = MathF.Min(moveForce, maxSafeForceForObject);

AddMovedByPressure(uid, component, physics);
// Grid-rotation adjusted direction
var dirVec = (direction.ToAngle() + gridWorldRotation).ToWorldVec();
var maxSafeForceForObject = SpaceWindMaxVelocity * physics.Mass;

// TODO: Technically these directions won't be correct but uhh I'm just here for optimisations buddy not to fix my old bugs.
if (throwTarget != EntityCoordinates.Invalid)
{
var pos = ((throwTarget.ToMap(EntityManager).Position - xform.WorldPosition).Normalized() + dirVec).Normalized();
_physics.ApplyLinearImpulse(uid, pos * moveForce, body: physics);
_physics.ApplyLinearImpulse(uid, pos * Math.Clamp(moveForce, 0, maxSafeForceForObject), body: physics);
}
else
{
moveForce = MathF.Min(moveForce, SpaceWindMaxPushForce);
_physics.ApplyLinearImpulse(uid, dirVec * moveForce, body: physics);
_physics.ApplyLinearImpulse(uid, dirVec * Math.Clamp(moveForce, 0, maxSafeForceForObject), body: physics);
}

component.LastHighPressureMovementAirCycle = cycle;
}
}
}
}
}
}
6 changes: 6 additions & 0 deletions Content.Server/Atmos/EntitySystems/FlammableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Content.Shared.Damage;
using Content.Shared.Database;
using Content.Shared.Interaction;
using Content.Shared.Mech.Components;
using Content.Shared.Physics;
using Content.Shared.Popups;
using Content.Shared.Projectiles;
Expand Down Expand Up @@ -305,6 +306,11 @@ public void Ignite(EntityUid uid, EntityUid ignitionSource, FlammableComponent?
if (!Resolve(uid, ref flammable))
return;

// I would rather there be a cancellable event for this but I really don't wanna fuck with this janky system more than I have too.
// FlammableSystem rework when?
if (TryComp<MechPilotComponent>(uid, out var mechPilot) && TryComp<MechComponent>(mechPilot.Mech, out var mech) && mech.Airtight)
return;

if (flammable.AlwaysCombustible)
{
flammable.FireStacks = Math.Max(flammable.FirestacksOnIgnite, flammable.FireStacks);
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public void TrySendInGameOOCMessage(
/// <param name="colorOverride">Optional color for the announcement message</param>
public void DispatchGlobalAnnouncement(
string message,
string sender = "Central Command",
string sender = "High Command",
bool playSound = true,
SoundSpecifier? announcementSound = null,
Color? colorOverride = null
Expand All @@ -344,7 +344,7 @@ public void DispatchGlobalAnnouncement(
public void DispatchStationAnnouncement(
EntityUid source,
string message,
string sender = "Central Command",
string sender = "High Command",
bool playDefaultSound = true,
SoundSpecifier? announcementSound = null,
Color? colorOverride = null)
Expand Down
75 changes: 75 additions & 0 deletions Content.Server/Mech/Equipment/EntitySystems/MechGunSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using Content.Server.Mech.Systems;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Shared.Mech.Components;
using Content.Shared.Mech.Equipment.Components;
using Content.Shared.Throwing;
using Content.Shared.Weapons.Ranged.Systems;
using Robust.Shared.Random;

namespace Content.Server.Mech.Equipment.EntitySystems;
public sealed class MechGunSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly ThrowingSystem _throwing = default!;
[Dependency] private readonly MechSystem _mech = default!;
[Dependency] private readonly BatterySystem _battery = default!;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MechEquipmentComponent, GunShotEvent>(MechGunShot);
}

private void MechGunShot(EntityUid uid, MechEquipmentComponent component, ref GunShotEvent args)
{
if (!component.EquipmentOwner.HasValue)
return;

if (!TryComp<MechComponent>(component.EquipmentOwner.Value, out var mech))
return;

if (TryComp<BatteryComponent>(uid, out var battery))
{
ChargeGunBattery(uid, battery);
return;
}

// In most guns the ammo itself isn't shot but turned into cassings
// and a new projectile is spawned instead, meaning that args.Ammo
// is most likely inside the equipment container (for some odd reason)

// I'm not even sure why this is needed since GunSystem.Shoot() has a
// container check before ejecting, but yet it still puts the spent ammo inside the mech
foreach (var (ent, _) in args.Ammo)
{
if (ent.HasValue && mech.EquipmentContainer.Contains(ent.Value))
{
mech.EquipmentContainer.Remove(ent.Value);
_throwing.TryThrow(ent.Value, _random.NextVector2(), _random.Next(5));
}
}
}

private void ChargeGunBattery(EntityUid uid, BatteryComponent component)
{
if (!TryComp<MechEquipmentComponent>(uid, out var mechEquipment) || !mechEquipment.EquipmentOwner.HasValue)
return;

if (!TryComp<MechComponent>(mechEquipment.EquipmentOwner.Value, out var mech))
return;

var maxCharge = component.MaxCharge;
var currentCharge = component.CurrentCharge;

var chargeDelta = maxCharge - currentCharge;

if (chargeDelta <= 0 || mech.Energy - chargeDelta < 0)
return;

if (!_mech.TryChangeEnergy(mechEquipment.EquipmentOwner.Value, -chargeDelta, mech))
return;

_battery.SetCharge(uid, component.MaxCharge, component);
}
}
1 change: 1 addition & 0 deletions Content.Server/Mech/Systems/MechSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Mech.Components;
using Content.Server.Power.Components;
Expand Down
5 changes: 5 additions & 0 deletions Content.Server/Weapons/Ranged/Systems/GunSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Server.Administration.Logs;
using Content.Server.Cargo.Systems;
using Content.Server.Interaction;
using Content.Server.Mech.Equipment.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.Stunnable;
using Content.Server.Weapons.Ranged.Components;
Expand All @@ -11,6 +12,7 @@
using Content.Shared.Database;
using Content.Shared.Effects;
using Content.Shared.Interaction.Components;
using Content.Shared.Mech.Equipment.Components;
using Content.Shared.Projectiles;
using Content.Shared.Weapons.Melee;
using Content.Shared.Weapons.Ranged;
Expand Down Expand Up @@ -170,9 +172,12 @@ public override void Shoot(EntityUid gunUid, GunComponent gun, List<(EntityUid?

// Something like ballistic might want to leave it in the container still
if (!cartridge.DeleteOnSpawn && !Containers.IsEntityInContainer(ent!.Value))
{
EjectCartridge(ent.Value, angle);
}

Dirty(ent!.Value, cartridge);

break;
// Ammo shoots itself
case AmmoComponent newAmmo:
Expand Down
3 changes: 3 additions & 0 deletions Content.Shared/Mech/EntitySystems/SharedMechSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using Content.Shared.Movement.Systems;
using Content.Shared.Popups;
using Content.Shared.Weapons.Melee;
using Content.Shared.Weapons.Ranged.Events;
using Robust.Shared.Containers;
using Robust.Shared.Network;
using Robust.Shared.Serialization;
Expand Down Expand Up @@ -43,7 +44,9 @@ public override void Initialize()
{
SubscribeLocalEvent<MechComponent, MechToggleEquipmentEvent>(OnToggleEquipmentAction);
SubscribeLocalEvent<MechComponent, MechEjectPilotEvent>(OnEjectPilotEvent);

SubscribeLocalEvent<MechComponent, InteractNoHandEvent>(RelayInteractionEvent);

SubscribeLocalEvent<MechComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<MechComponent, DestructionEventArgs>(OnDestruction);
SubscribeLocalEvent<MechComponent, GetAdditionalAccessEvent>(OnGetAdditionalAccess);
Expand Down
Loading
Loading