Skip to content

Commit

Permalink
Merge branch 'master' into sml-tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
VigersRay authored Jun 16, 2024
2 parents 5cf0ef0 + 7cb20da commit 4b94456
Show file tree
Hide file tree
Showing 58 changed files with 817 additions and 276 deletions.
2 changes: 1 addition & 1 deletion Content.Client/Power/APC/ApcVisualizerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public sealed partial class ApcVisualsComponent : Component
/// </summary>
[DataField("screenColors")]
[ViewVariables(VVAccess.ReadWrite)]
public Color[] ScreenColors = new Color[(byte)ApcChargeState.NumStates]{Color.FromHex("#d1332e"), Color.FromHex("#2e8ad1"), Color.FromHex("#3db83b"), Color.FromHex("#ffac1c")};
public Color[] ScreenColors = new Color[(byte)ApcChargeState.NumStates]{Color.FromHex("#d1332e"), Color.FromHex("#dcdc28"), Color.FromHex("#82ff4c"), Color.FromHex("#ffac1c")};

/// <summary>
/// The sprite state of the unlit overlay used for the APC screen when the APC has been emagged.
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Power/PowerMonitoringWindow.xaml.Widgets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ public PowerMonitoringButton()
{
HorizontalAlignment = HAlignment.Right,
Align = Label.AlignMode.Right,
SetWidth = 72f,
SetWidth = 80f,
Margin = new Thickness(10, 0, 0, 0),
ClipText = true,
};
Expand Down
4 changes: 3 additions & 1 deletion Content.Server/GameTicking/GameTicker.GamePreset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,9 @@ public bool OnGhostAttempt(EntityUid mindId, bool canReturnGlobal, bool viaComma
// (If the mob survives, that's a bug. Ghosting is kept regardless.)
var canReturn = canReturnGlobal && _mind.IsCharacterDeadPhysically(mind);

if (canReturnGlobal && TryComp(playerEntity, out MobStateComponent? mobState))
if (_configurationManager.GetCVar(CCVars.GhostKillCrit) &&
canReturnGlobal &&
TryComp(playerEntity, out MobStateComponent? mobState))
{
if (_mobState.IsCritical(playerEntity.Value, mobState))
{
Expand Down
13 changes: 0 additions & 13 deletions Content.Server/Movement/Components/PullMoverComponent.cs

This file was deleted.

30 changes: 8 additions & 22 deletions Content.Server/Movement/Systems/PullController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Robust.Shared.Physics.Dynamics.Joints;
using Robust.Shared.Player;
using Robust.Shared.Timing;
using Robust.Shared.Utility;

namespace Content.Server.Movement.Systems;

Expand Down Expand Up @@ -91,7 +92,7 @@ public override void Initialize()

UpdatesAfter.Add(typeof(MoverController));
SubscribeLocalEvent<PullMovingComponent, PullStoppedMessage>(OnPullStop);
SubscribeLocalEvent<PullMoverComponent, MoveEvent>(OnPullerMove);
SubscribeLocalEvent<ActivePullerComponent, MoveEvent>(OnPullerMove);

base.Initialize();
}
Expand Down Expand Up @@ -155,19 +156,22 @@ private bool OnRequestMovePulledObject(ICommonSession? session, EntityCoordinate
coords = fromUserCoords.WithEntityId(coords.EntityId);
}

EnsureComp<PullMoverComponent>(player);
var moving = EnsureComp<PullMovingComponent>(pulled!.Value);
moving.MovingTo = coords;
return false;
}

private void OnPullerMove(EntityUid uid, PullMoverComponent component, ref MoveEvent args)
private void OnPullerMove(EntityUid uid, ActivePullerComponent component, ref MoveEvent args)
{
if (!_pullerQuery.TryComp(uid, out var puller))
return;

if (puller.Pulling is not { } pullable)
{
DebugTools.Assert($"Failed to clean up puller: {ToPrettyString(uid)}");
RemCompDeferred(uid, component);
return;
}

UpdatePulledRotation(uid, pullable);

Expand All @@ -182,13 +186,7 @@ private void OnPullerMove(EntityUid uid, PullMoverComponent component, ref MoveE
if (_physicsQuery.TryComp(uid, out var physics))
PhysicsSystem.WakeBody(uid, body: physics);

StopMove(uid, pullable);
}

private void StopMove(Entity<PullMoverComponent?> mover, Entity<PullMovingComponent?> moving)
{
RemCompDeferred<PullMoverComponent>(mover.Owner);
RemCompDeferred<PullMovingComponent>(moving.Owner);
RemCompDeferred<PullMovingComponent>(pullable);
}

private void UpdatePulledRotation(EntityUid puller, EntityUid pulled)
Expand Down Expand Up @@ -302,17 +300,5 @@ public override void UpdateBeforeSolve(bool prediction, float frameTime)
PhysicsSystem.ApplyLinearImpulse(puller, -impulse);
}
}

// Cleanup PullMover
var moverQuery = EntityQueryEnumerator<PullMoverComponent, PullerComponent>();

while (moverQuery.MoveNext(out var uid, out _, out var puller))
{
if (!HasComp<PullMovingComponent>(puller.Pulling))
{
RemCompDeferred<PullMoverComponent>(uid);
continue;
}
}
}
}
12 changes: 5 additions & 7 deletions Content.Server/Silicons/Borgs/BorgSystem.Modules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,13 @@ public bool CanInsertModule(EntityUid uid, EntityUid module, BorgChassisComponen
if (!TryComp<ItemBorgModuleComponent>(containedModuleUid, out var containedItemModuleComp))
continue;

for (int i = 0; i < itemModuleComp.Items.Count; i++)
if (containedItemModuleComp.Items.Count == itemModuleComp.Items.Count &&
containedItemModuleComp.Items.All(itemModuleComp.Items.Contains))
{
if (itemModuleComp.Items[i] != containedItemModuleComp.Items[i])
continue;
if (user != null)
Popup.PopupEntity(Loc.GetString("borg-module-duplicate"), uid, user.Value);
return false;
}

if (user != null)
Popup.PopupEntity(Loc.GetString("borg-module-duplicate"), uid, user.Value);
return false;
}
}

Expand Down
6 changes: 6 additions & 0 deletions Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,12 @@ public static readonly CVarDef<string>
public static readonly CVarDef<float> GhostRoleTime =
CVarDef.Create("ghost.role_time", 3f, CVar.REPLICATED | CVar.SERVER);

/// <summary>
/// Whether or not to kill the player's mob on ghosting, when it is in a critical health state.
/// </summary>
public static readonly CVarDef<bool> GhostKillCrit =
CVarDef.Create("ghost.kill_crit", true, CVar.REPLICATED | CVar.SERVER);

/*
* Fire alarm
*/
Expand Down
27 changes: 27 additions & 0 deletions Content.Shared/Clothing/Components/FactionClothingComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Content.Shared.Clothing.EntitySystems;
using Content.Shared.NPC.Prototypes;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;

namespace Content.Shared.Clothing.Components;

/// <summary>
/// When equipped, adds the wearer to a faction.
/// When removed, removes the wearer from a faction.
/// </summary>
[RegisterComponent, NetworkedComponent, Access(typeof(FactionClothingSystem))]
public sealed partial class FactionClothingComponent : Component
{
/// <summary>
/// Faction to add and remove.
/// </summary>
[DataField(required: true)]
public ProtoId<NpcFactionPrototype> Faction = string.Empty;

/// <summary>
/// If true, the wearer was already part of the faction.
/// This prevents wrongly removing them after removing the item.
/// </summary>
[DataField]
public bool AlreadyMember;
}
42 changes: 42 additions & 0 deletions Content.Shared/Clothing/EntitySystems/FactionClothingSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Content.Shared.Clothing.Components;
using Content.Shared.Inventory.Events;
using Content.Shared.NPC.Components;
using Content.Shared.NPC.Systems;

namespace Content.Shared.Clothing.EntitySystems;

/// <summary>
/// Handles <see cref="FactionClothingComponent"/> faction adding and removal.
/// </summary>
public sealed class FactionClothingSystem : EntitySystem
{
[Dependency] private readonly NpcFactionSystem _faction = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<FactionClothingComponent, GotEquippedEvent>(OnEquipped);
SubscribeLocalEvent<FactionClothingComponent, GotUnequippedEvent>(OnUnequipped);
}

private void OnEquipped(Entity<FactionClothingComponent> ent, ref GotEquippedEvent args)
{
TryComp<NpcFactionMemberComponent>(args.Equipee, out var factionComp);
var faction = (args.Equipee, factionComp);
ent.Comp.AlreadyMember = _faction.IsMember(faction, ent.Comp.Faction);

_faction.AddFaction(faction, ent.Comp.Faction);
}

private void OnUnequipped(Entity<FactionClothingComponent> ent, ref GotUnequippedEvent args)
{
if (ent.Comp.AlreadyMember)
{
ent.Comp.AlreadyMember = false;
return;
}

_faction.RemoveFaction(args.Equipee, ent.Comp.Faction);
}
}
6 changes: 6 additions & 0 deletions Content.Shared/Clothing/MagbootsComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,10 @@ public sealed partial class MagbootsComponent : Component

[DataField]
public ProtoId<AlertPrototype> MagbootsAlert = "Magboots";

/// <summary>
/// If true, the user must be standing on a grid or planet map to experience the weightlessness-canceling effect
/// </summary>
[DataField]
public bool RequiresGrid = true;
}
5 changes: 5 additions & 0 deletions Content.Shared/Clothing/SharedMagbootsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public sealed class SharedMagbootsSystem : EntitySystem
[Dependency] private readonly AlertsSystem _alerts = default!;
[Dependency] private readonly ClothingSpeedModifierSystem _clothingSpeedModifier = default!;
[Dependency] private readonly ClothingSystem _clothing = default!;
[Dependency] private readonly SharedGravitySystem _gravity = default!;
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly SharedActionsSystem _sharedActions = default!;
[Dependency] private readonly SharedActionsSystem _actionContainer = default!;
Expand Down Expand Up @@ -147,6 +148,10 @@ private void OnIsWeightless(Entity<MagbootsComponent> ent, ref InventoryRelayedE
if (!ent.Comp.On)
return;

// do not cancel weightlessness if the person is in off-grid.
if (ent.Comp.RequiresGrid && !_gravity.EntityOnGravitySupportingGridOrMap(ent.Owner))
return;

args.Args.IsWeightless = false;
args.Args.Handled = true;
}
Expand Down
32 changes: 28 additions & 4 deletions Content.Shared/Gravity/SharedGravitySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public abstract partial class SharedGravitySystem : EntitySystem
[ValidatePrototypeId<AlertPrototype>]
public const string WeightlessAlert = "Weightless";

private EntityQuery<GravityComponent> _gravityQuery;

public bool IsWeightless(EntityUid uid, PhysicsComponent? body = null, TransformComponent? xform = null)
{
Resolve(uid, ref body, false);
Expand All @@ -36,15 +38,35 @@ public bool IsWeightless(EntityUid uid, PhysicsComponent? body = null, Transform
return true;

// If grid / map has gravity
if (TryComp<GravityComponent>(xform.GridUid, out var gravity) && gravity.Enabled ||
TryComp<GravityComponent>(xform.MapUid, out var mapGravity) && mapGravity.Enabled)
{
if (EntityGridOrMapHaveGravity((uid, xform)))
return false;
}

return true;
}

/// <summary>
/// Checks if a given entity is currently standing on a grid or map that supports having gravity at all.
/// </summary>
public bool EntityOnGravitySupportingGridOrMap(Entity<TransformComponent?> entity)
{
entity.Comp ??= Transform(entity);

return _gravityQuery.HasComp(entity.Comp.GridUid) ||
_gravityQuery.HasComp(entity.Comp.MapUid);
}


/// <summary>
/// Checks if a given entity is currently standing on a grid or map that has gravity of some kind.
/// </summary>
public bool EntityGridOrMapHaveGravity(Entity<TransformComponent?> entity)
{
entity.Comp ??= Transform(entity);

return _gravityQuery.TryComp(entity.Comp.GridUid, out var gravity) && gravity.Enabled ||
_gravityQuery.TryComp(entity.Comp.MapUid, out var mapGravity) && mapGravity.Enabled;
}

public override void Initialize()
{
base.Initialize();
Expand All @@ -54,6 +76,8 @@ public override void Initialize()
SubscribeLocalEvent<GravityChangedEvent>(OnGravityChange);
SubscribeLocalEvent<GravityComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<GravityComponent, ComponentHandleState>(OnHandleState);

_gravityQuery = GetEntityQuery<GravityComponent>();
}

public override void Update(float frameTime)
Expand Down
7 changes: 4 additions & 3 deletions Content.Shared/Mobs/Systems/MobStateSystem.StateMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public partial class MobStateSystem
/// <returns>If the entity can be set to that MobState</returns>
public bool HasState(EntityUid entity, MobState mobState, MobStateComponent? component = null)
{
return Resolve(entity, ref component, false) && component.AllowedStates.Contains(mobState);
return _mobStateQuery.Resolve(entity, ref component, false) &&
component.AllowedStates.Contains(mobState);
}

/// <summary>
Expand All @@ -27,7 +28,7 @@ public bool HasState(EntityUid entity, MobState mobState, MobStateComponent? com
/// <param name="origin">Entity that caused the state update (if applicable)</param>
public void UpdateMobState(EntityUid entity, MobStateComponent? component = null, EntityUid? origin = null)
{
if (!Resolve(entity, ref component))
if (!_mobStateQuery.Resolve(entity, ref component))
return;

var ev = new UpdateMobStateEvent {Target = entity, Component = component, Origin = origin};
Expand All @@ -46,7 +47,7 @@ public void UpdateMobState(EntityUid entity, MobStateComponent? component = null
public void ChangeMobState(EntityUid entity, MobState mobState, MobStateComponent? component = null,
EntityUid? origin = null)
{
if (!Resolve(entity, ref component))
if (!_mobStateQuery.Resolve(entity, ref component))
return;

ChangeState(entity, component, mobState, origin: origin);
Expand Down
Loading

0 comments on commit 4b94456

Please sign in to comment.