Skip to content

Commit 6d9d3ef

Browse files
Staging Stable Release (space-wizards#43265)
2 parents 9c28c19 + 4495128 commit 6d9d3ef

300 files changed

Lines changed: 17003 additions & 13869 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Content.Client/Atmos/EntitySystems/AtmosDebugOverlaySystem.cs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ namespace Content.Client.Atmos.EntitySystems
1010
[UsedImplicitly]
1111
internal sealed class AtmosDebugOverlaySystem : SharedAtmosDebugOverlaySystem
1212
{
13-
public readonly Dictionary<EntityUid, AtmosDebugOverlayMessage> TileData = new();
13+
[Dependency] private readonly IOverlayManager _overlayManager = default!;
14+
15+
public readonly Dictionary<EntityUid, AtmosDebugOverlayMessage> TileData = [];
1416

1517
// Configuration set by debug commands and used by AtmosDebugOverlay {
1618
/// <summary>Value source for display</summary>
@@ -25,6 +27,8 @@ internal sealed class AtmosDebugOverlaySystem : SharedAtmosDebugOverlaySystem
2527
public bool CfgCBM = false;
2628
// }
2729

30+
private AtmosDebugOverlay? _overlay;
31+
2832
public override void Initialize()
2933
{
3034
base.Initialize();
@@ -34,10 +38,6 @@ public override void Initialize()
3438
SubscribeNetworkEvent<AtmosDebugOverlayDisableMessage>(HandleAtmosDebugOverlayDisableMessage);
3539

3640
SubscribeLocalEvent<GridRemovalEvent>(OnGridRemoved);
37-
38-
var overlayManager = IoCManager.Resolve<IOverlayManager>();
39-
if(!overlayManager.HasOverlay<AtmosDebugOverlay>())
40-
overlayManager.AddOverlay(new AtmosDebugOverlay(this));
4141
}
4242

4343
private void OnGridRemoved(GridRemovalEvent ev)
@@ -51,19 +51,25 @@ private void OnGridRemoved(GridRemovalEvent ev)
5151
private void HandleAtmosDebugOverlayMessage(AtmosDebugOverlayMessage message)
5252
{
5353
TileData[GetEntity(message.GridId)] = message;
54+
55+
if (_overlay is not null)
56+
return;
57+
58+
_overlay = new AtmosDebugOverlay(this);
59+
_overlayManager.AddOverlay(_overlay);
5460
}
5561

5662
private void HandleAtmosDebugOverlayDisableMessage(AtmosDebugOverlayDisableMessage ev)
5763
{
5864
TileData.Clear();
65+
RemoveOverlay();
5966
}
6067

6168
public override void Shutdown()
6269
{
6370
base.Shutdown();
64-
var overlayManager = IoCManager.Resolve<IOverlayManager>();
65-
if (overlayManager.HasOverlay<AtmosDebugOverlay>())
66-
overlayManager.RemoveOverlay<AtmosDebugOverlay>();
71+
72+
RemoveOverlay();
6773
}
6874

6975
public void Reset(RoundRestartCleanupEvent ev)
@@ -75,6 +81,15 @@ public bool HasData(EntityUid gridId)
7581
{
7682
return TileData.ContainsKey(gridId);
7783
}
84+
85+
private void RemoveOverlay()
86+
{
87+
if (_overlay is null)
88+
return;
89+
90+
_overlayManager.RemoveOverlay(_overlay);
91+
_overlay = null;
92+
}
7893
}
7994

8095
internal enum AtmosDebugOverlayMode : byte

Content.Client/Atmos/EntitySystems/AtmosphereSystem.Gases.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,20 @@ code that would escape sandbox. As such these methods are overridden here with a
1313
implementation.
1414
*/
1515

16+
public override bool IsMixtureFuel(GasMixture mixture, float epsilon = Atmospherics.Epsilon)
17+
{
18+
var tmp = new float[Atmospherics.AdjustedNumberOfGases];
19+
NumericsHelpers.Multiply(mixture.Moles, GasFuelMask, tmp);
20+
return NumericsHelpers.HorizontalAdd(tmp) > epsilon;
21+
}
22+
23+
public override bool IsMixtureOxidizer(GasMixture mixture, float epsilon = Atmospherics.Epsilon)
24+
{
25+
var tmp = new float[Atmospherics.AdjustedNumberOfGases];
26+
NumericsHelpers.Multiply(mixture.Moles, GasOxidizerMask, tmp);
27+
return NumericsHelpers.HorizontalAdd(tmp) > epsilon;
28+
}
29+
1630
[MethodImpl(MethodImplOptions.AggressiveInlining)]
1731
protected override float GetHeatCapacityCalculation(float[] moles, bool space)
1832
{
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Linq;
22
using Content.Shared.BarSign;
33
using JetBrains.Annotations;
4+
using Robust.Client.UserInterface;
45
using Robust.Shared.Prototypes;
56

67
namespace Content.Client.BarSign.Ui;
@@ -16,30 +17,30 @@ protected override void Open()
1617
{
1718
base.Open();
1819

19-
var sign = EntMan.GetComponentOrNull<BarSignComponent>(Owner)?.Current is { } current
20-
? _prototype.Index(current)
21-
: null;
2220
var allSigns = BarSignSystem.GetAllBarSigns(_prototype)
2321
.OrderBy(p => Loc.GetString(p.Name))
2422
.ToList();
25-
_menu = new(sign, allSigns);
23+
24+
_menu = this.CreateWindow<BarSignMenu>();
25+
_menu.LoadSigns(allSigns);
2626

2727
_menu.OnSignSelected += id =>
2828
{
2929
SendPredictedMessage(new SetBarSignMessage(id));
3030
};
3131

3232
_menu.OnClose += Close;
33-
_menu.OpenCentered();
33+
_menu.OpenToLeft();
3434
}
3535

3636
public override void Update()
3737
{
38-
if (!EntMan.TryGetComponent<BarSignComponent>(Owner, out var signComp))
38+
if (!EntMan.TryGetComponent<BarSignComponent>(Owner, out var signComp)
39+
|| !_prototype.Resolve(signComp.Current, out var signPrototype))
3940
return;
4041

41-
if (_prototype.Resolve(signComp.Current, out var signPrototype))
42-
_menu?.UpdateState(signPrototype);
42+
_menu?.UpdateState(signPrototype);
4343
}
44+
4445
}
4546

Content.Client/BarSign/Ui/BarSignMenu.xaml.cs

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,42 +8,35 @@ namespace Content.Client.BarSign.Ui;
88
[GenerateTypedNameReferences]
99
public sealed partial class BarSignMenu : FancyWindow
1010
{
11-
private string? _currentId;
12-
13-
private readonly List<BarSignPrototype> _cachedPrototypes = new();
11+
private List<BarSignPrototype> _cachedPrototypes = new();
1412

1513
public event Action<string>? OnSignSelected;
1614

17-
public BarSignMenu(BarSignPrototype? currentSign, List<BarSignPrototype> signs)
15+
public BarSignMenu()
1816
{
1917
RobustXamlLoader.Load(this);
20-
_currentId = currentSign?.ID;
21-
22-
_cachedPrototypes.Clear();
23-
_cachedPrototypes = signs;
24-
foreach (var proto in _cachedPrototypes)
25-
{
26-
SignOptions.AddItem(Loc.GetString(proto.Name));
27-
}
2818

2919
SignOptions.OnItemSelected += idx =>
3020
{
3121
OnSignSelected?.Invoke(_cachedPrototypes[idx.Id].ID);
3222
SignOptions.SelectId(idx.Id);
3323
};
3424

35-
if (currentSign != null)
25+
}
26+
27+
public void LoadSigns(List<BarSignPrototype> signs)
28+
{
29+
_cachedPrototypes.Clear();
30+
_cachedPrototypes = signs;
31+
32+
foreach (var proto in _cachedPrototypes)
3633
{
37-
var idx = _cachedPrototypes.IndexOf(currentSign);
38-
SignOptions.TrySelectId(idx);
34+
SignOptions.AddItem(Loc.GetString(proto.Name));
3935
}
4036
}
4137

4238
public void UpdateState(BarSignPrototype newSign)
4339
{
44-
if (_currentId != null && newSign.ID == _currentId)
45-
return;
46-
_currentId = newSign.ID;
4740
var idx = _cachedPrototypes.IndexOf(newSign);
4841
SignOptions.TrySelectId(idx);
4942
}

Content.Client/CombatMode/CombatModeSystem.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Content.Client.Hands.Systems;
2-
using Content.Client.NPC.HTN;
32
using Content.Shared.CCVar;
43
using Content.Shared.CombatMode;
54
using Robust.Client.Graphics;
@@ -59,11 +58,6 @@ public override void SetInCombatMode(EntityUid entity, bool value, CombatModeCom
5958
UpdateHud(entity);
6059
}
6160

62-
protected override bool IsNpc(EntityUid uid)
63-
{
64-
return HasComp<HTNComponent>(uid);
65-
}
66-
6761
private void UpdateHud(EntityUid entity)
6862
{
6963
if (entity != _playerManager.LocalEntity || !Timing.IsFirstTimePredicted)

Content.Client/Damage/DamageVisualsComponent.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
using Content.Shared.Damage.Prototypes;
12
using Content.Shared.FixedPoint;
3+
using Robust.Shared.Prototypes;
24

35
namespace Content.Client.Damage;
46

@@ -55,7 +57,7 @@ public sealed partial class DamageVisualsComponent : Component
5557
/// (for example, Brute), and has a value
5658
/// of a DamageVisualizerSprite (see below)
5759
/// </summary>
58-
[DataField("damageOverlayGroups")] public Dictionary<string, DamageVisualizerSprite>? DamageOverlayGroups;
60+
[DataField("damageOverlayGroups")] public Dictionary<ProtoId<DamageGroupPrototype>, DamageVisualizerSprite>? DamageOverlayGroups;
5961

6062
/// <summary>
6163
/// Sets if you want sprites to overlay the
@@ -84,7 +86,7 @@ public sealed partial class DamageVisualsComponent : Component
8486
/// what kind of damage combination
8587
/// you would want, on which threshold.
8688
/// </remarks>
87-
[DataField("damageGroup")] public string? DamageGroup;
89+
[DataField("damageGroup")] public ProtoId<DamageGroupPrototype>? DamageGroup;
8890

8991
/// <summary>
9092
/// Set this if you want incoming damage to be

Content.Client/Damage/DamageVisualsSystem.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Content.Shared.Damage;
33
using Content.Shared.Damage.Components;
44
using Content.Shared.Damage.Prototypes;
5+
using Content.Shared.Damage.Systems;
56
using Content.Shared.FixedPoint;
67
using Robust.Client.GameObjects;
78
using Robust.Shared.Prototypes;
@@ -28,6 +29,7 @@ namespace Content.Client.Damage;
2829
public sealed class DamageVisualsSystem : VisualizerSystem<DamageVisualsComponent>
2930
{
3031
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
32+
[Dependency] private readonly DamageableSystem _damageable = default!;
3133

3234
public override void Initialize()
3335
{
@@ -174,7 +176,7 @@ private void InitializeVisualizer(EntityUid entity, DamageVisualsComponent damag
174176
// See if that group is in our entity's damage container.
175177
else if (!damageVisComp.Overlay && damageVisComp.DamageGroup != null)
176178
{
177-
if (!damageContainer.SupportedGroups.Contains(damageVisComp.DamageGroup))
179+
if (!damageContainer.SupportedGroups.Contains(damageVisComp.DamageGroup.Value))
178180
{
179181
Log.Error($"Damage keys were invalid for entity {entity}.");
180182
damageVisComp.Valid = false;
@@ -384,7 +386,7 @@ private void HandleDamage(EntityUid uid, AppearanceComponent component, DamageVi
384386
if (!AppearanceSystem.TryGetData<DamageVisualizerGroupData>(uid, DamageVisualizerKeys.DamageUpdateGroups,
385387
out var data, component))
386388
{
387-
data = new DamageVisualizerGroupData(Comp<DamageableComponent>(uid).DamagePerGroup.Keys.ToList());
389+
data = new DamageVisualizerGroupData(_damageable.GetDamagePerGroup(uid).Keys.ToList());
388390
}
389391

390392
UpdateDamageVisuals(data.GroupList, (uid, damageComponent, spriteComponent, damageVisComp));
@@ -486,11 +488,10 @@ private void ReorderOverlaySprite(Entity<SpriteComponent> spriteEnt, DamageVisua
486488
/// </summary>
487489
private void UpdateDamageVisuals(Entity<DamageableComponent, SpriteComponent, DamageVisualsComponent> entity)
488490
{
489-
var damageComponent = entity.Comp1;
490491
var spriteComponent = entity.Comp2;
491492
var damageVisComp = entity.Comp3;
492493

493-
if (!CheckThresholdBoundary(damageComponent.TotalDamage, damageVisComp.LastDamageThreshold, damageVisComp, out var threshold))
494+
if (!CheckThresholdBoundary(_damageable.GetTotalDamage(entity.AsNullable()), damageVisComp.LastDamageThreshold, damageVisComp, out var threshold))
494495
return;
495496

496497
damageVisComp.LastDamageThreshold = threshold;
@@ -513,19 +514,19 @@ private void UpdateDamageVisuals(Entity<DamageableComponent, SpriteComponent, Da
513514
/// according to the list of damage groups
514515
/// passed into it.
515516
/// </summary>
516-
private void UpdateDamageVisuals(List<string> delta, Entity<DamageableComponent, SpriteComponent, DamageVisualsComponent> entity)
517+
private void UpdateDamageVisuals(List<ProtoId<DamageGroupPrototype>> delta, Entity<DamageableComponent, SpriteComponent, DamageVisualsComponent> entity)
517518
{
518-
var damageComponent = entity.Comp1;
519519
var spriteComponent = entity.Comp2;
520520
var damageVisComp = entity.Comp3;
521+
var damage = _damageable.GetAllDamage((entity.Owner, entity.Comp1));
521522

522523
foreach (var damageGroup in delta)
523524
{
524525
if (!damageVisComp.Overlay && damageGroup != damageVisComp.DamageGroup)
525526
continue;
526527

527528
if (!_prototypeManager.TryIndex<DamageGroupPrototype>(damageGroup, out var damageGroupPrototype)
528-
|| !damageComponent.Damage.TryGetDamageInGroup(damageGroupPrototype, out var damageTotal))
529+
|| !damage.TryGetDamageInGroup(damageGroupPrototype, out var damageTotal))
529530
continue;
530531

531532
if (!damageVisComp.LastThresholdPerGroup.TryGetValue(damageGroup, out var lastThreshold)
@@ -590,7 +591,7 @@ private void ForceUpdateLayers(Entity<DamageableComponent, SpriteComponent, Dama
590591
}
591592
else if (damageVisComp.DamageGroup != null)
592593
{
593-
UpdateDamageVisuals(new List<string>() { damageVisComp.DamageGroup }, entity);
594+
UpdateDamageVisuals(new() { damageVisComp.DamageGroup.Value }, entity);
594595
}
595596
else if (damageVisComp.DamageOverlay != null)
596597
{

Content.Client/HealthAnalyzer/UI/HealthAnalyzerControl.xaml.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Content.Shared.Atmos;
44
using Content.Shared.Damage.Components;
55
using Content.Shared.Damage.Prototypes;
6+
using Content.Shared.Damage.Systems;
67
using Content.Shared.FixedPoint;
78
using Content.Shared.Humanoid;
89
using Content.Shared.Humanoid.Prototypes;
@@ -30,6 +31,7 @@ public sealed partial class HealthAnalyzerControl : BoxContainer
3031
private readonly SpriteSystem _spriteSystem;
3132
private readonly IPrototypeManager _prototypes;
3233
private readonly IResourceCache _cache;
34+
private readonly DamageableSystem _damageable;
3335

3436
public HealthAnalyzerControl()
3537
{
@@ -40,6 +42,7 @@ public HealthAnalyzerControl()
4042
_spriteSystem = _entityManager.System<SpriteSystem>();
4143
_prototypes = dependencies.Resolve<IPrototypeManager>();
4244
_cache = dependencies.Resolve<IResourceCache>();
45+
_damageable = _entityManager.System<DamageableSystem>();
4346
}
4447

4548
public void Populate(HealthAnalyzerUiState state)
@@ -101,7 +104,7 @@ public void Populate(HealthAnalyzerUiState state)
101104

102105
// Total Damage
103106

104-
DamageLabel.Text = damageable.TotalDamage.ToString();
107+
DamageLabel.Text = _damageable.GetTotalDamage(target.Value).ToString();
105108

106109
// Alerts
107110

@@ -132,10 +135,11 @@ public void Populate(HealthAnalyzerUiState state)
132135
// Damage Groups
133136

134137
var damageSortedGroups =
135-
damageable.DamagePerGroup.OrderByDescending(damage => damage.Value)
138+
_damageable.GetDamagePerGroup(target.Value)
139+
.OrderByDescending(damage => damage.Value)
136140
.ToDictionary(x => x.Key, x => x.Value);
137141

138-
IReadOnlyDictionary<string, FixedPoint2> damagePerType = damageable.Damage.DamageDict;
142+
var damagePerType = _damageable.GetAllDamage(target.Value).DamageDict;
139143

140144
DrawDiagnosticGroups(damageSortedGroups, damagePerType);
141145
}
@@ -152,8 +156,8 @@ private static string GetStatus(MobState mobState)
152156
}
153157

154158
private void DrawDiagnosticGroups(
155-
Dictionary<string, FixedPoint2> groups,
156-
IReadOnlyDictionary<string, FixedPoint2> damageDict)
159+
Dictionary<ProtoId<DamageGroupPrototype>, FixedPoint2> groups,
160+
IReadOnlyDictionary<ProtoId<DamageTypePrototype>, FixedPoint2> damageDict)
157161
{
158162
GroupsContainer.RemoveAllChildren();
159163

Content.Client/Medical/Cryogenics/CryoPodWindow.xaml.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using Content.Shared.Atmos;
55
using Content.Shared.Chemistry.Reagent;
66
using Content.Shared.Damage.Components;
7+
using Content.Shared.Damage.Systems;
78
using Content.Shared.EntityConditions.Conditions;
89
using Content.Shared.FixedPoint;
910
using Content.Shared.Medical.Cryogenics;
@@ -86,9 +87,7 @@ public void Populate(CryoPodUserMessage msg)
8687
// Health analyzer
8788
var maybePatient = _entityManager.GetEntity(msg.Health.TargetEntity);
8889
var hasPatient = msg.Health.TargetEntity.HasValue;
89-
var hasDamage = (hasPatient
90-
&& _entityManager.TryGetComponent(maybePatient, out DamageableComponent? damageable)
91-
&& damageable.TotalDamage > 0);
90+
var hasDamage = hasPatient && msg.HasDamage;
9291

9392
NoDamageText.Visible = (hasPatient && !hasDamage);
9493
HealthSection.Visible = hasPatient;

0 commit comments

Comments
 (0)