Skip to content

Commit

Permalink
Merge pull request #536 from Rxup/upstream-sync
Browse files Browse the repository at this point in the history
Upstream sync
  • Loading branch information
Rxup authored Mar 26, 2024
2 parents 9bb03d9 + 7908c7b commit fdc76b5
Show file tree
Hide file tree
Showing 498 changed files with 1,525,881 additions and 1,508,125 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/check-crlf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: CRLF Check

on:
pull_request:
types: [ opened, reopened, synchronize, ready_for_review ]

jobs:
build:
name: CRLF Check
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Check for CRLF
run: Tools/check_crlf.py
2 changes: 1 addition & 1 deletion .github/workflows/close-master-pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Close PR's on master
name: Close PRs on master

on:
pull_request_target:
Expand Down
15 changes: 12 additions & 3 deletions Content.Client/Disposal/Systems/DisposalUnitSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem

private const string AnimationKey = "disposal_unit_animation";

private const string DefaultFlushState = "disposal-flush";
private const string DefaultChargeState = "disposal-charging";

public override void Initialize()
{
base.Initialize();
Expand Down Expand Up @@ -101,12 +104,18 @@ private void UpdateState(EntityUid uid, SharedDisposalUnitComponent unit, Sprite
sprite.LayerSetVisible(DisposalUnitVisualLayers.Base, state == VisualState.Anchored);
sprite.LayerSetVisible(DisposalUnitVisualLayers.BaseFlush, state is VisualState.Flushing or VisualState.Charging);

var chargingState = sprite.LayerMapTryGet(DisposalUnitVisualLayers.BaseCharging, out var chargingLayer)
? sprite.LayerGetState(chargingLayer)
: new RSI.StateId(DefaultChargeState);

// This is a transient state so not too worried about replaying in range.
if (state == VisualState.Flushing)
{
if (!_animationSystem.HasRunningAnimation(uid, AnimationKey))
{
var flushState = new RSI.StateId("disposal-flush");
var flushState = sprite.LayerMapTryGet(DisposalUnitVisualLayers.BaseFlush, out var flushLayer)
? sprite.LayerGetState(flushLayer)
: new RSI.StateId(DefaultFlushState);

// Setup the flush animation to play
var anim = new Animation
Expand All @@ -124,7 +133,7 @@ private void UpdateState(EntityUid uid, SharedDisposalUnitComponent unit, Sprite
// Return to base state (though, depending on how the unit is
// configured we might get an appearance change event telling
// us to go to charging state)
new AnimationTrackSpriteFlick.KeyFrame("disposal-charging", (float) unit.FlushDelay.TotalSeconds)
new AnimationTrackSpriteFlick.KeyFrame(chargingState, (float) unit.FlushDelay.TotalSeconds)
}
},
}
Expand All @@ -147,7 +156,7 @@ private void UpdateState(EntityUid uid, SharedDisposalUnitComponent unit, Sprite
}
else if (state == VisualState.Charging)
{
sprite.LayerSetState(DisposalUnitVisualLayers.BaseFlush, new RSI.StateId("disposal-charging"));
sprite.LayerSetState(DisposalUnitVisualLayers.BaseFlush, chargingState);
}
else
{
Expand Down
12 changes: 6 additions & 6 deletions Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ private void AddSmiteVerbs(GetVerbsEvent<Verb> args)
var fixtures = Comp<FixturesComponent>(args.Target);
xform.Anchored = false; // Just in case.
_physics.SetBodyType(args.Target, BodyType.Dynamic, manager: fixtures, body: physics);
_physics.SetBodyStatus(physics, BodyStatus.InAir);
_physics.SetBodyStatus(args.Target, physics, BodyStatus.InAir);
_physics.WakeBody(args.Target, manager: fixtures, body: physics);

foreach (var fixture in fixtures.Fixtures.Values)
Expand All @@ -424,8 +424,8 @@ private void AddSmiteVerbs(GetVerbsEvent<Verb> args)

_physics.SetLinearVelocity(args.Target, _random.NextVector2(1.5f, 1.5f), manager: fixtures, body: physics);
_physics.SetAngularVelocity(args.Target, MathF.PI * 12, manager: fixtures, body: physics);
_physics.SetLinearDamping(physics, 0f);
_physics.SetAngularDamping(physics, 0f);
_physics.SetLinearDamping(args.Target, physics, 0f);
_physics.SetAngularDamping(args.Target, physics, 0f);
},
Impact = LogImpact.Extreme,
Message = Loc.GetString("admin-smite-pinball-description")
Expand All @@ -444,7 +444,7 @@ private void AddSmiteVerbs(GetVerbsEvent<Verb> args)
xform.Anchored = false; // Just in case.

_physics.SetBodyType(args.Target, BodyType.Dynamic, body: physics);
_physics.SetBodyStatus(physics, BodyStatus.InAir);
_physics.SetBodyStatus(args.Target, physics, BodyStatus.InAir);
_physics.WakeBody(args.Target, manager: fixtures, body: physics);

foreach (var fixture in fixtures.Fixtures.Values)
Expand All @@ -454,8 +454,8 @@ private void AddSmiteVerbs(GetVerbsEvent<Verb> args)

_physics.SetLinearVelocity(args.Target, _random.NextVector2(8.0f, 8.0f), manager: fixtures, body: physics);
_physics.SetAngularVelocity(args.Target, MathF.PI * 12, manager: fixtures, body: physics);
_physics.SetLinearDamping(physics, 0f);
_physics.SetAngularDamping(physics, 0f);
_physics.SetLinearDamping(args.Target, physics, 0f);
_physics.SetAngularDamping(args.Target, physics, 0f);
},
Impact = LogImpact.Extreme,
Message = Loc.GetString("admin-smite-yeet-description")
Expand Down
16 changes: 14 additions & 2 deletions Content.Server/Administration/Systems/AdminVerbSystem.Tools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,21 @@ private void AddTricksVerbs(GetVerbsEvent<Verb> args)
Icon = new SpriteSpecifier.Rsi(new("/Textures/Objects/Fun/caps.rsi"), "mag-6"),
Act = () =>
{
_quickDialog.OpenDialog(player, "Set Bullet Amount", $"Amount (max {ballisticAmmo.Capacity}):", (int amount) =>
_quickDialog.OpenDialog(player, "Set Bullet Amount", $"Amount (standard {ballisticAmmo.Capacity}):", (string amount) =>
{
ballisticAmmo.UnspawnedCount = amount;
if (!int.TryParse(amount, out var result))
return;

if (result > 0)
{
ballisticAmmo.UnspawnedCount = result;
}
else
{
ballisticAmmo.UnspawnedCount = 0;
}

_gun.UpdateBallisticAppearance(args.Target, ballisticAmmo);
});
},
Impact = LogImpact.Medium,
Expand Down
32 changes: 29 additions & 3 deletions Content.Server/Atmos/Components/AirtightComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,53 @@ public sealed partial class AirtightComponent : Component
{
public (EntityUid Grid, Vector2i Tile) LastPosition { get; set; }

/// <summary>
/// The directions in which this entity should block airflow, relative to its own reference frame.
/// </summary>
[DataField("airBlockedDirection", customTypeSerializer: typeof(FlagSerializer<AtmosDirectionFlags>))]
public int InitialAirBlockedDirection { get; set; } = (int) AtmosDirection.All;

/// <summary>
/// The directions in which the entity is currently blocking airflow, relative to the grid that the entity is on.
/// I.e., this is a variant of <see cref="InitialAirBlockedDirection"/> that takes into account the entity's
/// current rotation.
/// </summary>
[ViewVariables]
public int CurrentAirBlockedDirection;

[DataField("airBlocked")]
/// <summary>
/// Whether the airtight entity is currently blocking airflow.
/// </summary>
[DataField]
public bool AirBlocked { get; set; } = true;

[DataField("fixVacuum")]
/// <summary>
/// If true, entities on this tile will attempt to draw air from surrounding tiles when they become unblocked
/// and currently have no air. This is generally only required when <see cref="NoAirWhenFullyAirBlocked"/> is
/// true, or if the entity is likely to occupy the same tile as another no-air airtight entity.
/// </summary>
[DataField]
public bool FixVacuum { get; set; } = true;
// I think fixvacuum exists to ensure that repeatedly closing/opening air-blocking doors doesn't end up
// depressurizing a room. However it can also effectively be used as a means of generating gasses for free
// TODO ATMOS Mass conservation. Make it actually push/pull air from adjacent tiles instead of destroying & creating,


// TODO ATMOS Do we need these two fields?
[DataField("rotateAirBlocked")]
public bool RotateAirBlocked { get; set; } = true;

// TODO ATMOS remove this? What is this even for??
[DataField("fixAirBlockedDirectionInitialize")]
public bool FixAirBlockedDirectionInitialize { get; set; } = true;

[DataField("noAirWhenFullyAirBlocked")]
/// <summary>
/// If true, then the tile that this entity is on will have no air at all if all directions are blocked.
/// </summary>
[DataField]
public bool NoAirWhenFullyAirBlocked { get; set; } = true;

/// <inheritdoc cref="CurrentAirBlockedDirection"/>
[Access(Other = AccessPermissions.ReadWriteExecute)]
public AtmosDirection AirBlockedDirection => (AtmosDirection)CurrentAirBlockedDirection;
}
Expand Down
2 changes: 0 additions & 2 deletions Content.Server/Atmos/EntitySystems/AirtightSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ private void OnAirtightMoved(Entity<AirtightComponent> airtight, ref MoveEvent e
private bool AirtightMove(Entity<AirtightComponent> ent, ref MoveEvent ev)
{
var (owner, airtight) = ent;
if (!airtight.RotateAirBlocked || airtight.InitialAirBlockedDirection == (int)AtmosDirection.Invalid)
return false;

airtight.CurrentAirBlockedDirection = (int) Rotate((AtmosDirection)airtight.InitialAirBlockedDirection, ev.NewRotation);
var pos = airtight.LastPosition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,7 @@ private void GridIsHotspotActive(EntityUid uid, GridAtmosphereComponent componen
args.Handled = true;
}

private void GridFixTileVacuum(
Entity<GridAtmosphereComponent, GasTileOverlayComponent, MapGridComponent, TransformComponent> ent,
TileAtmosphere tile,
float volume)
private void GridFixTileVacuum(TileAtmosphere tile)
{
DebugTools.AssertNotNull(tile.Air);
DebugTools.Assert(tile.Air?.Immutable == false );
Expand All @@ -416,6 +413,9 @@ private void GridFixTileVacuum(
count++;
}

if (count == 0)
return;

var ratio = 1f / count;
var totalTemperature = 0f;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private void UpdateHighPressure(float frameTime)
if (HasComp<MobStateComponent>(uid) &&
TryComp<PhysicsComponent>(uid, out var body))
{
_physics.SetBodyStatus(body, BodyStatus.OnGround);
_physics.SetBodyStatus(uid, body, BodyStatus.OnGround);
}

if (TryComp<FixturesComponent>(uid, out var fixtures))
Expand All @@ -75,7 +75,7 @@ private void AddMobMovedByPressure(EntityUid uid, MovedByPressureComponent compo
if (!TryComp<FixturesComponent>(uid, out var fixtures))
return;

_physics.SetBodyStatus(body, BodyStatus.InAir);
_physics.SetBodyStatus(uid, body, BodyStatus.InAir);

foreach (var (id, fixture) in fixtures.Fixtures)
{
Expand All @@ -94,9 +94,9 @@ private void HighPressureMovements(Entity<GridAtmosphereComponent> gridAtmospher
// TODO ATMOS finish this

// Don't play the space wind sound on tiles that are on fire...
if(tile.PressureDifference > 15 && !tile.Hotspot.Valid)
if (tile.PressureDifference > 15 && !tile.Hotspot.Valid)
{
if(_spaceWindSoundCooldown == 0 && !string.IsNullOrEmpty(SpaceWindSound))
if (_spaceWindSoundCooldown == 0 && !string.IsNullOrEmpty(SpaceWindSound))
{
var coordinates = _mapSystem.ToCenterCoordinates(tile.GridIndex, tile.GridIndices);
_audio.PlayPvs(SpaceWindSound, coordinates, AudioParams.Default.WithVariation(0.125f).WithVolume(MathHelper.Clamp(tile.PressureDifference / 10, 10, 100)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ private void UpdateTileAir(
tile.Air = new GasMixture(volume){Temperature = Atmospherics.T20C};

if (data.FixVacuum)
GridFixTileVacuum(ent, tile, volume);
GridFixTileVacuum(tile);
}

private void QueueRunTiles(
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Atmos/EntitySystems/AtmosphereSystem.Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,13 @@ private AirtightData GetAirtightData(EntityUid uid, MapGridComponent grid, Vecto
if (!_airtightQuery.TryGetComponent(ent, out var airtight))
continue;

fixVacuum |= airtight.FixVacuum;

if(!airtight.AirBlocked)
continue;

blockedDirs |= airtight.AirBlockedDirection;
noAirWhenBlocked |= airtight.NoAirWhenFullyAirBlocked;
fixVacuum |= airtight.FixVacuum;

if (blockedDirs == AtmosDirection.All && noAirWhenBlocked && fixVacuum)
break;
Expand Down
7 changes: 4 additions & 3 deletions Content.Server/Atmos/GasMixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public float Temperature
get => _temperature;
set
{
DebugTools.Assert(!float.IsNaN(_temperature));
if (Immutable) return;
_temperature = MathF.Min(MathF.Max(value, Atmospherics.TCMB), Atmospherics.Tmax);
DebugTools.Assert(!float.IsNaN(value));
if (!Immutable)
_temperature = MathF.Min(MathF.Max(value, Atmospherics.TCMB), Atmospherics.Tmax);
}
}

Expand All @@ -91,6 +91,7 @@ public GasMixture(float[] moles, float temp, float volume = Atmospherics.CellVol
if (volume < 0)
volume = 0;

DebugTools.Assert(!float.IsNaN(temp));
_temperature = temp;
Moles = moles;
Volume = volume;
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Atmos/TileAtmosphere.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public sealed class TileAtmosphere : IGasMixtureHolder
[ViewVariables]
public TileAtmosphere? PressureSpecificTarget { get; set; }

/// <summary>
/// This is either the pressure difference, or the quantity of moles transferred if monstermos is enabled.
/// </summary>
[ViewVariables]
public float PressureDifference { get; set; }

Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Chemistry/EntitySystems/VaporSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public void Start(Entity<VaporComponent> vapor, TransformComponent vaporXform, V
// Set Move
if (EntityManager.TryGetComponent(vapor, out PhysicsComponent? physics))
{
_physics.SetLinearDamping(physics, 0f);
_physics.SetAngularDamping(physics, 0f);
_physics.SetLinearDamping(vapor, physics, 0f);
_physics.SetAngularDamping(vapor, physics, 0f);

_throwing.TryThrow(vapor, dir, speed, user: user);

Expand Down
38 changes: 38 additions & 0 deletions Content.Server/DeviceNetwork/Systems/DeviceNetworkJammerSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Content.Server.DeviceNetwork.Components;
using Content.Shared.DeviceNetwork.Components;
using Robust.Server.GameObjects;

namespace Content.Server.DeviceNetwork.Systems;

public sealed class DeviceNetworkJammerSystem : EntitySystem
{
[Dependency] private TransformSystem _transform = default!;
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<TransformComponent, BeforePacketSentEvent>(BeforePacketSent);
}

private void BeforePacketSent(EntityUid uid, TransformComponent xform, BeforePacketSentEvent ev)
{
if (ev.Cancelled)
return;

var query = EntityQueryEnumerator<DeviceNetworkJammerComponent, TransformComponent>();

while (query.MoveNext(out _, out var jammerComp, out var jammerXform))
{
if (!jammerComp.JammableNetworks.Contains(ev.NetworkId))
continue;

if (jammerXform.Coordinates.InRange(EntityManager, _transform, ev.SenderTransform.Coordinates, jammerComp.Range)
|| jammerXform.Coordinates.InRange(EntityManager, _transform, xform.Coordinates, jammerComp.Range))
{
ev.Cancel();
return;
}
}
}

}
11 changes: 9 additions & 2 deletions Content.Server/DeviceNetwork/Systems/DeviceNetworkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,14 @@ private void SendToConnections(ReadOnlySpan<DeviceNetworkComponent> connections,

var xform = Transform(packet.Sender);

BeforePacketSentEvent beforeEv = new(packet.Sender, xform, _transformSystem.GetWorldPosition(xform));
var senderPos = _transformSystem.GetWorldPosition(xform);

foreach (var connection in connections)
{
if (connection.Owner == packet.Sender)
continue;

BeforePacketSentEvent beforeEv = new(packet.Sender, xform, senderPos, connection.NetIdEnum.ToString());
RaiseLocalEvent(connection.Owner, beforeEv, false);

if (!beforeEv.Cancelled)
Expand Down Expand Up @@ -386,11 +387,17 @@ public sealed class BeforePacketSentEvent : CancellableEntityEventArgs
/// </summary>
public readonly Vector2 SenderPosition;

public BeforePacketSentEvent(EntityUid sender, TransformComponent xform, Vector2 senderPosition)
/// <summary>
/// The network the packet will be sent to.
/// </summary>
public readonly string NetworkId;

public BeforePacketSentEvent(EntityUid sender, TransformComponent xform, Vector2 senderPosition, string networkId)
{
Sender = sender;
SenderTransform = xform;
SenderPosition = senderPosition;
NetworkId = networkId;
}
}

Expand Down
Loading

0 comments on commit fdc76b5

Please sign in to comment.