Skip to content

Commit

Permalink
Merge branch 'master' into DeltaV-Station_Delta-v_993_2024-04-07
Browse files Browse the repository at this point in the history
  • Loading branch information
VMSolidus committed May 12, 2024
2 parents cea5626 + 4b53cdf commit e6f0a08
Show file tree
Hide file tree
Showing 84 changed files with 4,715 additions and 260 deletions.
25 changes: 16 additions & 9 deletions Content.Client/Overlays/ShowHealthIconsSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Content.Shared.Atmos.Rotting;
using Content.Shared.Damage;
using Content.Shared.Inventory.Events;
using Content.Shared.Mobs.Components;
using Content.Shared.Overlays;
using Content.Shared.StatusIcon;
using Content.Shared.StatusIcon.Components;
Expand All @@ -17,9 +19,6 @@ public sealed class ShowHealthIconsSystem : EquipmentHudSystem<ShowHealthIconsCo

public HashSet<string> DamageContainers = new();

[ValidatePrototypeId<StatusIconPrototype>]
private const string HealthIconFine = "HealthIconFine";

public override void Initialize()
{
base.Initialize();
Expand All @@ -45,18 +44,20 @@ protected override void DeactivateInternal()
DamageContainers.Clear();
}

private void OnGetStatusIconsEvent(EntityUid uid, DamageableComponent damageableComponent, ref GetStatusIconsEvent args)
private void OnGetStatusIconsEvent(Entity<DamageableComponent> entity, ref GetStatusIconsEvent args)
{
if (!IsActive || args.InContainer)
return;

var healthIcons = DecideHealthIcons(damageableComponent);
var healthIcons = DecideHealthIcons(entity);

args.StatusIcons.AddRange(healthIcons);
}

private IReadOnlyList<StatusIconPrototype> DecideHealthIcons(DamageableComponent damageableComponent)
private IReadOnlyList<StatusIconPrototype> DecideHealthIcons(Entity<DamageableComponent> entity)
{
var damageableComponent = entity.Comp;

if (damageableComponent.DamageContainerID == null ||
!DamageContainers.Contains(damageableComponent.DamageContainerID))
{
Expand All @@ -66,10 +67,16 @@ private IReadOnlyList<StatusIconPrototype> DecideHealthIcons(DamageableComponent
var result = new List<StatusIconPrototype>();

// Here you could check health status, diseases, mind status, etc. and pick a good icon, or multiple depending on whatever.
if (damageableComponent?.DamageContainerID == "Biological" &&
_prototypeMan.TryIndex<StatusIconPrototype>(HealthIconFine, out var healthyIcon))
if (damageableComponent?.DamageContainerID == "Biological")
{
result.Add(healthyIcon);
if (TryComp<MobStateComponent>(entity, out var state))
{
// Since there is no MobState for a rotting mob, we have to deal with this case first.
if (HasComp<RottingComponent>(entity) && _prototypeMan.TryIndex(damageableComponent.RottingIcon, out var rottingIcon))
result.Add(rottingIcon);
else if (damageableComponent.HealthIcons.TryGetValue(state.CurrentState, out var value) && _prototypeMan.TryIndex(value, out var icon))
result.Add(icon);
}
}

return result;
Expand Down
6 changes: 2 additions & 4 deletions Content.Server/Chemistry/EntitySystems/VaporSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ internal sealed class VaporSystem : EntitySystem

private const float ReactTime = 0.125f;

private ISawmill _sawmill = default!;

public override void Initialize()
{
base.Initialize();
_sawmill = Logger.GetSawmill("vapor");

SubscribeLocalEvent<VaporComponent, StartCollideEvent>(HandleCollide);
}

Expand Down Expand Up @@ -128,7 +126,7 @@ private void Update(float frameTime, Entity<VaporComponent> ent, Entity<Solution

if (reaction > reagentQuantity.Quantity)
{
_sawmill.Error($"Tried to tile react more than we have for reagent {reagentQuantity}. Found {reaction} and we only have {reagentQuantity.Quantity}");
Log.Error($"Tried to tile react more than we have for reagent {reagentQuantity}. Found {reaction} and we only have {reagentQuantity.Quantity}");
reaction = reagentQuantity.Quantity;
}

Expand Down
7 changes: 2 additions & 5 deletions Content.Server/DeviceNetwork/Systems/DeviceListSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using Content.Server.DeviceNetwork.Components;
using Content.Shared.DeviceNetwork;
using Content.Shared.DeviceNetwork.Components;
Expand All @@ -12,8 +12,6 @@ namespace Content.Server.DeviceNetwork.Systems;
[UsedImplicitly]
public sealed class DeviceListSystem : SharedDeviceListSystem
{
private ISawmill _sawmill = default!;

[Dependency] private readonly NetworkConfiguratorSystem _configurator = default!;

public override void Initialize()
Expand All @@ -23,7 +21,6 @@ public override void Initialize()
SubscribeLocalEvent<DeviceListComponent, BeforeBroadcastAttemptEvent>(OnBeforeBroadcast);
SubscribeLocalEvent<DeviceListComponent, BeforePacketSentEvent>(OnBeforePacketSent);
SubscribeLocalEvent<BeforeSaveEvent>(OnMapSave);
_sawmill = Logger.GetSawmill("devicelist");
}

private void OnShutdown(EntityUid uid, DeviceListComponent component, ComponentShutdown args)
Expand Down Expand Up @@ -154,7 +151,7 @@ private void OnMapSave(BeforeSaveEvent ev)
// TODO full game saves.
// when full saves are supported, this should instead add data to the BeforeSaveEvent informing the
// saving system that this map (or null-space entity) also needs to be included in the save.
_sawmill.Error(
Log.Error(
$"Saving a device list ({ToPrettyString(uid)}) that has a reference to an entity on another map ({ToPrettyString(ent)}). Removing entity from list.");
}

Expand Down
10 changes: 3 additions & 7 deletions Content.Server/Forensics/Systems/ForensicScannerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,10 @@ public sealed class ForensicScannerSystem : EntitySystem
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;

private ISawmill _sawmill = default!;

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

_sawmill = Logger.GetSawmill("forensics.scanner");

SubscribeLocalEvent<ForensicScannerComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<ForensicScannerComponent, AfterInteractUsingEvent>(OnAfterInteractUsing);
SubscribeLocalEvent<ForensicScannerComponent, BeforeActivatableUIOpenEvent>(OnBeforeActivatableUIOpen);
Expand All @@ -57,7 +53,7 @@ private void UpdateUserInterface(EntityUid uid, ForensicScannerComponent compone
component.PrintReadyAt);

if (!_uiSystem.TrySetUiState(uid, ForensicScannerUiKey.Key, state))
_sawmill.Warning($"{ToPrettyString(uid)} was unable to set UI state.");
Log.Warning($"{ToPrettyString(uid)} was unable to set UI state.");
}

private void OnDoAfter(EntityUid uid, ForensicScannerComponent component, DoAfterEvent args)
Expand Down Expand Up @@ -180,7 +176,7 @@ private void OnPrint(EntityUid uid, ForensicScannerComponent component, Forensic
{
if (!args.Session.AttachedEntity.HasValue)
{
_sawmill.Warning($"{ToPrettyString(uid)} got OnPrint without Session.AttachedEntity");
Log.Warning($"{ToPrettyString(uid)} got OnPrint without Session.AttachedEntity");
return;
}

Expand All @@ -200,7 +196,7 @@ private void OnPrint(EntityUid uid, ForensicScannerComponent component, Forensic

if (!HasComp<PaperComponent>(printed))
{
_sawmill.Error("Printed paper did not have PaperComponent.");
Log.Error("Printed paper did not have PaperComponent.");
return;
}

Expand Down
14 changes: 6 additions & 8 deletions Content.Server/Mapping/MappingSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.IO;
using System.IO;
using Content.Server.Administration;
using Content.Shared.Administration;
using Content.Shared.CCVar;
Expand Down Expand Up @@ -32,7 +32,6 @@ public sealed class MappingSystem : EntitySystem
/// <returns></returns>
private Dictionary<MapId, (TimeSpan next, string fileName)> _currentlyAutosaving = new();

private ISawmill _sawmill = default!;
private bool _autosaveEnabled;

public override void Initialize()
Expand All @@ -44,7 +43,6 @@ public override void Initialize()
"autosave <map> <path if enabling>",
ToggleAutosaveCommand);

_sawmill = Logger.GetSawmill("autosave");
Subs.CVar(_cfg, CCVars.AutosaveEnabled, SetAutosaveEnabled, true);
}

Expand All @@ -69,7 +67,7 @@ public override void Update(float frameTime)

if (!_mapManager.MapExists(map) || _mapManager.IsMapInitialized(map))
{
_sawmill.Warning($"Can't autosave map {map}; it doesn't exist, or is initialized. Removing from autosave.");
Log.Warning($"Can't autosave map {map}; it doesn't exist, or is initialized. Removing from autosave.");
_currentlyAutosaving.Remove(map);
return;
}
Expand All @@ -79,7 +77,7 @@ public override void Update(float frameTime)

var path = Path.Combine(saveDir, $"{DateTime.Now.ToString("yyyy-M-dd_HH.mm.ss")}-AUTO.yml");
_currentlyAutosaving[map] = (CalculateNextTime(), name);
_sawmill.Info($"Autosaving map {name} ({map}) to {path}. Next save in {ReadableTimeLeft(map)} seconds.");
Log.Info($"Autosaving map {name} ({map}) to {path}. Next save in {ReadableTimeLeft(map)} seconds.");
_map.SaveMap(map, path);
}
}
Expand All @@ -105,17 +103,17 @@ public void ToggleAutosave(MapId map, string? path=null)
{
if (!_mapManager.MapExists(map) || _mapManager.IsMapInitialized(map))
{
_sawmill.Warning("Tried to enable autosaving on non-existant or already initialized map!");
Log.Warning("Tried to enable autosaving on non-existant or already initialized map!");
_currentlyAutosaving.Remove(map);
return;
}

_sawmill.Info($"Started autosaving map {path} ({map}). Next save in {ReadableTimeLeft(map)} seconds.");
Log.Info($"Started autosaving map {path} ({map}). Next save in {ReadableTimeLeft(map)} seconds.");
}
else
{
_currentlyAutosaving.Remove(map);
_sawmill.Info($"Stopped autosaving on map {map}");
Log.Info($"Stopped autosaving on map {map}");
}
}

Expand Down
6 changes: 1 addition & 5 deletions Content.Server/Mech/Systems/MechSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,11 @@ public sealed partial class MechSystem : SharedMechSystem
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly UserInterfaceSystem _ui = default!;

private ISawmill _sawmill = default!;

/// <inheritdoc/>
public override void Initialize()
{
base.Initialize();

_sawmill = Logger.GetSawmill("mech");

SubscribeLocalEvent<MechComponent, InteractUsingEvent>(OnInteractUsing);
SubscribeLocalEvent<MechComponent, EntInsertedIntoContainerMessage>(OnInsertBattery);
SubscribeLocalEvent<MechComponent, MapInitEvent>(OnMapInit);
Expand Down Expand Up @@ -343,7 +339,7 @@ public override bool TryChangeEnergy(EntityUid uid, FixedPoint2 delta, MechCompo
_battery.SetCharge(battery!.Value, batteryComp.CurrentCharge + delta.Float(), batteryComp);
if (batteryComp.CurrentCharge != component.Energy) //if there's a discrepency, we have to resync them
{
_sawmill.Debug($"Battery charge was not equal to mech charge. Battery {batteryComp.CurrentCharge}. Mech {component.Energy}");
Log.Debug($"Battery charge was not equal to mech charge. Battery {batteryComp.CurrentCharge}. Mech {component.Energy}");
component.Energy = batteryComp.CurrentCharge;
Dirty(component);
}
Expand Down
8 changes: 3 additions & 5 deletions Content.Server/Movement/Systems/LagCompensationSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@ public sealed class LagCompensationSystem : EntitySystem
// Max ping I've had is 350ms from aus to spain.
public static readonly TimeSpan BufferTime = TimeSpan.FromMilliseconds(750);

private ISawmill _sawmill = Logger.GetSawmill("lagcomp");

public override void Initialize()
{
base.Initialize();
_sawmill.Level = LogLevel.Info;
Log.Level = LogLevel.Info;
SubscribeLocalEvent<LagCompensationComponent, MoveEvent>(OnLagMove);
}

Expand Down Expand Up @@ -87,13 +85,13 @@ private void OnLagMove(EntityUid uid, LagCompensationComponent component, ref Mo

if (coordinates == default)
{
_sawmill.Debug($"No long comp coords found, using {xform.Coordinates}");
Log.Debug($"No long comp coords found, using {xform.Coordinates}");
coordinates = xform.Coordinates;
angle = xform.LocalRotation;
}
else
{
_sawmill.Debug($"Actual coords is {xform.Coordinates} and got {coordinates}");
Log.Debug($"Actual coords is {xform.Coordinates} and got {coordinates}");
}

return (coordinates, angle);
Expand Down
16 changes: 7 additions & 9 deletions Content.Server/NPC/Systems/NpcFactionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ public sealed partial class NpcFactionSystem : EntitySystem
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly IPrototypeManager _protoManager = default!;

private ISawmill _sawmill = default!;

/// <summary>
/// To avoid prototype mutability we store an intermediary data class that gets used instead.
/// </summary>
Expand All @@ -25,7 +23,7 @@ public sealed partial class NpcFactionSystem : EntitySystem
public override void Initialize()
{
base.Initialize();
_sawmill = Logger.GetSawmill("faction");

SubscribeLocalEvent<NpcFactionMemberComponent, ComponentStartup>(OnFactionStartup);
SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnProtoReload);

Expand Down Expand Up @@ -70,7 +68,7 @@ public void AddFaction(EntityUid uid, string faction, bool dirty = true)
{
if (!_protoManager.HasIndex<NpcFactionPrototype>(faction))
{
_sawmill.Error($"Unable to find faction {faction}");
Log.Error($"Unable to find faction {faction}");
return;
}

Expand All @@ -91,7 +89,7 @@ public void RemoveFaction(EntityUid uid, string faction, bool dirty = true)
{
if (!_protoManager.HasIndex<NpcFactionPrototype>(faction))
{
_sawmill.Error($"Unable to find faction {faction}");
Log.Error($"Unable to find faction {faction}");
return;
}

Expand Down Expand Up @@ -214,13 +212,13 @@ public void MakeFriendly(string source, string target)
{
if (!_factions.TryGetValue(source, out var sourceFaction))
{
_sawmill.Error($"Unable to find faction {source}");
Log.Error($"Unable to find faction {source}");
return;
}

if (!_factions.ContainsKey(target))
{
_sawmill.Error($"Unable to find faction {target}");
Log.Error($"Unable to find faction {target}");
return;
}

Expand Down Expand Up @@ -256,13 +254,13 @@ public void MakeHostile(string source, string target)
{
if (!_factions.TryGetValue(source, out var sourceFaction))
{
_sawmill.Error($"Unable to find faction {source}");
Log.Error($"Unable to find faction {source}");
return;
}

if (!_factions.ContainsKey(target))
{
_sawmill.Error($"Unable to find faction {target}");
Log.Error($"Unable to find faction {target}");
return;
}

Expand Down
Loading

0 comments on commit e6f0a08

Please sign in to comment.