Skip to content

Commit

Permalink
Merge branch 'Simple-Station:master' into Walls/Windows-Resprites
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxxoTrystan committed May 13, 2024
2 parents 50245ce + 255e307 commit 8bcdefd
Show file tree
Hide file tree
Showing 350 changed files with 6,607 additions and 502 deletions.
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
1 change: 1 addition & 0 deletions Content.Client/Actions/ActionsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ private void BaseHandleState<T>(EntityUid uid, BaseActionComponent component, Ba
component.Container = EnsureEntity<T>(state.Container, uid);
component.EntityIcon = EnsureEntity<T>(state.EntityIcon, uid);
component.CheckCanInteract = state.CheckCanInteract;
component.CheckConsciousness = state.CheckConsciousness;
component.ClientExclusive = state.ClientExclusive;
component.Priority = state.Priority;
component.AttachedEntity = EnsureEntity<T>(state.AttachedEntity, uid);
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/Chat/UI/SpeechBubble.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ protected override Control BuildBubble(ChatMessage message, string speechStyleCl
var bubbleContent = new RichTextLabel
{
MaxWidth = SpeechMaxWidth,
Margin = new Thickness(2, 6, 2, 2)
Margin = new Thickness(2, 6, 2, 2),
StyleClasses = { "bubbleContent" }
};

//We'll be honest. *Yes* this is hacky. Doing this in a cleaner way would require a bottom-up refactor of how saycode handles sending chat messages. -Myr
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
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
120 changes: 120 additions & 0 deletions Content.Client/Paint/PaintVisualizerSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
using System.Linq;
using Robust.Client.GameObjects;
using static Robust.Client.GameObjects.SpriteComponent;
using Content.Shared.Clothing;
using Content.Shared.Hands;
using Content.Shared.Paint;
using Robust.Client.Graphics;
using Robust.Shared.Prototypes;

namespace Content.Client.Paint
{
public sealed class PaintedVisualizerSystem : VisualizerSystem<PaintedComponent>
{
/// <summary>
/// Visualizer for Paint which applies a shader and colors the entity.
/// </summary>

[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly IPrototypeManager _protoMan = default!;

public ShaderInstance? Shader; // in Robust.Client.Graphics so cannot move to shared component.

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

SubscribeLocalEvent<PaintedComponent, HeldVisualsUpdatedEvent>(OnHeldVisualsUpdated);
SubscribeLocalEvent<PaintedComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<PaintedComponent, EquipmentVisualsUpdatedEvent>(OnEquipmentVisualsUpdated);
}

protected override void OnAppearanceChange(EntityUid uid, PaintedComponent component, ref AppearanceChangeEvent args)
{
// ShaderPrototype sadly in Robust.Client, cannot move to shared component.
Shader = _protoMan.Index<ShaderPrototype>(component.ShaderName).Instance();

if (args.Sprite == null)
return;

if (!_appearance.TryGetData<bool>(uid, PaintVisuals.Painted, out bool isPainted))
return;

var sprite = args.Sprite;


foreach (var spriteLayer in sprite.AllLayers)
{
if (spriteLayer is not Layer layer)
continue;

if (layer.Shader == null) // If shader isn't null we dont want to replace the original shader.
{
layer.Shader = Shader;
layer.Color = component.Color;
}
}
}

private void OnHeldVisualsUpdated(EntityUid uid, PaintedComponent component, HeldVisualsUpdatedEvent args)
{
if (args.RevealedLayers.Count == 0)
return;

if (!TryComp(args.User, out SpriteComponent? sprite))
return;

foreach (var revealed in args.RevealedLayers)
{
if (!sprite.LayerMapTryGet(revealed, out var layer) || sprite[layer] is not Layer notlayer)
continue;

sprite.LayerSetShader(layer, component.ShaderName);
sprite.LayerSetColor(layer, component.Color);
}
}

private void OnEquipmentVisualsUpdated(EntityUid uid, PaintedComponent component, EquipmentVisualsUpdatedEvent args)
{
if (args.RevealedLayers.Count == 0)
return;

if (!TryComp(args.Equipee, out SpriteComponent? sprite))
return;

foreach (var revealed in args.RevealedLayers)
{
if (!sprite.LayerMapTryGet(revealed, out var layer) || sprite[layer] is not Layer notlayer)
continue;

sprite.LayerSetShader(layer, component.ShaderName);
sprite.LayerSetColor(layer, component.Color);
}
}

private void OnShutdown(EntityUid uid, PaintedComponent component, ref ComponentShutdown args)
{
if (!TryComp(uid, out SpriteComponent? sprite))
return;

component.BeforeColor = sprite.Color;
Shader = _protoMan.Index<ShaderPrototype>(component.ShaderName).Instance();

if (!Terminating(uid))
{
foreach (var spriteLayer in sprite.AllLayers)
{
if (spriteLayer is not Layer layer)
continue;

if (layer.Shader == Shader) // If shader isn't same as one in component we need to ignore it.
{
layer.Shader = null;
if (layer.Color == component.Color) // If color isn't the same as one in component we don't want to change it.
layer.Color = component.BeforeColor;
}
}
}
}
}
}
8 changes: 8 additions & 0 deletions Content.Client/Stylesheets/StyleNano.cs
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,14 @@ public StyleNano(IResourceCache resCache) : base(resCache)
new StyleProperty(PanelContainer.StylePropertyPanel, whisperBox)
}),

new StyleRule(new SelectorChild(
new SelectorElement(typeof(PanelContainer), new[] {"speechBox", "whisperBox"}, null, null),
new SelectorElement(typeof(RichTextLabel), new[] {"bubbleContent"}, null, null)),
new[]
{
new StyleProperty("font", notoSansItalic12),
}),

new StyleRule(new SelectorChild(
new SelectorElement(typeof(PanelContainer), new[] {"speechBox", "emoteBox"}, null, null),
new SelectorElement(typeof(RichTextLabel), null, null, null)),
Expand Down
6 changes: 4 additions & 2 deletions Content.Server/Access/Systems/PresetIdCardSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ private void OnMapInit(EntityUid uid, PresetIdCardComponent id, MapInitEvent arg

var station = _stationSystem.GetOwningStation(uid);
var extended = false;
if (station != null)
extended = Comp<StationJobsComponent>(station.Value).ExtendedAccess;

// Station not guaranteed to have jobs (e.g. nukie outpost).
if (TryComp(station, out StationJobsComponent? stationJobs))
extended = stationJobs.ExtendedAccess;

SetupIdAccess(uid, id, extended);
SetupIdName(uid, id);
Expand Down
6 changes: 4 additions & 2 deletions Content.Server/Atmos/EntitySystems/BarotraumaSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ public float GetFeltLowPressure(EntityUid uid, BarotraumaComponent barotrauma, f
return Atmospherics.OneAtmosphere;
}

return (environmentPressure + barotrauma.LowPressureModifier) * (barotrauma.LowPressureMultiplier);
var modified = (environmentPressure + barotrauma.LowPressureModifier) * (barotrauma.LowPressureMultiplier);
return Math.Min(modified, Atmospherics.OneAtmosphere);
}

/// <summary>
Expand All @@ -162,7 +163,8 @@ public float GetFeltHighPressure(EntityUid uid, BarotraumaComponent barotrauma,
return Atmospherics.OneAtmosphere;
}

return (environmentPressure + barotrauma.HighPressureModifier) * (barotrauma.HighPressureMultiplier);
var modified = (environmentPressure + barotrauma.HighPressureModifier) * (barotrauma.HighPressureMultiplier);
return Math.Max(modified, Atmospherics.OneAtmosphere);
}

public bool TryGetPressureProtectionValues(
Expand Down
8 changes: 8 additions & 0 deletions Content.Server/Bed/Sleep/SleepingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Content.Shared.Examine;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Slippery;
Expand Down Expand Up @@ -45,6 +46,7 @@ public override void Initialize()
SubscribeLocalEvent<SleepingComponent, InteractHandEvent>(OnInteractHand);
SubscribeLocalEvent<SleepingComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<SleepingComponent, SlipAttemptEvent>(OnSlip);
SubscribeLocalEvent<SleepingComponent, ConsciousAttemptEvent>(OnConsciousAttempt);
SubscribeLocalEvent<ForcedSleepingComponent, ComponentInit>(OnInit);
}

Expand Down Expand Up @@ -173,6 +175,12 @@ private void OnSlip(EntityUid uid, SleepingComponent component, SlipAttemptEvent
args.Cancel();
}

private void OnConsciousAttempt(EntityUid uid, SleepingComponent component, ConsciousAttemptEvent args)
{
args.Cancel();
}


private void OnInit(EntityUid uid, ForcedSleepingComponent component, ComponentInit args)
{
TrySleeping(uid);
Expand Down
26 changes: 26 additions & 0 deletions Content.Server/Cargo/Systems/CargoSystem.CVars.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Robust.Shared.Configuration;

namespace Content.Server.Cargo.Systems
{
public sealed partial class CargoSystem
{
[Dependency] private readonly IConfigurationManager _cfg = default!;
}

[CVarDefs]
public sealed class CargoCVars
{
/// <summary>
/// Determines if a trade station spawns in its own FTL map.
/// </summary>
/// <remarks>
/// Set this to true if and only if you are disabling the normal spawning method.
/// Otherwise you get two trade stations.
/// This does NOTHING to the trade station that spawns on the default map.
/// To change that, in Resources/Prototypes/Entities/Stations/base.yml;
/// comment out the "trade:" section.
/// </remarks>
public static readonly CVarDef<bool> CreateCargoMap =
CVarDef.Create("cargo.tradestation_spawns_in_ftl_map", false, CVar.SERVERONLY);
}
}
5 changes: 3 additions & 2 deletions Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using Robust.Shared.Audio;
using Robust.Shared.Physics.Components;
using Robust.Shared.Utility;
using Robust.Shared.Configuration;

namespace Content.Server.Cargo.Systems;

Expand All @@ -27,7 +28,7 @@ public sealed partial class CargoSystem
/*
* Handles cargo shuttle / trade mechanics.
*/

[Dependency] private readonly IConfigurationManager _confMan = default!;
public MapId? CargoMap { get; private set; }

private static readonly SoundPathSpecifier ApproveSound = new("/Audio/Effects/Cargo/ping.ogg");
Expand Down Expand Up @@ -369,7 +370,7 @@ private void OnStationInitialize(StationInitializedEvent args)
if (!HasComp<StationCargoOrderDatabaseComponent>(args.Station)) // No cargo, L
return;

if (_cfgManager.GetCVar(CCVars.GridFill))
if (_cfgManager.GetCVar(CCVars.GridFill) && _confMan.GetCVar(CargoCVars.CreateCargoMap))
SetupTradePost();
}

Expand Down
Loading

0 comments on commit 8bcdefd

Please sign in to comment.