Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into upstream-sync
Browse files Browse the repository at this point in the history
# Conflicts:
#	Content.Server/Chat/Systems/ChatSystem.cs
  • Loading branch information
Morb0 committed Oct 22, 2023
2 parents d742c3e + c318cba commit 429c0c2
Show file tree
Hide file tree
Showing 162 changed files with 1,947 additions and 332 deletions.
13 changes: 8 additions & 5 deletions Content.Client/Ghost/GhostSystem.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Content.Client.Movement.Systems;
using Content.Shared.Actions;
using Content.Shared.Ghost;
using Content.Shared.Popups;
using Robust.Client.Console;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
Expand Down Expand Up @@ -33,9 +32,10 @@ private bool GhostVisibility

_ghostVisibility = value;

foreach (var ghost in EntityQuery<GhostComponent, SpriteComponent>(true))
var query = AllEntityQuery<GhostComponent, SpriteComponent>();
while (query.MoveNext(out var uid, out _, out var sprite))
{
ghost.Item2.Visible = true;
sprite.Visible = value || uid == _playerManager.LocalPlayer?.ControlledEntity;
}
}
}
Expand Down Expand Up @@ -103,7 +103,10 @@ private void OnToggleGhosts(EntityUid uid, GhostComponent component, ToggleGhost
return;

Popup.PopupEntity(Loc.GetString("ghost-gui-toggle-ghost-visibility-popup"), args.Performer);
ToggleGhostVisibility();

if (uid == _playerManager.LocalPlayer?.ControlledEntity)
ToggleGhostVisibility();

args.Handled = true;
}

Expand Down Expand Up @@ -204,7 +207,7 @@ public void OpenGhostRoles()

public void ToggleGhostVisibility()
{
_console.RemoteExecuteCommand(null, "toggleghosts");
GhostVisibility = !GhostVisibility;
}
}
}
3 changes: 2 additions & 1 deletion Content.Client/Hands/Systems/HandsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ private void HandleComponentState(EntityUid uid, HandsComponent component, ref C
}
}

component.SortedHands = new(state.HandNames);
component.SortedHands.Clear();
component.SortedHands.AddRange(state.HandNames);
var sorted = addedHands.OrderBy(hand => component.SortedHands.IndexOf(hand.Name));

foreach (var hand in sorted)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ private bool TryFindFallbackSpawn(out EntityCoordinates coords)

Entity<MapGridComponent>? maxUid = null;
float? maxSize = null;
while (EntityQueryEnumerator<MapGridComponent>().MoveNext(out var uid, out var grid))
var gridQuery = EntityQueryEnumerator<MapGridComponent>();

while (gridQuery.MoveNext(out var uid, out var grid))
{
var size = grid.LocalAABB.Size.LengthSquared();
if (maxSize == null || size > maxSize)
Expand Down
5 changes: 3 additions & 2 deletions Content.Server/Body/Systems/ThermalRegulatorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ private void ProcessThermalRegulation(EntityUid uid, ThermalRegulatorComponent c

// implicit heat regulation
var tempDiff = Math.Abs(temperatureComponent.CurrentTemperature - comp.NormalBodyTemperature);
var targetHeat = tempDiff * temperatureComponent.HeatCapacity;
var heatCapacity = _tempSys.GetHeatCapacity(uid, temperatureComponent);
var targetHeat = tempDiff * heatCapacity;
if (temperatureComponent.CurrentTemperature > comp.NormalBodyTemperature)
{
totalMetabolismTempChange -= Math.Min(targetHeat, comp.ImplicitHeatRegulation);
Expand All @@ -49,7 +50,7 @@ private void ProcessThermalRegulation(EntityUid uid, ThermalRegulatorComponent c

// recalc difference and target heat
tempDiff = Math.Abs(temperatureComponent.CurrentTemperature - comp.NormalBodyTemperature);
targetHeat = tempDiff * temperatureComponent.HeatCapacity;
targetHeat = tempDiff * heatCapacity;

// if body temperature is not within comfortable, thermal regulation
// processes starts
Expand Down
4 changes: 3 additions & 1 deletion Content.Server/Chat/Managers/ChatSanitizationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public sealed class ChatSanitizationManager : IChatSanitizationManager
{ "._.", "chatsan-surprised" },
{ ".-.", "chatsan-confused" },
{ "-_-", "chatsan-unimpressed" },
{ "smh", "chatsan-unimpressed" },
{ "o/", "chatsan-waves" },
{ "^^/", "chatsan-waves" },
{ ":/", "chatsan-uncertain" },
Expand All @@ -88,10 +89,11 @@ public sealed class ChatSanitizationManager : IChatSanitizationManager
{ "lel.", "chatsan-laughs" },
{ "kek", "chatsan-laughs" },
{ "kek.", "chatsan-laughs" },
{ "rofl", "chatsan-laughs" },
{ "o7", "chatsan-salutes" },
{ ";_;7", "chatsan-tearfully-salutes"},
{ "idk", "chatsan-shrugs" },
{ "idk.", "chatsan-shrugs" }
{ "idk.", "chatsan-shrugs" },
};

private bool _doSanitize;
Expand Down
19 changes: 19 additions & 0 deletions Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System.Globalization;
using System.Linq;
using System.Text;
using Content.Server.Speech.EntitySystems;
using Content.Server.Speech.Components;
using Content.Server.Administration.Logs;
using Content.Server.Administration.Managers;
using Content.Server.Chat.Managers;
Expand Down Expand Up @@ -54,6 +56,7 @@ public sealed partial class ChatSystem : SharedChatSystem
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly ReplacementAccentSystem _wordreplacement = default!;

public const int VoiceRange = 10; // how far voice goes in world units
public const int WhisperClearRange = 2; // how far whisper goes while still being understandable, in world units
Expand Down Expand Up @@ -701,6 +704,8 @@ private string SanitizeInGameICMessage(EntityUid source, string message, out str
{
var newMessage = message.Trim();
newMessage = ReplaceWords(newMessage); // Corvax-ChatSanitize
newMessage = SanitizeMessageReplaceWords(newMessage);

if (capitalize)
newMessage = SanitizeMessageCapital(newMessage);
if (capitalizeTheWordI)
Expand Down Expand Up @@ -748,6 +753,20 @@ private string SanitizeMessagePeriod(string message)
return message;
}

[ValidatePrototypeId<ReplacementAccentPrototype>]
public const string ChatSanitize_Accent = "chatsanitize";

public string SanitizeMessageReplaceWords(string message)
{
if (string.IsNullOrEmpty(message)) return message;

var msg = message;

msg = _wordreplacement.ApplyReplacements(msg, ChatSanitize_Accent);

return msg;
}

/// <summary>
/// Returns list of players and ranges for all players withing some range. Also returns observers with a range of -1.
/// </summary>
Expand Down
26 changes: 19 additions & 7 deletions Content.Server/Construction/ConstructionSystem.Interactions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,16 +380,28 @@ private HandleResult HandleInteraction(EntityUid uid, object ev, ConstructionGra
if (ev is not OnTemperatureChangeEvent)
break;

if (TryComp<TemperatureComponent>(uid, out var tempComp))
// prefer using InternalTemperature since that's more accurate for cooking.
float temp;
if (TryComp<InternalTemperatureComponent>(uid, out var internalTemp))
{
if ((!temperatureChangeStep.MinTemperature.HasValue || tempComp.CurrentTemperature >= temperatureChangeStep.MinTemperature.Value) &&
(!temperatureChangeStep.MaxTemperature.HasValue || tempComp.CurrentTemperature <= temperatureChangeStep.MaxTemperature.Value))
{
return HandleResult.True;
}
temp = internalTemp.Temperature;
}
else if (TryComp<TemperatureComponent>(uid, out var tempComp))
{
temp = tempComp.CurrentTemperature;
}
else
{
return HandleResult.False;
}
return HandleResult.False;

if ((!temperatureChangeStep.MinTemperature.HasValue || temp >= temperatureChangeStep.MinTemperature.Value) &&
(!temperatureChangeStep.MaxTemperature.HasValue || temp <= temperatureChangeStep.MaxTemperature.Value))
{
return HandleResult.True;
}

return HandleResult.False;
}

case PartAssemblyConstructionGraphStep partAssemblyStep:
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/GameTicking/Rules/RevolutionaryRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ private void OnPlayerJobAssigned(RulePlayerJobsAssignedEvent ev)
{
_antagSelection.EligiblePlayers(comp.HeadRevPrototypeId, comp.MaxHeadRevs, comp.PlayersPerHeadRev, comp.HeadRevStartSound,
"head-rev-role-greeting", "#5e9cff", out var chosen);
if (!chosen.Any())
GiveHeadRev(chosen, comp.RevPrototypeId, comp);
if (chosen.Any())
GiveHeadRev(chosen, comp.HeadRevPrototypeId, comp);
else
{
_chatManager.SendAdminAnnouncement(Loc.GetString("rev-no-heads"));
Expand Down
27 changes: 0 additions & 27 deletions Content.Server/Ghost/GhostSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Content.Server.Roles.Jobs;
using Content.Server.Warps;
using Content.Shared.Actions;
using Content.Shared.Administration;
using Content.Shared.Examine;
using Content.Shared.Eye;
using Content.Shared.Follower;
Expand All @@ -16,11 +15,9 @@
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Movement.Events;
using Content.Shared.Popups;
using Content.Shared.Storage.Components;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Timing;
Expand Down Expand Up @@ -357,28 +354,4 @@ public bool DoGhostBooEvent(EntityUid target)
return ghostBoo.Handled;
}
}

[AnyCommand]
public sealed class ToggleGhostVisibility : IConsoleCommand
{
public string Command => "toggleghosts";
public string Description => "Toggles ghost visibility";
public string Help => $"{Command}";

public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player == null)
shell.WriteLine("You can only toggle ghost visibility on a client.");

var entityManager = IoCManager.Resolve<IEntityManager>();

var uid = shell.Player?.AttachedEntity;
if (uid == null
|| !entityManager.HasComponent<GhostComponent>(uid)
|| !entityManager.TryGetComponent<EyeComponent>(uid, out var eyeComponent))
return;

entityManager.System<EyeSystem>().SetVisibilityMask(uid.Value, eyeComponent.VisibilityMask ^ (int) VisibilityFlags.Ghost, eyeComponent);
}
}
}
2 changes: 1 addition & 1 deletion Content.Server/Guardian/GuardianSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private void OnHostStateChange(EntityUid uid, GuardianHostComponent component, M

if (args.NewMobState == MobState.Critical)
{
_popupSystem.PopupEntity(Loc.GetString("guardian-critical-warn"), component.HostedGuardian.Value, component.HostedGuardian.Value);
_popupSystem.PopupEntity(Loc.GetString("guardian-host-critical-warn"), component.HostedGuardian.Value, component.HostedGuardian.Value);
_audio.Play("/Audio/Effects/guardian_warn.ogg", Filter.Pvs(component.HostedGuardian.Value), component.HostedGuardian.Value, true);
}
else if (args.NewMobState == MobState.Dead)
Expand Down
16 changes: 8 additions & 8 deletions Content.Server/IgnitionSource/IgniteOnTriggerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ public override void Update(float deltaTime)
if (_timing.CurTime < comp.IgnitedUntil)
continue;

_source.SetIgnited(uid, false, source);
_source.SetIgnited((uid, source), false);
}
}

private void OnTrigger(EntityUid uid, IgniteOnTriggerComponent comp, TriggerEvent args)
private void OnTrigger(Entity<IgniteOnTriggerComponent> ent, ref TriggerEvent args)
{
// prevent spamming sound and ignition
TryComp<UseDelayComponent>(uid, out var delay);
if (_useDelay.ActiveDelay(uid, delay))
TryComp<UseDelayComponent>(ent, out var delay);
if (_useDelay.ActiveDelay(ent, delay))
return;

_source.SetIgnited(uid);
_audio.PlayPvs(comp.IgniteSound, uid);
_source.SetIgnited(ent.Owner);
_audio.PlayPvs(ent.Comp.IgniteSound, ent);

_useDelay.BeginDelay(uid, delay);
comp.IgnitedUntil = _timing.CurTime + comp.IgnitedTime;
_useDelay.BeginDelay(ent, delay);
ent.Comp.IgnitedUntil = _timing.CurTime + ent.Comp.IgnitedTime;
}
}
11 changes: 5 additions & 6 deletions Content.Server/IgnitionSource/IgnitionSourceComponent.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
namespace Content.Server.IgnitionSource;

/// <summary>
/// This is used for...
/// This is used for creating atmosphere hotspots while ignited to start reactions such as fire.
/// </summary>
[RegisterComponent]
[Access(typeof(IgnitionSourceSystem))]
[RegisterComponent, Access(typeof(IgnitionSourceSystem))]
public sealed partial class IgnitionSourceComponent : Component
{
[DataField("ignited")]
public bool Ignited = false;
[DataField, ViewVariables(VVAccess.ReadWrite)]
public bool Ignited;

[DataField("temperature", required: true)]
[DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
public int Temperature;
}
31 changes: 14 additions & 17 deletions Content.Server/IgnitionSource/IgnitionSourceSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,49 @@ namespace Content.Server.IgnitionSource;
/// <summary>
/// This handles ignition, Jez basically coded this.
/// </summary>
///
public sealed class IgnitionSourceSystem : EntitySystem
{
/// <inheritdoc/>
///
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly TransformSystem _transformSystem = default!;
[Dependency] private readonly AtmosphereSystem _atmosphere = default!;
[Dependency] private readonly TransformSystem _transform = default!;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<IgnitionSourceComponent,IsHotEvent>(OnIsHot);

SubscribeLocalEvent<IgnitionSourceComponent, IsHotEvent>(OnIsHot);
}

private void OnIsHot(EntityUid uid, IgnitionSourceComponent component, IsHotEvent args)
private void OnIsHot(Entity<IgnitionSourceComponent> ent, ref IsHotEvent args)
{
SetIgnited(uid, args.IsHot, component);
SetIgnited((ent.Owner, ent.Comp), args.IsHot);
}

/// <summary>
/// Simply sets the ignited field to the ignited param.
/// </summary>
public void SetIgnited(EntityUid uid, bool ignited = true, IgnitionSourceComponent? comp = null)
public void SetIgnited(Entity<IgnitionSourceComponent?> ent, bool ignited = true)
{
if (!Resolve(uid, ref comp))
if (!Resolve(ent, ref ent.Comp))
return;

comp.Ignited = ignited;
ent.Comp.Ignited = ignited;
}

public override void Update(float frameTime)
{
base.Update(frameTime);

var query = EntityQueryEnumerator<IgnitionSourceComponent, TransformComponent>();
while (query.MoveNext(out var source, out var component, out var transform))
while (query.MoveNext(out var uid, out var comp, out var xform))
{
if (!component.Ignited)
if (!comp.Ignited)
continue;

if (transform.GridUid is { } gridUid)
if (xform.GridUid is { } gridUid)
{
var position = _transformSystem.GetGridOrMapTilePosition(source, transform);
_atmosphereSystem.HotspotExpose(gridUid, position, component.Temperature, 50, source, true);
var position = _transform.GetGridOrMapTilePosition(uid, xform);
_atmosphere.HotspotExpose(gridUid, position, comp.Temperature, 50, uid, true);
}
}

}
}
6 changes: 3 additions & 3 deletions Content.Server/Salvage/SalvageSystem.ExpeditionConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private void OnSalvageClaimMessage(EntityUid uid, SalvageExpeditionConsoleCompon
data.ActiveMission = args.Index;
var mission = GetMission(_prototypeManager.Index<SalvageDifficultyPrototype>(missionparams.Difficulty), missionparams.Seed);
data.NextOffer = _timing.CurTime + mission.Duration + TimeSpan.FromSeconds(1);
UpdateConsoles(data);
UpdateConsoles((station.Value, data));
}

private void OnSalvageConsoleInit(Entity<SalvageExpeditionConsoleComponent> console, ref ComponentInit args)
Expand All @@ -33,7 +33,7 @@ private void OnSalvageConsoleParent(Entity<SalvageExpeditionConsoleComponent> co
UpdateConsole(console);
}

private void UpdateConsoles(SalvageExpeditionDataComponent component)
private void UpdateConsoles(Entity<SalvageExpeditionDataComponent> component)
{
var state = GetState(component);

Expand All @@ -42,7 +42,7 @@ private void UpdateConsoles(SalvageExpeditionDataComponent component)
{
var station = _station.GetOwningStation(uid, xform);

if (station != uid)
if (station != component.Owner)
continue;

_ui.TrySetUiState(uid, SalvageConsoleUiKey.Expedition, state, ui: uiComp);
Expand Down
Loading

0 comments on commit 429c0c2

Please sign in to comment.