Skip to content

Commit

Permalink
Merge pull request Simple-Station#94 from SS14-Classic/Update-11/2/2024
Browse files Browse the repository at this point in the history
Update 11/2/2024
  • Loading branch information
VMSolidus authored Nov 2, 2024
2 parents bd12e99 + 1080ae9 commit db21108
Show file tree
Hide file tree
Showing 112 changed files with 45,294 additions and 35,552 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using Content.Server.Atmos.EntitySystems;
using Content.Server.Atmos.Piping.Components;
using Content.Server.Atmos.Piping.Trinary.Components;
using Content.Server.NodeContainer;
using Content.Server.NodeContainer.EntitySystems;
using Content.Server.NodeContainer.Nodes;
using Content.Shared.Atmos.Piping;
Expand All @@ -13,7 +11,6 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems
[UsedImplicitly]
public sealed class PressureControlledValveSystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly NodeContainerSystem _nodeContainer = default!;
Expand All @@ -40,39 +37,26 @@ private void OnUpdate(EntityUid uid, PressureControlledValveComponent comp, ref
return;
}

// If output is higher than input, flip input/output to enable bidirectional flow.
if (outletNode.Air.Pressure > inletNode.Air.Pressure)
{
PipeNode temp = outletNode;
outletNode = inletNode;
inletNode = temp;
}

float control = (controlNode.Air.Pressure - outletNode.Air.Pressure) - comp.Threshold;
float transferRate;
if (control < 0)
{
comp.Enabled = false;
transferRate = 0;
}
else
// If the pressure in either inlet or outlet exceeds the side pressure, act as an open pipe.
if (!comp.Enabled && (controlNode.Air.Pressure < inletNode.Air.Pressure
|| controlNode.Air.Pressure < outletNode.Air.Pressure))
{
inletNode.AddAlwaysReachable(outletNode);
outletNode.AddAlwaysReachable(inletNode);
comp.Enabled = true;
transferRate = Math.Min(control * comp.Gain, comp.MaxTransferRate * _atmosphereSystem.PumpSpeedup());
UpdateAppearance(uid, comp);
_ambientSoundSystem.SetAmbience(uid, true);
return;
}
UpdateAppearance(uid, comp);

// We multiply the transfer rate in L/s by the seconds passed since the last process to get the liters.
var transferVolume = transferRate * args.dt;
if (transferVolume <= 0)
{
_ambientSoundSystem.SetAmbience(uid, false);
if (!comp.Enabled)
return;
}

_ambientSoundSystem.SetAmbience(uid, true);
var removed = inletNode.Air.RemoveVolume(transferVolume);
_atmosphereSystem.Merge(outletNode.Air, removed);
inletNode.RemoveAlwaysReachable(outletNode);
outletNode.RemoveAlwaysReachable(inletNode);
comp.Enabled = false;
UpdateAppearance(uid, comp);
_ambientSoundSystem.SetAmbience(uid, false);
}

private void OnFilterLeaveAtmosphere(EntityUid uid, PressureControlledValveComponent comp, ref AtmosDeviceDisabledEvent args)
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Chat/Systems/ChatSystem.Emote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private void CacheEmotes()
/// <param name="emoteId">The id of emote prototype. Should has valid <see cref="EmotePrototype.ChatMessages"/></param>
/// <param name="hideLog">Whether or not this message should appear in the adminlog window</param>
/// <param name="range">Conceptual range of transmission, if it shows in the chat window, if it shows to far-away ghosts or ghosts at all...</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerNameEvent"/>. If this is set, the event will not get raised.</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerSpeechEvent"/>. If this is set, the event will not get raised.</param>
public void TryEmoteWithChat(
EntityUid source,
string emoteId,
Expand All @@ -74,7 +74,7 @@ public void TryEmoteWithChat(
/// <param name="hideLog">Whether or not this message should appear in the adminlog window</param>
/// <param name="hideChat">Whether or not this message should appear in the chat window</param>
/// <param name="range">Conceptual range of transmission, if it shows in the chat window, if it shows to far-away ghosts or ghosts at all...</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerNameEvent"/>. If this is set, the event will not get raised.</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerSpeechEvent"/>. If this is set, the event will not get raised.</param>
public void TryEmoteWithChat(
EntityUid source,
EmotePrototype emote,
Expand Down
29 changes: 7 additions & 22 deletions Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Content.Server.Language;
using Content.Server.Speech.Components;
using Content.Server.Speech.EntitySystems;
using Content.Server.Chat;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Shared.ActionBlocker;
Expand Down Expand Up @@ -147,7 +146,7 @@ private void OnGameChange(GameRunLevelChangedEvent ev)
/// <param name="hideLog">Whether or not this message should appear in the adminlog window</param>
/// <param name="shell"></param>
/// <param name="player">The player doing the speaking</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerNameEvent"/>. If this is set, the event will not get raised.</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerSpeechEvent"/>. If this is set, the event will not get raised.</param>
public void TrySendInGameICMessage(
EntityUid source,
string message,
Expand All @@ -170,7 +169,7 @@ public void TrySendInGameICMessage(
/// <param name="range">Conceptual range of transmission, if it shows in the chat window, if it shows to far-away ghosts or ghosts at all...</param>
/// <param name="shell"></param>
/// <param name="player">The player doing the speaking</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerNameEvent"/>. If this is set, the event will not get raised.</param>
/// <param name="nameOverride">The name to use for the speaking entity. Usually this should just be modified via <see cref="TransformSpeakerSpeechEvent"/>. If this is set, the event will not get raised.</param>
/// <param name="ignoreActionBlocker">If set to true, action blocker will not be considered for whether an entity can send this message.</param>
public void TrySendInGameICMessage(
EntityUid source,
Expand Down Expand Up @@ -421,11 +420,11 @@ private void SendEntitySpeak(
}
else
{
var nameEv = new TransformSpeakerNameEvent(source, Name(source));
var nameEv = new TransformSpeakerSpeechEvent(source, Name(source));
RaiseLocalEvent(source, nameEv);
name = nameEv.Name;
name = nameEv.VoiceName ?? Name(source);
// Check for a speech verb override
if (nameEv.SpeechVerb != null && _prototypeManager.TryIndex<SpeechVerbPrototype>(nameEv.SpeechVerb, out var proto))
if (nameEv.SpeechVerb != null && _prototypeManager.TryIndex(nameEv.SpeechVerb, out var proto))
speech = proto;
}

Expand Down Expand Up @@ -493,9 +492,9 @@ private void SendEntityWhisper(
}
else
{
var nameEv = new TransformSpeakerNameEvent(source, Name(source));
var nameEv = new TransformSpeakerSpeechEvent(source, Name(source));
RaiseLocalEvent(source, nameEv);
name = nameEv.Name;
name = nameEv.VoiceName ?? Name(source);
}
name = FormattedMessage.EscapeText(name);

Expand Down Expand Up @@ -990,20 +989,6 @@ public record ExpandICChatRecipientstEvent(EntityUid Source, float VoiceRange, D
{
}

public sealed class TransformSpeakerNameEvent : EntityEventArgs
{
public EntityUid Sender;
public string Name;
public string? SpeechVerb;

public TransformSpeakerNameEvent(EntityUid sender, string name, string? speechVerb = null)
{
Sender = sender;
Name = name;
SpeechVerb = speechVerb;
}
}

/// <summary>
/// Raised broadcast in order to transform speech.transmit
/// </summary>
Expand Down
80 changes: 76 additions & 4 deletions Content.Server/Cocoon/CocoonerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
using Content.Server.Speech.Components;
using Robust.Shared.Containers;
using Content.Shared.Mobs.Components;
using Content.Shared.Destructible;
using Robust.Shared.Random;
using Content.Shared.Nutrition.Components;
using Content.Shared.Storage;
using Robust.Shared.Utility;

namespace Content.Server.Cocoon
{
Expand All @@ -25,17 +30,26 @@ public sealed class CocooningSystem : EntitySystem
[Dependency] private readonly BlindableSystem _blindableSystem = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly SharedDestructibleSystem _destructibleSystem = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;

private const string BodySlot = "body_slot";

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CocoonerComponent, GetVerbsEvent<InnateVerb>>(AddCocoonVerb);
SubscribeLocalEvent<CocoonerComponent, GetVerbsEvent<InnateVerb>>(AddVerbs);
SubscribeLocalEvent<CocoonComponent, EntInsertedIntoContainerMessage>(OnCocEntInserted);
SubscribeLocalEvent<CocoonComponent, EntRemovedFromContainerMessage>(OnCocEntRemoved);
SubscribeLocalEvent<CocoonComponent, DamageChangedEvent>(OnDamageChanged);
SubscribeLocalEvent<CocoonerComponent, CocoonDoAfterEvent>(OnCocoonDoAfter);
SubscribeLocalEvent<CocoonerComponent, UnCocoonDoAfterEvent>(OnUnCocoonDoAfter);
}

private void AddVerbs(EntityUid uid, CocoonerComponent component, GetVerbsEvent<InnateVerb> args)
{
AddCocoonVerb(uid, component, args);
AddUnCocoonVerb(uid, component, args);
}

private void AddCocoonVerb(EntityUid uid, CocoonerComponent component, GetVerbsEvent<InnateVerb> args)
Expand All @@ -50,6 +64,25 @@ private void AddCocoonVerb(EntityUid uid, CocoonerComponent component, GetVerbsE
StartCocooning(uid, component, args.Target);
},
Text = Loc.GetString("cocoon"),
Icon = new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/Actions/web.png")),
Priority = 2
};
args.Verbs.Add(verb);
}

private void AddUnCocoonVerb(EntityUid uid, CocoonerComponent component, GetVerbsEvent<InnateVerb> args)
{
if (!args.CanAccess || !args.CanInteract || !HasComp<CocoonComponent>(args.Target))
return;

InnateVerb verb = new()
{
Act = () =>
{
StartUnCocooning(uid, component, args.Target);
},
Text = Loc.GetString("uncocoon"),
Icon = new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/Actions/web.png")),
Priority = 2
};
args.Verbs.Add(verb);
Expand All @@ -71,9 +104,11 @@ private void OnCocEntInserted(EntityUid uid, CocoonComponent component, EntInser
private void OnCocEntRemoved(EntityUid uid, CocoonComponent component, EntRemovedFromContainerMessage args)
{
if (TryComp<ReplacementAccentComponent>(args.Entity, out var replacement))
replacement.Accent = component.OldAccent ?? replacement.Accent;
else
RemComp<ReplacementAccentComponent>(args.Entity);
if (component.OldAccent is not null)
replacement.Accent = component.OldAccent;
else
RemComp(args.Entity, replacement);


RemComp<StunnedComponent>(args.Entity);
_blindableSystem.UpdateIsBlind(args.Entity);
Expand Down Expand Up @@ -107,6 +142,22 @@ private void StartCocooning(EntityUid uid, CocoonerComponent component, EntityUi
_doAfter.TryStartDoAfter(args);
}

private void StartUnCocooning(EntityUid uid, CocoonerComponent component, EntityUid target)
{
_popupSystem.PopupEntity(Loc.GetString("uncocoon-start-third-person", ("target", target), ("spider", Identity.Entity(uid, EntityManager))), uid,
Shared.Popups.PopupType.MediumCaution);

var delay = component.CocoonDelay / 2;

var args = new DoAfterArgs(EntityManager, uid, delay, new UnCocoonDoAfterEvent(), uid, target: target)
{
BreakOnUserMove = true,
BreakOnTargetMove = true,
};

_doAfter.TryStartDoAfter(args);
}

private void OnCocoonDoAfter(EntityUid uid, CocoonerComponent component, CocoonDoAfterEvent args)
{
if (args.Handled || args.Cancelled || args.Args.Target == null)
Expand All @@ -128,5 +179,26 @@ private void OnCocoonDoAfter(EntityUid uid, CocoonerComponent component, CocoonD
_adminLogger.Add(LogType.Action, impact, $"{ToPrettyString(args.Args.User):player} cocooned {ToPrettyString(args.Args.Target.Value):target}");
args.Handled = true;
}

private void OnUnCocoonDoAfter(EntityUid uid, CocoonerComponent component, UnCocoonDoAfterEvent args)
{
if (args.Handled || args.Cancelled || args.Args.Target == null)
return;

if (TryComp<ButcherableComponent>(args.Args.Target.Value, out var butcher))
{
var spawnEntities = EntitySpawnCollection.GetSpawns(butcher.SpawnedEntities, _robustRandom);
var coords = Transform(args.Args.Target.Value).MapPosition;
EntityUid popupEnt = default!;
foreach (var proto in spawnEntities)
popupEnt = Spawn(proto, coords.Offset(_robustRandom.NextVector2(0.25f)));
}

_destructibleSystem.DestroyEntity(args.Args.Target.Value);

_adminLogger.Add(LogType.Action, LogImpact.Low
, $"{ToPrettyString(args.Args.User):player} uncocooned {ToPrettyString(args.Args.Target.Value):target}");
args.Handled = true;
}
}
}
Loading

0 comments on commit db21108

Please sign in to comment.