Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…on-14 into fix/shuttle-control-radius-scale
  • Loading branch information
exincore committed May 6, 2024
2 parents 99112dc + eee8e03 commit 7ede0f6
Show file tree
Hide file tree
Showing 74 changed files with 385 additions and 164 deletions.
2 changes: 1 addition & 1 deletion Content.Client/Chat/UI/EmotesMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<TextureRect VerticalAlignment="Center" HorizontalAlignment="Center" TextureScale="2 2" TexturePath="/Textures/Clothing/Head/Soft/mimesoft.rsi/icon.png"/>
</ui:RadialMenuTextureButton>
<ui:RadialMenuTextureButton StyleClasses="RadialMenuButton" SetSize="64 64" ToolTip="{Loc 'emote-menu-category-vocal'}" TargetLayer="Vocal" Visible="False">
<TextureRect VerticalAlignment="Center" HorizontalAlignment="Center" TextureScale="2 2" TexturePath="/Textures/Interface/Actions/scream.png"/>
<TextureRect VerticalAlignment="Center" HorizontalAlignment="Center" TextureScale="2 2" TexturePath="/Textures/Interface/Emotes/vocal.png"/>
</ui:RadialMenuTextureButton>
<ui:RadialMenuTextureButton StyleClasses="RadialMenuButton" SetSize="64 64" ToolTip="{Loc 'emote-menu-category-hands'}" TargetLayer="Hands" Visible="False">
<TextureRect VerticalAlignment="Center" HorizontalAlignment="Center" TextureScale="2 2" TexturePath="/Textures/Clothing/Hands/Gloves/latex.rsi/icon.png"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Content.Client.Cooldown;
using Content.Shared.Alert;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Timing;
Expand Down Expand Up @@ -117,7 +116,9 @@ protected override void FrameUpdate(FrameEventArgs args)
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_entityManager.QueueDeleteEntity(_spriteViewEntity);

if (!_entityManager.Deleted(_spriteViewEntity))
_entityManager.QueueDeleteEntity(_spriteViewEntity);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using static Robust.UnitTesting.RobustIntegrationTest;

namespace Content.IntegrationTests.Tests.Interaction;

Expand Down Expand Up @@ -54,7 +55,7 @@ public static implicit operator EntitySpecifier((string, int) tuple)
/// <summary>
/// Convert applicable entity prototypes into stack prototypes.
/// </summary>
public void ConvertToStack(IPrototypeManager protoMan, IComponentFactory factory)
public async Task ConvertToStack(IPrototypeManager protoMan, IComponentFactory factory, ServerIntegrationInstance server)
{
if (Converted)
return;
Expand All @@ -73,11 +74,14 @@ public void ConvertToStack(IPrototypeManager protoMan, IComponentFactory factory
return;
}

if (entProto.TryGetComponent<StackComponent>(factory.GetComponentName(typeof(StackComponent)),
out var stackComp))
StackComponent? stack = null;
await server.WaitPost(() =>
{
Prototype = stackComp.StackTypeId;
}
entProto.TryGetComponent(factory.GetComponentName(typeof(StackComponent)), out stack);
});

if (stack != null)
Prototype = stack.StackTypeId;
}
}

Expand All @@ -100,11 +104,14 @@ await Server.WaitPost(() =>
return default;
}

if (entProto.TryGetComponent<StackComponent>(Factory.GetComponentName(typeof(StackComponent)),
out var stackComp))
StackComponent? stack = null;
await Server.WaitPost(() =>
{
return await SpawnEntity((stackComp.StackTypeId, spec.Quantity), coords);
}
entProto.TryGetComponent(Factory.GetComponentName(typeof(StackComponent)), out stack);
});

if (stack != null)
return await SpawnEntity((stack.StackTypeId, spec.Quantity), coords);

Assert.That(spec.Quantity, Is.EqualTo(1), "SpawnEntity only supports returning a singular entity");
await Server.WaitPost(() => uid = SEntMan.SpawnEntity(spec.Prototype, coords));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using static Robust.UnitTesting.RobustIntegrationTest;

namespace Content.IntegrationTests.Tests.Interaction;

Expand Down Expand Up @@ -111,7 +112,7 @@ public EntitySpecifierCollection Clone()
/// <summary>
/// Convert applicable entity prototypes into stack prototypes.
/// </summary>
public void ConvertToStacks(IPrototypeManager protoMan, IComponentFactory factory)
public async Task ConvertToStacks(IPrototypeManager protoMan, IComponentFactory factory, ServerIntegrationInstance server)
{
if (Converted)
return;
Expand All @@ -130,14 +131,17 @@ public void ConvertToStacks(IPrototypeManager protoMan, IComponentFactory factor
continue;
}

if (!entProto.TryGetComponent<StackComponent>(factory.GetComponentName(typeof(StackComponent)),
out var stackComp))
StackComponent? stack = null;
await server.WaitPost(() =>
{
entProto.TryGetComponent(factory.GetComponentName(typeof(StackComponent)), out stack);
});

if (stack == null)
continue;
}

toRemove.Add(id);
toAdd.Add((stackComp.StackTypeId, quantity));
toAdd.Add((stack.StackTypeId, quantity));
}

foreach (var id in toRemove)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
using System.Numerics;
using System.Reflection;
using Content.Client.Construction;
using Content.Server.Atmos;
using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Construction.Components;
using Content.Server.Gravity;
using Content.Server.Item;
using Content.Server.Power.Components;
using Content.Shared.Atmos;
using Content.Shared.Construction.Prototypes;
Expand Down Expand Up @@ -634,7 +631,7 @@ protected async Task AssertEntityLookup(
var entities = await DoEntityLookup(flags);
var found = ToEntityCollection(entities);
expected.Remove(found);
expected.ConvertToStacks(ProtoMan, Factory);
await expected.ConvertToStacks(ProtoMan, Factory, Server);

if (expected.Entities.Count == 0)
return;
Expand Down Expand Up @@ -670,7 +667,7 @@ protected async Task<EntityUid> FindEntity(
LookupFlags flags = LookupFlags.Uncontained | LookupFlags.Contained,
bool shouldSucceed = true)
{
spec.ConvertToStack(ProtoMan, Factory);
await spec.ConvertToStack(ProtoMan, Factory, Server);

var entities = await DoEntityLookup(flags);
foreach (var uid in entities)
Expand Down
55 changes: 35 additions & 20 deletions Content.IntegrationTests/Tests/StorageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,32 @@ public async Task TestSufficientSpaceForFill()
var allSizes = protoMan.EnumeratePrototypes<ItemSizePrototype>().ToList();
allSizes.Sort();

Assert.Multiple(() =>
await Assert.MultipleAsync(async () =>
{
foreach (var proto in pair.GetPrototypesWithComponent<StorageFillComponent>())
{
if (proto.HasComponent<EntityStorageComponent>(compFact))
continue;

if (!proto.TryGetComponent<StorageComponent>("Storage", out var storage))
StorageComponent? storage = null;
ItemComponent? item = null;
StorageFillComponent fill = default!;
var size = 0;
await server.WaitAssertion(() =>
{
Assert.Fail($"Entity {proto.ID} has storage-fill without a storage component!");
continue;
}
if (!proto.TryGetComponent("Storage", out storage))
{
Assert.Fail($"Entity {proto.ID} has storage-fill without a storage component!");
return;
}

proto.TryGetComponent<ItemComponent>("Item", out var item);
proto.TryGetComponent("Item", out item);
fill = (StorageFillComponent) proto.Components[id].Component;
size = GetFillSize(fill, false, protoMan, itemSys);
});

var fill = (StorageFillComponent) proto.Components[id].Component;
var size = GetFillSize(fill, false, protoMan, itemSys);
if (storage == null)
continue;

var maxSize = storage.MaxItemSize;
if (storage.MaxItemSize == null)
Expand Down Expand Up @@ -138,7 +147,13 @@ public async Task TestSufficientSpaceForFill()
if (!protoMan.TryIndex<EntityPrototype>(entry.PrototypeId, out var fillItem))
continue;

if (!fillItem.TryGetComponent<ItemComponent>("Item", out var entryItem))
ItemComponent? entryItem = null;
await server.WaitPost(() =>
{
fillItem.TryGetComponent("Item", out entryItem);
});

if (entryItem == null)
continue;

Assert.That(protoMan.Index(entryItem.Size).Weight,
Expand All @@ -164,25 +179,25 @@ public async Task TestSufficientSpaceForEntityStorageFill()

var itemSys = entMan.System<SharedItemSystem>();

Assert.Multiple(() =>
foreach (var proto in pair.GetPrototypesWithComponent<StorageFillComponent>())
{
foreach (var proto in pair.GetPrototypesWithComponent<StorageFillComponent>())
{
if (proto.HasComponent<StorageComponent>(compFact))
continue;
if (proto.HasComponent<StorageComponent>(compFact))
continue;

if (!proto.TryGetComponent<EntityStorageComponent>("EntityStorage", out var entStorage))
{
await server.WaitAssertion(() =>
{
if (!proto.TryGetComponent("EntityStorage", out EntityStorageComponent? entStorage))
Assert.Fail($"Entity {proto.ID} has storage-fill without a storage component!");
continue;
}

if (entStorage == null)
return;

var fill = (StorageFillComponent) proto.Components[id].Component;
var size = GetFillSize(fill, true, protoMan, itemSys);
Assert.That(size, Is.LessThanOrEqualTo(entStorage.Capacity),
$"{proto.ID} storage fill is too large.");
}
});
});
}
await pair.CleanReturnAsync();
}

Expand Down
11 changes: 9 additions & 2 deletions Content.Server/Salvage/Expeditions/SalvageExpeditionComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,21 @@ public sealed partial class SalvageExpeditionComponent : SharedSalvageExpedition
/// <summary>
/// Countdown audio stream.
/// </summary>
[DataField, AutoNetworkedField]
public EntityUid? Stream = null;

/// <summary>
/// Sound that plays when the mission end is imminent.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("sound")]
public SoundSpecifier Sound = new SoundPathSpecifier("/Audio/Misc/tension_session.ogg")
[ViewVariables(VVAccess.ReadWrite), DataField]
public SoundSpecifier Sound = new SoundCollectionSpecifier("ExpeditionEnd")
{
Params = AudioParams.Default.WithVolume(-5),
};

/// <summary>
/// Song selected on MapInit so we can predict the audio countdown properly.
/// </summary>
[DataField]
public SoundPathSpecifier SelectedSong;
}
9 changes: 9 additions & 0 deletions Content.Server/Salvage/SalvageSystem.Expeditions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
using Content.Server.Salvage.Expeditions.Structure;
using Content.Shared.CCVar;
using Content.Shared.Examine;
using Content.Shared.Random.Helpers;
using Content.Shared.Salvage.Expeditions;
using Robust.Shared.Audio;
using Robust.Shared.CPUJob.JobQueues;
using Robust.Shared.CPUJob.JobQueues.Queues;
using Robust.Shared.GameStates;
Expand Down Expand Up @@ -32,6 +34,7 @@ private void InitializeExpeditions()
SubscribeLocalEvent<SalvageExpeditionConsoleComponent, EntParentChangedMessage>(OnSalvageConsoleParent);
SubscribeLocalEvent<SalvageExpeditionConsoleComponent, ClaimSalvageMessage>(OnSalvageClaimMessage);

SubscribeLocalEvent<SalvageExpeditionComponent, MapInitEvent>(OnExpeditionMapInit);
SubscribeLocalEvent<SalvageExpeditionComponent, ComponentShutdown>(OnExpeditionShutdown);
SubscribeLocalEvent<SalvageExpeditionComponent, ComponentGetState>(OnExpeditionGetState);

Expand Down Expand Up @@ -64,6 +67,12 @@ private void SetCooldownChange(float obj)
_cooldown = obj;
}

private void OnExpeditionMapInit(EntityUid uid, SalvageExpeditionComponent component, MapInitEvent args)
{
var selectedFile = _audio.GetSound(component.Sound);
component.SelectedSong = new SoundPathSpecifier(selectedFile, component.Sound.Params);
}

private void OnExpeditionShutdown(EntityUid uid, SalvageExpeditionComponent component, ComponentShutdown args)
{
component.Stream = _audio.Stop(component.Stream);
Expand Down
10 changes: 6 additions & 4 deletions Content.Server/Salvage/SalvageSystem.Runner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,22 @@ private void UpdateRunner()
while (query.MoveNext(out var uid, out var comp))
{
var remaining = comp.EndTime - _timing.CurTime;
var audioLength = _audio.GetAudioLength(comp.SelectedSong.Path.ToString());

if (comp.Stage < ExpeditionStage.FinalCountdown && remaining < TimeSpan.FromSeconds(45))
{
comp.Stage = ExpeditionStage.FinalCountdown;
Dirty(uid, comp);
Announce(uid, Loc.GetString("salvage-expedition-announcement-countdown-seconds", ("duration", TimeSpan.FromSeconds(45).Seconds)));
}
else if (comp.Stage < ExpeditionStage.MusicCountdown && remaining < TimeSpan.FromMinutes(2))
else if (comp.Stream == null && remaining < audioLength)
{
// TODO: Some way to play audio attached to a map for players.
comp.Stream = _audio.PlayGlobal(comp.Sound, Filter.BroadcastMap(Comp<MapComponent>(uid).MapId), true).Value.Entity;
var audio = _audio.PlayPvs(comp.Sound, uid).Value;
comp.Stream = audio.Entity;
_audio.SetMapAudio(audio);
comp.Stage = ExpeditionStage.MusicCountdown;
Dirty(uid, comp);
Announce(uid, Loc.GetString("salvage-expedition-announcement-countdown-minutes", ("duration", TimeSpan.FromMinutes(2).Minutes)));
Announce(uid, Loc.GetString("salvage-expedition-announcement-countdown-minutes", ("duration", audioLength.Minutes)));
}
else if (comp.Stage < ExpeditionStage.Countdown && remaining < TimeSpan.FromMinutes(4))
{
Expand Down
15 changes: 8 additions & 7 deletions Content.Server/Speech/EntitySystems/FrenchAccentSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ public sealed class FrenchAccentSystem : EntitySystem
{
[Dependency] private readonly ReplacementAccentSystem _replacement = default!;

private static readonly Regex RegexTh = new(@"th", RegexOptions.IgnoreCase);
private static readonly Regex RegexStartH = new(@"(?<!\w)h", RegexOptions.IgnoreCase);
private static readonly Regex RegexSpacePunctuation = new(@"(?<=\w\w)[!?;:](?!\w)", RegexOptions.IgnoreCase);

public override void Initialize()
{
base.Initialize();
Expand All @@ -23,17 +27,14 @@ public string Accentuate(string message, FrenchAccentComponent component)

msg = _replacement.ApplyReplacements(msg, "french");

// replaces th with dz
msg = Regex.Replace(msg, @"th", "'z", RegexOptions.IgnoreCase);
// replaces th with dz
msg = RegexTh.Replace(msg, "'z");

// removes the letter h from the start of words.
msg = Regex.Replace(msg, @"(?<!\w)[h]", "'", RegexOptions.IgnoreCase);
msg = RegexStartH.Replace(msg, "'");

// spaces out ! ? : and ;.
msg = Regex.Replace(msg, @"(?<=\w\w)!(?!\w)", " !", RegexOptions.IgnoreCase);
msg = Regex.Replace(msg, @"(?<=\w\w)[?](?!\w)", " ?", RegexOptions.IgnoreCase);
msg = Regex.Replace(msg, @"(?<=\w\w)[;](?!\w)", " ;", RegexOptions.IgnoreCase);
msg = Regex.Replace(msg, @"(?<=\w\w)[:](?!\w)", " :", RegexOptions.IgnoreCase);
msg = RegexSpacePunctuation.Replace(msg, " $&");

return msg;
}
Expand Down
15 changes: 11 additions & 4 deletions Content.Server/Speech/EntitySystems/FrontalLispSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ namespace Content.Server.Speech.EntitySystems;

public sealed class FrontalLispSystem : EntitySystem
{
// @formatter:off
private static readonly Regex RegexUpperTh = new(@"[T]+[Ss]+|[S]+[Cc]+(?=[IiEeYy]+)|[C]+(?=[IiEeYy]+)|[P][Ss]+|([S]+[Tt]+|[T]+)(?=[Ii]+[Oo]+[Uu]*[Nn]*)|[C]+[Hh]+(?=[Ii]*[Ee]*)|[Z]+|[S]+|[X]+(?=[Ee]+)");
private static readonly Regex RegexLowerTh = new(@"[t]+[s]+|[s]+[c]+(?=[iey]+)|[c]+(?=[iey]+)|[p][s]+|([s]+[t]+|[t]+)(?=[i]+[o]+[u]*[n]*)|[c]+[h]+(?=[i]*[e]*)|[z]+|[s]+|[x]+(?=[e]+)");
private static readonly Regex RegexUpperEcks = new(@"[E]+[Xx]+[Cc]*|[X]+");
private static readonly Regex RegexLowerEcks = new(@"[e]+[x]+[c]*|[x]+");
// @formatter:on

public override void Initialize()
{
base.Initialize();
Expand All @@ -16,11 +23,11 @@ private void OnAccent(EntityUid uid, FrontalLispComponent component, AccentGetEv
var message = args.Message;

// handles ts, sc(i|e|y), c(i|e|y), ps, st(io(u|n)), ch(i|e), z, s
message = Regex.Replace(message, @"[T]+[Ss]+|[S]+[Cc]+(?=[IiEeYy]+)|[C]+(?=[IiEeYy]+)|[P][Ss]+|([S]+[Tt]+|[T]+)(?=[Ii]+[Oo]+[Uu]*[Nn]*)|[C]+[Hh]+(?=[Ii]*[Ee]*)|[Z]+|[S]+|[X]+(?=[Ee]+)", "TH");
message = Regex.Replace(message, @"[t]+[s]+|[s]+[c]+(?=[iey]+)|[c]+(?=[iey]+)|[p][s]+|([s]+[t]+|[t]+)(?=[i]+[o]+[u]*[n]*)|[c]+[h]+(?=[i]*[e]*)|[z]+|[s]+|[x]+(?=[e]+)", "th");
message = RegexUpperTh.Replace(message, "TH");
message = RegexLowerTh.Replace(message, "th");
// handles ex(c), x
message = Regex.Replace(message, @"[E]+[Xx]+[Cc]*|[X]+", "EKTH");
message = Regex.Replace(message, @"[e]+[x]+[c]*|[x]+", "ekth");
message = RegexUpperEcks.Replace(message, "EKTH");
message = RegexLowerEcks.Replace(message, "ekth");

args.Message = message;
}
Expand Down
Loading

0 comments on commit 7ede0f6

Please sign in to comment.