Skip to content

Commit

Permalink
Merge pull request space-wizards#571 from space-syndicate/upstream-sync
Browse files Browse the repository at this point in the history
Upstream sync
  • Loading branch information
Morb0 authored Nov 21, 2022
2 parents 6a2e25a + c6cec67 commit 0011165
Show file tree
Hide file tree
Showing 108 changed files with 2,287 additions and 216,529 deletions.
33 changes: 33 additions & 0 deletions Content.Client/Implants/ImplanterSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Content.Client.Implants.UI;
using Content.Client.Items;
using Content.Shared.Implants;
using Content.Shared.Implants.Components;
using Robust.Shared.GameStates;

namespace Content.Client.Implants;

public sealed class ImplanterSystem : SharedImplanterSystem
{
public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<ImplanterComponent, ComponentHandleState>(OnHandleImplanterState);
SubscribeLocalEvent<ImplanterComponent, ItemStatusCollectMessage>(OnItemImplanterStatus);
}

private void OnHandleImplanterState(EntityUid uid, ImplanterComponent component, ref ComponentHandleState args)
{
if (args.Current is not ImplanterComponentState state)
return;

component.CurrentMode = state.CurrentMode;
component.ImplantOnly = state.ImplantOnly;
component.UiUpdateNeeded = true;
}

private void OnItemImplanterStatus(EntityUid uid, ImplanterComponent component, ItemStatusCollectMessage args)
{
args.Controls.Add(new ImplanterStatusControl(component));
}
}
53 changes: 53 additions & 0 deletions Content.Client/Implants/UI/ImplanterStatusControl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Content.Client.Message;
using Content.Client.Stylesheets;
using Content.Shared.Implants.Components;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Timing;

namespace Content.Client.Implants.UI;

public sealed class ImplanterStatusControl : Control
{
private readonly ImplanterComponent _parent;
private readonly RichTextLabel _label;

public ImplanterStatusControl(ImplanterComponent parent)
{
_parent = parent;
_label = new RichTextLabel { StyleClasses = { StyleNano.StyleClassItemStatus } };
AddChild(_label);

Update();
}

protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);
if (!_parent.UiUpdateNeeded)
return;

Update();
}

private void Update()
{
_parent.UiUpdateNeeded = false;

var modeStringLocalized = _parent.CurrentMode switch
{
ImplanterToggleMode.Draw => Loc.GetString("implanter-draw-text"),
ImplanterToggleMode.Inject => Loc.GetString("implanter-inject-text"),
_ => Loc.GetString("injector-invalid-injector-toggle-mode")
};

var entitiesStringLocalized = _parent.ImplanterSlot.HasItem switch
{
false => Loc.GetString("implanter-empty-text"),
true => Loc.GetString("implanter-implant-text", ("implantName", _parent.ImplantData.Item1), ("implantDescription", _parent.ImplantData.Item2), ("lineBreak", "\n")),
};


_label.SetMarkup(Loc.GetString("implanter-label", ("currentEntities", entitiesStringLocalized), ("modeString", modeStringLocalized), ("lineBreak", "\n")));
}
}
80 changes: 10 additions & 70 deletions Content.Client/Xenoarchaeology/Ui/AnalysisConsoleMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Controls;
using Content.Shared.Xenoarchaeology.Equipment;
using Content.Shared.Xenoarchaeology.XenoArtifacts;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;

namespace Content.Client.Xenoarchaeology.Ui;
Expand All @@ -15,7 +13,6 @@ namespace Content.Client.Xenoarchaeology.Ui;
public sealed partial class AnalysisConsoleMenu : FancyWindow
{
[Dependency] private readonly IEntityManager _ent = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;

public AnalysisDestroyWindow? AnalysisDestroyWindow;

Expand Down Expand Up @@ -73,7 +70,7 @@ public void SetButtonsDisabled(AnalysisConsoleScanUpdateState state)
}
}

public void UpdateArtifactIcon(EntityUid? uid)
private void UpdateArtifactIcon(EntityUid? uid)
{
if (uid == null)
{
Expand All @@ -100,75 +97,18 @@ public void UpdateInformationDisplay(AnalysisConsoleScanUpdateState state)
return;
}

//do this here
UpdateArtifactIcon(state.Artifact);

if (state.Artifact == null)//no scan present
{
if (!state.AnalyzerConnected) //no analyzer connected
message.AddMarkup(Loc.GetString("analysis-console-info-no-scanner"));
else if (!state.CanScan) //no artifact
message.AddMarkup(Loc.GetString("analysis-console-info-no-artifact"));
else if (state.Artifact == null) //ready to go
message.AddMarkup(Loc.GetString("analysis-console-info-ready"));
}

if (state.Id != null) //node id
{
message.AddMarkup(Loc.GetString("analysis-console-info-id", ("id", state.Id)));
message.PushNewline();
}
if (state.Depth != null) //node depth
{
message.AddMarkup(Loc.GetString("analysis-console-info-depth", ("depth", state.Depth)));
message.PushNewline();
}

if (state.Triggered != null) //whether it has been triggered
{
var activated = state.Triggered.Value
? "analysis-console-info-triggered-true"
: "analysis-console-info-triggered-false";
message.AddMarkup(Loc.GetString(activated));
message.PushNewline();
}
if (!state.AnalyzerConnected) //no analyzer connected
message.AddMarkup(Loc.GetString("analysis-console-info-no-scanner"));
else if (!state.CanScan) //no artifact
message.AddMarkup(Loc.GetString("analysis-console-info-no-artifact"));
else if (state.Artifact == null) //ready to go
message.AddMarkup(Loc.GetString("analysis-console-info-ready"));

message.PushNewline();
var needSecondNewline = false;

if (state.TriggerProto != null && //possible triggers
_proto.TryIndex<ArtifactTriggerPrototype>(state.TriggerProto, out var trigger) &&
trigger.TriggerHint != null)
{
message.AddMarkup(Loc.GetString("analysis-console-info-trigger",
("trigger", Loc.GetString(trigger.TriggerHint))));
message.PushNewline();
needSecondNewline = true;
}

if (state.EffectProto != null && //possible effects
_proto.TryIndex<ArtifactEffectPrototype>(state.EffectProto, out var effect) &&
effect.EffectHint != null)
{
message.AddMarkup(Loc.GetString("analysis-console-info-effect",
("effect", Loc.GetString(effect.EffectHint))));
message.PushNewline();
needSecondNewline = true;
}
UpdateArtifactIcon(state.Artifact);

if (needSecondNewline)
message.PushNewline();
if (state.ScanReport != null)
message.AddMessage(state.ScanReport);

if (state.Edges != null) //number of edges
{
message.AddMarkup(Loc.GetString("analysis-console-info-edges", ("edges", state.Edges)));
message.PushNewline();
}
if (state.PointValue != null) //completion percentage
{
message.AddMarkup(Loc.GetString("analysis-console-info-value", ("value", state.PointValue)));
message.PushNewline();
}
Information.SetMessage(message);
}

Expand Down
4 changes: 2 additions & 2 deletions Content.IntegrationTests/Tests/SaveLoadSaveTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ await server.WaitPost(() =>
/// Loads the default map, runs it for 5 ticks, then assert that it did not change.
/// </summary>
[Test]
public async Task LoadSaveTicksSaveSaltern()
public async Task LoadSaveTicksSaveBagel()
{
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true});
var server = pairTracker.Pair.Server;
Expand All @@ -97,7 +97,7 @@ public async Task LoadSaveTicksSaveSaltern()
mapId = mapManager.CreateMap();
mapManager.AddUninitializedMap(mapId);
mapManager.SetMapPaused(mapId, true);
mapLoader.LoadMap(mapId, "Maps/saltern.yml");
mapLoader.LoadMap(mapId, "Maps/bagel.yml");
mapLoader.SaveMap(mapId, "load save ticks save 1.yml");
});

Expand Down
1 change: 1 addition & 0 deletions Content.MapRenderer/Content.MapRenderer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<OutputPath>..\bin\Content.MapRenderer\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<Nullable>enable</Nullable>
<ServerGarbageCollection>true</ServerGarbageCollection>
</PropertyGroup>

<ItemGroup>
Expand Down
18 changes: 17 additions & 1 deletion Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,17 @@ private void UpdateChunkTile(GridAtmosphereComponent gridAtmosphere, GasOverlayC
return;
}

var changed = oldData.Equals(default) || oldData.FireState != tile.Hotspot.State;
var changed = false;
if (oldData.Equals(default))
{
changed = true;
oldData = new GasOverlayData(tile.Hotspot.State, new byte[VisibleGasId.Length]);
}
else if (oldData.FireState != tile.Hotspot.State)
{
changed = true;
oldData = new GasOverlayData(tile.Hotspot.State, oldData.Opacity);
}

if (tile.Air != null)
{
Expand Down Expand Up @@ -166,6 +174,14 @@ private void UpdateChunkTile(GridAtmosphereComponent gridAtmosphere, GasOverlayC
changed = true;
}
}
else
{
for (var i = 0; i < VisibleGasId.Length; i++)
{
changed |= oldData.Opacity[i] != 0;
oldData.Opacity[i] = 0;
}
}

if (!changed)
return;
Expand Down
15 changes: 11 additions & 4 deletions Content.Server/Body/Systems/BodySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ protected override void InitBody(BodyComponent body, BodyPrototype prototype)
InitPart(partComponent, prototype, prototype.Root);
}

public override HashSet<EntityUid> GibBody(EntityUid? bodyId, bool gibOrgans = false, BodyComponent? body = null)
public override HashSet<EntityUid> GibBody(EntityUid? bodyId, bool gibOrgans = false, BodyComponent? body = null, bool deleteItems = false)
{
if (bodyId == null || !Resolve(bodyId.Value, ref body, false))
return new HashSet<EntityUid>();
Expand All @@ -150,9 +150,16 @@ public override HashSet<EntityUid> GibBody(EntityUid? bodyId, bool gibOrgans = f
{
foreach (var ent in cont.ContainedEntities)
{
cont.ForceRemove(ent);
Transform(ent).Coordinates = coordinates;
ent.RandomOffset(0.25f);
if (deleteItems)
{
QueueDel(ent);
}
else
{
cont.ForceRemove(ent);
Transform(ent).Coordinates = coordinates;
ent.RandomOffset(0.25f);
}
}
}
}
Expand Down
44 changes: 30 additions & 14 deletions Content.Server/Chat/SuicideSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,27 @@ public bool Suicide(EntityUid victim)
{
// Checks to see if the CannotSuicide tag exits, ghosts instead.
if (_tagSystem.HasTag(victim, "CannotSuicide"))
{
return false;
}

// Checks to see if the player is dead.
if (!TryComp<MobStateComponent>(victim, out var mobState) || _mobState.IsDead(victim, mobState))
{
return false;
}

_adminLogger.Add(LogType.Suicide,
$"{EntityManager.ToPrettyString(victim):player} is committing suicide");
_adminLogger.Add(LogType.Suicide, $"{EntityManager.ToPrettyString(victim):player} is committing suicide");

var suicideEvent = new SuicideEvent(victim);

//Check to see if there were any systems blocking this suicide
if (SuicideAttemptBlocked(victim, suicideEvent))
return false;

// If you are critical, you wouldn't be able to use your surroundings to suicide, so you do the default suicide
if (!_mobState.IsCritical(victim, mobState))
{
EnvironmentSuicideHandler(victim, suicideEvent);
}

if (suicideEvent.AttemptBlocked)
return false;

DefaultSuicideHandler(victim, suicideEvent);

ApplyDeath(victim, suicideEvent.Kind!.Value);
Expand All @@ -58,7 +59,9 @@ public bool Suicide(EntityUid victim)
/// </summary>
private static void DefaultSuicideHandler(EntityUid victim, SuicideEvent suicideEvent)
{
if (suicideEvent.Handled) return;
if (suicideEvent.Handled)
return;

var othersMessage = Loc.GetString("suicide-command-default-text-others", ("name", victim));
victim.PopupMessageOtherClients(othersMessage);

Expand All @@ -68,10 +71,26 @@ private static void DefaultSuicideHandler(EntityUid victim, SuicideEvent suicide
}

/// <summary>
/// Raise event to attempt to use held item, or surrounding entities to commit suicide
/// Checks to see if there are any other systems that prevent suicide
/// </summary>
/// <returns>Returns true if there was a blocked attempt</returns>
private bool SuicideAttemptBlocked(EntityUid victim, SuicideEvent suicideEvent)
{
RaiseLocalEvent(victim, suicideEvent, false);

if (suicideEvent.AttemptBlocked)
return true;

return false;
}

/// <summary>
/// Raise event to attempt to use held item, or surrounding entities to attempt to commit suicide
/// </summary>
private void EnvironmentSuicideHandler(EntityUid victim, SuicideEvent suicideEvent)
{
var itemQuery = GetEntityQuery<ItemComponent>();

// Suicide by held item
if (EntityManager.TryGetComponent(victim, out HandsComponent? handsComponent)
&& handsComponent.ActiveHandEntity is { } item)
Expand All @@ -82,8 +101,6 @@ private void EnvironmentSuicideHandler(EntityUid victim, SuicideEvent suicideEve
return;
}

var itemQuery = GetEntityQuery<ItemComponent>();

// Suicide by nearby entity (ex: Microwave)
foreach (var entity in _entityLookupSystem.GetEntitiesInRange(victim, 1, LookupFlags.Approximate | LookupFlags.Anchored))
{
Expand All @@ -106,8 +123,7 @@ private void ApplyDeath(EntityUid target, SuicideKind kind)
if (!_prototypeManager.TryIndex<DamageTypePrototype>(kind.ToString(), out var damagePrototype))
{
const SuicideKind fallback = SuicideKind.Blunt;
Logger.Error(
$"{nameof(SuicideSystem)} could not find the damage type prototype associated with {kind}. Falling back to {fallback}");
Logger.Error($"{nameof(SuicideSystem)} could not find the damage type prototype associated with {kind}. Falling back to {fallback}");
damagePrototype = _prototypeManager.Index<DamageTypePrototype>(fallback.ToString());
}
const int lethalAmountOfDamage = 200; // TODO: Would be nice to get this number from somewhere else
Expand Down
Loading

0 comments on commit 0011165

Please sign in to comment.