Skip to content

Commit

Permalink
Merge branch 'master-ru' of git.arumoon.ru:Workbench-Team/space-stati…
Browse files Browse the repository at this point in the history
…on-14 into arumoon-server
  • Loading branch information
AruMoon committed Jul 31, 2023
2 parents b4b6d02 + 589589e commit 31fd0b9
Show file tree
Hide file tree
Showing 59 changed files with 2,140 additions and 2,304 deletions.
12 changes: 5 additions & 7 deletions Content.Client/Flash/FlashOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public sealed class FlashOverlay : Overlay
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;

public override OverlaySpace Space => OverlaySpace.ScreenSpace;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
private readonly ShaderInstance _shader;
private double _startTime = -1;
private double _lastsFor = 1;
Expand Down Expand Up @@ -61,18 +61,16 @@ protected override void Draw(in OverlayDrawArgs args)
if (percentComplete >= 1.0f)
return;

var screenSpaceHandle = args.ScreenHandle;
screenSpaceHandle.UseShader(_shader);
var worldHandle = args.WorldHandle;
worldHandle.UseShader(_shader);
_shader.SetParameter("percentComplete", percentComplete);

var screenSize = UIBox2.FromDimensions(new Vector2(0, 0), _displayManager.ScreenSize);

if (_screenshotTexture != null)
{
screenSpaceHandle.DrawTextureRect(_screenshotTexture, screenSize);
worldHandle.DrawTextureRectRegion(_screenshotTexture, args.WorldBounds);
}

screenSpaceHandle.UseShader(null);
worldHandle.UseShader(null);
}

protected override void DisposeBehavior()
Expand Down
36 changes: 22 additions & 14 deletions Content.Client/MassMedia/Ui/MiniArticleCardControl.xaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
<Control xmlns="https://spacestation14.io"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client">
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<PanelContainer VerticalExpand="True" HorizontalExpand="True">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#202124" />
</PanelContainer.PanelOverride>
<RichTextLabel Name="Name" Margin="8 8 8 8" HorizontalAlignment="Left"/>
<Button Name="Delete"
MinWidth="30"
HorizontalAlignment="Right"
Text="{Loc 'news-write-ui-delete-text'}"
Access="Public"
Margin="6 6 6 6">
</Button>
</PanelContainer>
<BoxContainer Orientation="Vertical" HorizontalExpand="True" Margin="0 0 0 12">
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" VerticalExpand="True">
<PanelContainer HorizontalExpand="True" VerticalExpand="True">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#4c6530"/>
</PanelContainer.PanelOverride>
<Label Name="Name" Margin="6 6 6 6" HorizontalAlignment="Center"/>
</PanelContainer>
</BoxContainer>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<PanelContainer HorizontalExpand="True" VerticalExpand="True">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#33333f"/>
</PanelContainer.PanelOverride>
<RichTextLabel Name="Author" HorizontalExpand="True" VerticalAlignment="Bottom" Margin="6 6 6 6"/>
<Button Name="Delete"
Text="{Loc 'news-write-ui-delete-text'}"
HorizontalAlignment="Right"
Margin="8 6 6 6"
Access="Public"/>
</PanelContainer>
</BoxContainer>
</BoxContainer>
</Control>
5 changes: 3 additions & 2 deletions Content.Client/MassMedia/Ui/MiniArticleCardControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ public sealed partial class MiniArticleCardControl : Control
public Action? OnDeletePressed;
public int ArtcileNum;

public MiniArticleCardControl(string name)
public MiniArticleCardControl(string name, string author)
{
RobustXamlLoader.Load(this);

Name.SetMarkup(name);
Name.Text = name;
Author.SetMarkup(author);

Delete.OnPressed += _ => OnDeletePressed?.Invoke();
}
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/MassMedia/Ui/NewsWriteMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public void UpdateUI(NewsArticle[] articles, bool shareAvalible)

for (int i = 0; i < articles.Length; i++)
{
var mini = new MiniArticleCardControl(articles[i].Name);
var article = articles[i];
var mini = new MiniArticleCardControl(article.Name, (article.Author != null ? article.Author : Loc.GetString("news-read-ui-no-author")));
mini.ArtcileNum = i;
mini.OnDeletePressed += () => DeleteButtonPressed?.Invoke(mini.ArtcileNum);

Expand Down
4 changes: 4 additions & 0 deletions Content.IntegrationTests/Tests/Body/SaveLoadReparentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,11 @@ await server.WaitAssertion(() =>
Assert.That(component.ParentSlot.Child, Is.EqualTo(id));
});
}
maps.DeleteMap(mapId);
}
});

await pairTracker.CleanReturnAsync();
}
}
1 change: 1 addition & 0 deletions Content.IntegrationTests/Tests/EntityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ await server.WaitAssertion(() =>
// such as MetaData or Transform
if (entityManager.HasComponent(entity, type))
{
entityManager.DeleteEntity(entity);
continue;
}
Expand Down
2 changes: 2 additions & 0 deletions Content.IntegrationTests/Tests/LogErrorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ public async Task TestLogErrorCausesTestFailure()
// But errors do
await server.WaitPost(() => Assert.Throws<AssertionException>(() => logmill.Error("test")));
await client.WaitPost(() => Assert.Throws<AssertionException>(() => logmill.Error("test")));

await pairTracker.CleanReturnAsync();
}
}
2 changes: 2 additions & 0 deletions Content.IntegrationTests/Tests/Networking/ConnectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public async Task TestConnect()

Assert.That(clEntityManager.GetComponent<TransformComponent>(lastSvEntity).Coordinates,
Is.EqualTo(svEntityManager.GetComponent<TransformComponent>(lastSvEntity).Coordinates));

await pairTracker.CleanReturnAsync();
}
}
}
82 changes: 82 additions & 0 deletions Content.IntegrationTests/Tests/Serialization/SerializationTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using System.Collections.Generic;
using System.Linq;
using Robust.Shared.Reflection;
using Robust.Shared.Serialization.Manager;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Serialization.Markdown.Value;

namespace Content.IntegrationTests.Tests.Serialization;

[TestFixture]
public sealed class SerializationTest
{
/// <summary>
/// Check that serializing generic enums works as intended. This should really be in engine, but engine
/// integrations tests block reflection and I am lazy..
/// </summary>
[Test]
public async Task SerializeGenericEnums()
{
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
var server = pairTracker.Pair.Server;
var seriMan = server.ResolveDependency<ISerializationManager>();
var refMan = server.ResolveDependency<IReflectionManager>();

Enum value = TestEnum.Bb;

var node = seriMan.WriteValue(value, notNullableOverride:true);
var valueNode = node as ValueDataNode;
Assert.NotNull(valueNode);

var expected = refMan.GetEnumReference(value);
Assert.That(valueNode!.Value, Is.EqualTo(expected));

var errors = seriMan.ValidateNode<Enum>(valueNode).GetErrors();
Assert.That(errors.Any(), Is.False);

var deserialized = seriMan.Read<Enum>(node, notNullableOverride:true);
Assert.That(deserialized, Is.EqualTo(value));

// Repeat test with enums in a data definitions.
var data = new TestData
{
Value = TestEnum.Cc,
Sequence = new() {TestEnum.Dd, TestEnum.Aa}
};

node = seriMan.WriteValue(data, notNullableOverride:true);

errors = seriMan.ValidateNode<TestData>(node).GetErrors();
Assert.That(errors.Any(), Is.False);

var deserializedData = seriMan.Read<TestData>(node, notNullableOverride:false);

Assert.That(deserializedData.Value, Is.EqualTo(data.Value));
Assert.That(deserializedData.Sequence.Count, Is.EqualTo(data.Sequence.Count));
Assert.That(deserializedData.Sequence[0], Is.EqualTo(data.Sequence[0]));
Assert.That(deserializedData.Sequence[1], Is.EqualTo(data.Sequence[1]));

// Check that Generic & non-generic serializers are incompativle.
Enum genericValue = TestEnum.Bb;
TestEnum typedValue = TestEnum.Bb;

var genericNode = seriMan.WriteValue(genericValue, notNullableOverride:true);
var typedNode = seriMan.WriteValue(typedValue);

Assert.That(seriMan.ValidateNode<Enum>(genericNode).GetErrors().Any(), Is.False);
Assert.That(seriMan.ValidateNode<TestEnum>(genericNode).GetErrors().Any(), Is.True);
Assert.That(seriMan.ValidateNode<Enum>(typedNode).GetErrors().Any(), Is.True);
Assert.That(seriMan.ValidateNode<TestEnum>(typedNode).GetErrors().Any(), Is.False);

await pairTracker.CleanReturnAsync();
}

private enum TestEnum : byte { Aa, Bb, Cc, Dd }

[DataDefinition]
private sealed class TestData
{
[DataField("value")] public Enum Value = default!;
[DataField("sequence")] public List<Enum> Sequence = default!;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,15 @@ private void OnPassiveVentUpdated(EntityUid uid, GasPassiveVentComponent vent, A
if (!_nodeContainer.TryGetNode(nodeContainer, vent.InletName, out PipeNode? inlet))
return;

var environmentPressure = environment.Pressure;
var pressureDelta = MathF.Abs(environmentPressure - inlet.Air.Pressure);

if ((environment.Temperature > 0 || inlet.Air.Temperature > 0) && pressureDelta > 0.5f)
{
if (environmentPressure < inlet.Air.Pressure)
{
var airTemperature = environment.Temperature > 0 ? environment.Temperature : inlet.Air.Temperature;
var transferMoles = pressureDelta * environment.Volume / (airTemperature * Atmospherics.R);
var removed = inlet.Air.Remove(transferMoles);
_atmosphereSystem.Merge(environment, removed);
}
else
{
var airTemperature = inlet.Air.Temperature > 0 ? inlet.Air.Temperature : environment.Temperature;
var outputVolume = inlet.Air.Volume;
var transferMoles = (pressureDelta * outputVolume) / (airTemperature * Atmospherics.R);
transferMoles = MathF.Min(transferMoles, environment.TotalMoles * inlet.Air.Volume / environment.Volume);
var removed = environment.Remove(transferMoles);
_atmosphereSystem.Merge(inlet.Air, removed);
}
}
var inletAir = inlet.Air.RemoveRatio(1f);
var envAir = environment.RemoveRatio(1f);

var mergeAir = new GasMixture(inletAir.Volume + envAir.Volume);
_atmosphereSystem.Merge(mergeAir, inletAir);
_atmosphereSystem.Merge(mergeAir, envAir);

_atmosphereSystem.Merge(inlet.Air, mergeAir.RemoveVolume(inletAir.Volume));
_atmosphereSystem.Merge(environment, mergeAir);
}
}
}
65 changes: 64 additions & 1 deletion Content.Server/Body/Systems/BodySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
using Content.Server.Humanoid;
using Content.Server.Kitchen.Components;
using Content.Server.Mind;
using Content.Server.Mind.Components;
using Content.Shared.Body.Components;
using Content.Shared.Body.Organ;
using Content.Shared.Body.Part;
using Content.Shared.Body.Prototypes;
using Content.Shared.Body.Systems;
Expand Down Expand Up @@ -36,11 +36,74 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<BodyPartComponent, ComponentStartup>(OnPartStartup);
SubscribeLocalEvent<BodyComponent, ComponentStartup>(OnBodyStartup);
SubscribeLocalEvent<BodyComponent, MoveInputEvent>(OnRelayMoveInput);
SubscribeLocalEvent<BodyComponent, ApplyMetabolicMultiplierEvent>(OnApplyMetabolicMultiplier);
SubscribeLocalEvent<BodyComponent, BeingMicrowavedEvent>(OnBeingMicrowaved);
}

private void OnPartStartup(EntityUid uid, BodyPartComponent component, ComponentStartup args)
{
// This inter-entity relationship makes be deeply uncomfortable because its probably going to re-encounter
// all of the networking & startup ordering issues that containers and joints have.
// TODO just use containers. Please.

foreach (var slot in component.Children.Values)
{
DebugTools.Assert(slot.Parent == uid);
if (slot.Child == null)
continue;

if (TryComp(slot.Child, out BodyPartComponent? child))
{
child.ParentSlot = slot;
Dirty(slot.Child.Value);
continue;
}

Log.Error($"Body part encountered missing limbs: {ToPrettyString(uid)}. Slot: {slot.Id}");
slot.Child = null;
}

foreach (var slot in component.Organs.Values)
{
DebugTools.Assert(slot.Parent == uid);
if (slot.Child == null)
continue;

if (TryComp(slot.Child, out OrganComponent? child))
{
child.ParentSlot = slot;
Dirty(slot.Child.Value);
continue;
}

Log.Error($"Body part encountered missing organ: {ToPrettyString(uid)}. Slot: {slot.Id}");
slot.Child = null;
}
}

private void OnBodyStartup(EntityUid uid, BodyComponent component, ComponentStartup args)
{
if (component.Root is not { } slot)
return;

DebugTools.Assert(slot.Parent == uid);
if (slot.Child == null)
return;

if (!TryComp(slot.Child, out BodyPartComponent? child))
{
Log.Error($"Body part encountered missing limbs: {ToPrettyString(uid)}. Slot: {slot.Id}");
slot.Child = null;
return;
}

child.ParentSlot = slot;
Dirty(slot.Child.Value);
}

private void OnRelayMoveInput(EntityUid uid, BodyComponent component, ref MoveInputEvent args)
{
if (_mobState.IsDead(uid) && _mindSystem.TryGetMind(uid, out var mind))
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ private void OnPlayersSpawning(RulePlayerSpawningEvent ev)
}
}

var numNukies = MathHelper.Clamp(ev.PlayerPool.Count / playersPerOperative, 1, maxOperatives);
var numNukies = MathHelper.Clamp(_playerSystem.PlayerCount / playersPerOperative, 1, maxOperatives);

for (var i = 0; i < numNukies; i++)
{
Expand Down
6 changes: 6 additions & 0 deletions Content.Server/MassMedia/Components/NewsWriteComponent.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Robust.Shared.Audio;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;

namespace Content.Server.MassMedia.Components
Expand All @@ -13,5 +14,10 @@ public sealed class NewsWriteComponent : Component

[ViewVariables(VVAccess.ReadWrite), DataField("shareCooldown")]
public float ShareCooldown = 60f;

[DataField("noAccessSound")]
public SoundSpecifier NoAccessSound = new SoundPathSpecifier("/Audio/Machines/airlock_deny.ogg");
[DataField("confirmSound")]
public SoundSpecifier ConfirmSound = new SoundPathSpecifier("/Audio/Machines/scan_finish.ogg");
}
}
Loading

0 comments on commit 31fd0b9

Please sign in to comment.