Skip to content

Commit

Permalink
Merge pull request space-syndicate#2587 from space-syndicate/upstream…
Browse files Browse the repository at this point in the history
…-sync

Upstream sync
  • Loading branch information
Morb0 authored Sep 13, 2024
2 parents 13d399b + ca32f59 commit 2a448a9
Show file tree
Hide file tree
Showing 77 changed files with 924 additions and 662 deletions.
2 changes: 1 addition & 1 deletion Content.Client/VendingMachines/UI/VendingMachineItem.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
SeparationOverride="4">
<EntityPrototypeView
Name="ItemPrototype"
Margin="4 4"
Margin="4 0 0 0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
MinSize="32 32"
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/VendingMachines/UI/VendingMachineMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:co="clr-namespace:Content.Client.UserInterface.Controls">
<BoxContainer Name="MainContainer" Orientation="Vertical">
<LineEdit Name="SearchBar" PlaceHolder="{Loc 'vending-machine-component-search-filter'}" HorizontalExpand="True" Margin ="4 4"/>
<co:SearchListContainer Name="VendingContents" VerticalExpand="True" Margin="4 0"/>
<co:SearchListContainer Name="VendingContents" VerticalExpand="True" Margin="4 4"/>
<!-- Footer -->
<BoxContainer Orientation="Vertical">
<PanelContainer StyleClasses="LowDivider" />
Expand Down
48 changes: 26 additions & 22 deletions Content.Client/Verbs/VerbSystem.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Numerics;
using Content.Client.Examine;
using Content.Client.Gameplay;
using Content.Client.Popups;
using Content.Shared.Examine;
using Content.Shared.Tag;
using Content.Shared.Verbs;
using JetBrains.Annotations;
using Robust.Client.ComponentTrees;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
Expand All @@ -21,25 +23,26 @@ public sealed class VerbSystem : SharedVerbSystem
{
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly ExamineSystem _examine = default!;
[Dependency] private readonly SpriteTreeSystem _tree = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;

/// <summary>
/// When a user right clicks somewhere, how large is the box we use to get entities for the context menu?
/// </summary>
public const float EntityMenuLookupSize = 0.25f;

[Dependency] private readonly IEyeManager _eyeManager = default!;

/// <summary>
/// These flags determine what entities the user can see on the context menu.
/// </summary>
public MenuVisibility Visibility;

public Action<VerbsResponseEvent>? OnVerbsResponse;

private List<EntityUid> _entities = new();

public override void Initialize()
{
base.Initialize();
Expand Down Expand Up @@ -76,49 +79,50 @@ public bool TryGetEntityMenuEntities(MapCoordinates targetPos, [NotNullWhen(true
visibility = ev.Visibility;

// Get entities
List<EntityUid> entities;
var examineFlags = LookupFlags.All & ~LookupFlags.Sensors;
_entities.Clear();
var entitiesUnderMouse = _tree.QueryAabb(targetPos.MapId, Box2.CenteredAround(targetPos.Position, new Vector2(EntityMenuLookupSize, EntityMenuLookupSize)));

// Do we have to do FoV checks?
if ((visibility & MenuVisibility.NoFov) == 0)
{
var entitiesUnderMouse = gameScreenBase.GetClickableEntities(targetPos).ToHashSet();
bool Predicate(EntityUid e) => e == player || entitiesUnderMouse.Contains(e);
bool Predicate(EntityUid e) => e == player;

TryComp(player.Value, out ExaminerComponent? examiner);

entities = new();
foreach (var ent in _entityLookup.GetEntitiesInRange(targetPos, EntityMenuLookupSize, flags: examineFlags))
foreach (var ent in entitiesUnderMouse)
{
if (_examine.CanExamine(player.Value, targetPos, Predicate, ent, examiner))
entities.Add(ent);
if (_examine.CanExamine(player.Value, targetPos, Predicate, ent.Uid, examiner))
_entities.Add(ent.Uid);
}
}
else
{
entities = _entityLookup.GetEntitiesInRange(targetPos, EntityMenuLookupSize, flags: examineFlags).ToList();
foreach (var ent in entitiesUnderMouse)
{
_entities.Add(ent.Uid);
}
}

if (entities.Count == 0)
if (_entities.Count == 0)
return false;

if (visibility == MenuVisibility.All)
{
result = entities;
result = new (_entities);
return true;
}

// remove any entities in containers
if ((visibility & MenuVisibility.InContainer) == 0)
{
for (var i = entities.Count - 1; i >= 0; i--)
for (var i = _entities.Count - 1; i >= 0; i--)
{
var entity = entities[i];
var entity = _entities[i];

if (ContainerSystem.IsInSameOrTransparentContainer(player.Value, entity))
continue;

entities.RemoveSwap(i);
_entities.RemoveSwap(i);
}
}

Expand All @@ -127,23 +131,23 @@ public bool TryGetEntityMenuEntities(MapCoordinates targetPos, [NotNullWhen(true
{
var spriteQuery = GetEntityQuery<SpriteComponent>();

for (var i = entities.Count - 1; i >= 0; i--)
for (var i = _entities.Count - 1; i >= 0; i--)
{
var entity = entities[i];
var entity = _entities[i];

if (!spriteQuery.TryGetComponent(entity, out var spriteComponent) ||
!spriteComponent.Visible ||
_tagSystem.HasTag(entity, "HideContextMenu"))
{
entities.RemoveSwap(i);
_entities.RemoveSwap(i);
}
}
}

if (entities.Count == 0)
if (_entities.Count == 0)
return false;

result = entities;
result = new(_entities);
return true;
}

Expand Down
6 changes: 3 additions & 3 deletions Content.Server/Anomaly/Effects/TechAnomalySystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public override void Update(float frameTime)
while (query.MoveNext(out var uid, out var tech, out var anom))
{
if (_timing.CurTime < tech.NextTimer)
return;
continue;

tech.NextTimer = _timing.CurTime + TimeSpan.FromSeconds(tech.TimerFrequency * anom.Stability);
tech.NextTimer += TimeSpan.FromSeconds(tech.TimerFrequency * anom.Stability);

_signal.InvokePort(uid, tech.TimerPort);
}
Expand All @@ -61,7 +61,7 @@ private void CreateNewRandomLink(Entity<TechAnomalyComponent> tech, int count)
var devices = _lookup.GetEntitiesInRange<DeviceLinkSinkComponent>(Transform(tech).Coordinates, range);
if (devices.Count < 1)
return;

for (var i = 0; i < count; i++)
{
var device = _random.Pick(devices);
Expand Down
7 changes: 7 additions & 0 deletions Content.Server/Body/Components/BloodstreamComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ public sealed partial class BloodstreamComponent : Component
[DataField]
public SoundSpecifier BloodHealedSound = new SoundPathSpecifier("/Audio/Effects/lightburn.ogg");

/// <summary>
/// The minimum amount damage reduction needed to play the healing sound/popup.
/// This prevents tiny amounts of heat damage from spamming the sound, e.g. spacing.
/// </summary>
[DataField]
public float BloodHealedSoundThreshold = -0.1f;

// TODO probably damage bleed thresholds.

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Body/Systems/BloodstreamSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ private void OnDamageChanged(Entity<BloodstreamComponent> ent, ref DamageChanged
}

// Heat damage will cauterize, causing the bleed rate to be reduced.
else if (totalFloat < 0 && oldBleedAmount > 0)
else if (totalFloat <= ent.Comp.BloodHealedSoundThreshold && oldBleedAmount > 0)
{
// Magically, this damage has healed some bleeding, likely
// because it's burn damage that cauterized their wounds.
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/EntityEffects/Effects/ActivateArtifact.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public sealed partial class ActivateArtifact : EntityEffect
public override void Effect(EntityEffectBaseArgs args)
{
var artifact = args.EntityManager.EntitySysManager.GetEntitySystem<ArtifactSystem>();
artifact.TryActivateArtifact(args.TargetEntity);
artifact.TryActivateArtifact(args.TargetEntity, logMissing: false);
}

protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) =>
Expand Down
14 changes: 7 additions & 7 deletions Content.Server/Forensics/Systems/ForensicPadSystem.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Inventory;
using Content.Server.Labels;
using Content.Server.Popups;
using Content.Shared.DoAfter;
using Content.Shared.Examine;
using Content.Shared.Forensics;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Inventory;

namespace Content.Server.Forensics
{
Expand All @@ -17,6 +18,7 @@ public sealed class ForensicPadSystem : EntitySystem
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly LabelSystem _label = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -99,10 +101,8 @@ private void OnDoAfter(EntityUid uid, ForensicPadComponent padComponent, Forensi

if (args.Args.Target != null)
{
var name = HasComp<FingerprintComponent>(args.Args.Target)
? "forensic-pad-fingerprint-name"
: "forensic-pad-gloves-name";
_metaData.SetEntityName(uid, Loc.GetString(name, ("entity", args.Args.Target)));
string label = Identity.Name(args.Args.Target.Value, EntityManager);
_label.Label(uid, label);
}

padComponent.Sample = args.Sample;
Expand Down
5 changes: 2 additions & 3 deletions Content.Server/Shuttles/Systems/ArrivalsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<PlayerSpawningEvent>(HandlePlayerSpawning, before: new []{ typeof(ContainerSpawnPointSystem), typeof(SpawnPointSystem)});
SubscribeLocalEvent<PlayerSpawningEvent>(HandlePlayerSpawning, before: new []{ typeof(SpawnPointSystem)}, after: new [] { typeof(ContainerSpawnPointSystem)});

SubscribeLocalEvent<StationArrivalsComponent, StationPostInitEvent>(OnStationPostInit);

Expand Down Expand Up @@ -335,8 +335,7 @@ public void HandlePlayerSpawning(PlayerSpawningEvent ev)
if (ev.SpawnResult != null)
return;

if (ev.HumanoidCharacterProfile?.SpawnPriority != SpawnPriorityPreference.Arrivals)
return;
// We use arrivals as the default spawn so don't check for job prio.

// Only works on latejoin even if enabled.
if (!Enabled || _ticker.RunLevel != GameRunLevel.InRound)
Expand Down
Loading

0 comments on commit 2a448a9

Please sign in to comment.