Skip to content

Commit

Permalink
[Fix] Massive Bug Fixes / Массовое Исправление Багов (WWhiteDreamProj…
Browse files Browse the repository at this point in the history
…ect#131)

* fix

* fix

* fix

* fix

* fix

* Fix Bug with Opening Storage Containers (#1292)

<!--
This is a semi-strict format, you can add/remove sections as needed but
the order/format should be kept the same
Remove these comments before submitting
-->

# Description

<!--
Explain this PR in as much detail as applicable

Some example prompts to consider:
How might this affect the game? The codebase?
What might be some alternatives to this?
How/Who does this benefit/hurt [the game/codebase]?
-->

Fixes the bug with opening storage containers while there's already one
opened.

---

# Changelog

<!--
You can add an author after the `:cl:` to change the name that appears
in the changelog (ex: `:cl: Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

:cl:
- fix: Fixed the bug with opening storage containers while there's
already one open.

(cherry picked from commit b0407604ced2859ccbdc417345dadc29656f71f0)

* Automatic Changelog Update (#1292)

(cherry picked from commit 9a40c3783eb0d0e622badc2febcaf0794f6f8ddd)

* possible test fix

* possible test fix

* fix

---------

Co-authored-by: sleepyyapril <[email protected]>
Co-authored-by: SimpleStation Changelogs <[email protected]>
  • Loading branch information
3 people authored Dec 1, 2024
1 parent 762c491 commit 1cd5b0a
Show file tree
Hide file tree
Showing 25 changed files with 400 additions and 257 deletions.
8 changes: 5 additions & 3 deletions Content.Client/Lobby/UI/LobbyGui.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,18 @@ public void SwitchState(LobbyGuiState state)
CharacterSetupState.Visible = true;
// WD EDIT START
Center.Visible = false;
RightSide.Visible = true;
RightSide.Visible = false;
LabelName.Visible = false;
Changelog.Visible = false;
// WD EDIT END

var actualWidth = (float) UserInterfaceManager.RootControl.PixelWidth;
var setupWidth = (float) LeftSide.PixelWidth;

if (1 - (setupWidth / actualWidth) < 0.30)
RightSide.Visible = false;
// WD EDIT START
if (1 - (setupWidth / actualWidth) < 0.15)
RightSide.Visible = true;
// WD EDIT END

UserInterfaceManager.GetUIController<LobbyUIController>().ReloadCharacterSetup();

Expand Down
1 change: 1 addition & 0 deletions Content.Client/Storage/StorageBoundUserInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public sealed class StorageBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IEntityManager _entManager = default!;

[Obsolete] public override bool DeferredClose => false;
private readonly StorageSystem _storage;

public StorageBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
Expand Down
11 changes: 6 additions & 5 deletions Content.Client/Weather/WeatherSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ protected override void Run(EntityUid uid, WeatherData weather, WeatherPrototype
if (!Timing.IsFirstTimePredicted || weatherProto.Sound == null)
return;

var playStream = _audio.PlayGlobal(weatherProto.Sound, Filter.Local(), true);
weather.Stream ??= playStream!.Value.Entity;
// WD EDIT START
weather.Stream ??= _audio.PlayGlobal(weatherProto.Sound, Filter.Local(), true)?.Entity;
if (!TryComp(weather.Stream, out AudioComponent? comp))
return;
// WD EDIT END

var stream = weather.Stream.Value;
var comp = Comp<AudioComponent>(stream);
var occlusion = 0f;

// Work out tiles nearby to determine volume.
Expand Down Expand Up @@ -116,7 +117,7 @@ protected override void Run(EntityUid uid, WeatherData weather, WeatherPrototype

var alpha = GetPercent(weather, uid);
alpha *= SharedAudioSystem.VolumeToGain(weatherProto.Sound.Params.Volume);
_audio.SetGain(stream, alpha, comp);
_audio.SetGain(weather.Stream, alpha, comp); // WD EDIR
comp.Occlusion = occlusion;
}

Expand Down
7 changes: 5 additions & 2 deletions Content.IntegrationTests/Tests/Fluids/AbsorbentTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
using Robust.Shared.Prototypes;
using System.Collections.Generic;
using System.Linq;
using Content.Shared.Coordinates;
using Robust.Shared.Physics;


namespace Content.IntegrationTests.Tests.Fluids;

Expand Down Expand Up @@ -109,7 +112,7 @@ await server.WaitAssertion(() =>
solutionContainerSystem.AddSolution(refillableSoln.Value, new Solution(NonEvaporablePrototypeId, testCase.InitialRefillableSolution.VolumeOfNonEvaporable));

// Act
absorbentSystem.Mop(user, refillable, absorbent, component);
absorbentSystem.Mop(user, absorbent, component, refillable.ToCoordinates(), refillable); // WD EDIT

// Assert
var absorbentComposition = absorbentSolution.GetReagentPrototypes(prototypeManager).ToDictionary(r => r.Key.ID, r => r.Value);
Expand Down Expand Up @@ -166,7 +169,7 @@ await server.WaitAssertion(() =>
solutionContainerSystem.AddSolution(refillableSoln.Value, new Solution(NonEvaporablePrototypeId, testCase.InitialRefillableSolution.VolumeOfNonEvaporable));

// Act
absorbentSystem.Mop(user, refillable, absorbent, component);
absorbentSystem.Mop(user, absorbent, component, refillable.ToCoordinates(), refillable); // WD EDIT

// Assert
var absorbentComposition = absorbentSolution.GetReagentPrototypes(prototypeManager).ToDictionary(r => r.Key.ID, r => r.Value);
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Animals/Systems/WoolySystem.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using Content.Server.Animals.Components;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.Nutrition;
using Content.Shared.Mobs.Systems;
using Content.Shared.Nutrition;
using Content.Shared.Nutrition.Components;
using Content.Shared.Nutrition.EntitySystems;
using Robust.Shared.Timing;

namespace Content.Server.Animals.Systems;

/// <summary>
/// Gives ability to produce fiber reagents, produces endless if the
/// Gives ability to produce fiber reagents, produces endless if the
/// owner has no HungerComponent
/// </summary>
public sealed class WoolySystem : EntitySystem
Expand Down
7 changes: 6 additions & 1 deletion Content.Server/Doors/Systems/AirlockSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public override void Initialize()
SubscribeLocalEvent<AirlockComponent, SignalReceivedEvent>(OnSignalReceived);

SubscribeLocalEvent<AirlockComponent, PowerChangedEvent>(OnPowerChanged);
SubscribeLocalEvent<AirlockComponent, ActivateInWorldEvent>(OnActivate, before: new[] { typeof(DoorSystem) });
SubscribeLocalEvent<AirlockComponent, ActivateInWorldEvent>(OnActivate, after: new[] { typeof(DoorSystem) }); // WD EDIT
}

private void OnAirlockInit(EntityUid uid, AirlockComponent component, ComponentInit args)
Expand Down Expand Up @@ -67,6 +67,11 @@ private void OnPowerChanged(EntityUid uid, AirlockComponent component, ref Power

private void OnActivate(EntityUid uid, AirlockComponent component, ActivateInWorldEvent args)
{
// WD EDIT START
if (args.Handled)
return;
// WD EDIT END

if (TryComp<WiresPanelComponent>(uid, out var panel) &&
panel.Open &&
TryComp<ActorComponent>(args.User, out var actor))
Expand Down
108 changes: 66 additions & 42 deletions Content.Server/Fluids/EntitySystems/AbsorbentSystem.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
using System.Numerics;
using Content.Server.Chemistry.Containers.EntitySystems;
using Content.Server.Interaction;
using Content.Server.Popups;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.FixedPoint;
using Content.Shared.Fluids;
using Content.Shared.Fluids.Components;
using Content.Shared.Interaction;
using Content.Shared.Maps;
using Content.Shared.Physics;
using Content.Shared.Timing;
using Content.Shared.Tools.Components;
using Content.Shared.Weapons.Melee;
using Robust.Server.Audio;
using Robust.Server.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
Expand All @@ -29,6 +34,10 @@ public sealed class AbsorbentSystem : SharedAbsorbentSystem
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
[Dependency] private readonly UseDelaySystem _useDelay = default!;
[Dependency] private readonly MapSystem _mapSystem = default!;
[Dependency] private readonly IMapManager _mapManager = default!; // WD EDIT
[Dependency] private readonly EntityLookupSystem _lookup = default!; // WD EDIT

public const float AbsorptionRange = 0.25f; // WD EDIT

public override void Initialize()
{
Expand Down Expand Up @@ -90,20 +99,20 @@ private void OnInteractNoHand(EntityUid uid, AbsorbentComponent component, Inter
if (args.Handled || args.Target == null)
return;

Mop(uid, args.Target.Value, uid, component);
Mop(uid, uid, component, args.ClickLocation, args.Target);
args.Handled = true;
}

private void OnAfterInteract(EntityUid uid, AbsorbentComponent component, AfterInteractEvent args)
{
if (!args.CanReach || args.Handled || args.Target == null)
if (!args.CanReach || args.Handled)
return;

Mop(args.User, args.Target.Value, args.Used, component);
Mop(args.User, args.Used, component, args.ClickLocation, args.Target);
args.Handled = true;
}

public void Mop(EntityUid user, EntityUid target, EntityUid used, AbsorbentComponent component)
public void Mop(EntityUid user, EntityUid used, AbsorbentComponent component, EntityCoordinates coordinates, EntityUid? target = null)
{
if (!_solutionContainerSystem.TryGetSolution(used, AbsorbentComponent.SolutionName, out var absorberSoln))
return;
Expand All @@ -113,18 +122,20 @@ public void Mop(EntityUid user, EntityUid target, EntityUid used, AbsorbentCompo
return;

// If it's a puddle try to grab from
if (!TryPuddleInteract(user, used, target, component, useDelay, absorberSoln.Value))
{
// If it's refillable try to transfer
if (!TryRefillableInteract(user, used, target, component, useDelay, absorberSoln.Value))
return;
}
if (TryPuddleInteract(user, used, component, useDelay, absorberSoln.Value, coordinates))
return;

// If it's refillable try to transfer
if (!target.HasValue)
return;

TryRefillableInteract(user, used, target.Value, component, useDelay, absorberSoln.Value);
}

/// <summary>
/// Logic for an absorbing entity interacting with a refillable.
/// </summary>
private bool TryRefillableInteract(EntityUid user, EntityUid used, EntityUid target, AbsorbentComponent component, UseDelayComponent? useDelay, Entity<SolutionComponent> absorbentSoln)
public bool TryRefillableInteract(EntityUid user, EntityUid used, EntityUid target, AbsorbentComponent component, UseDelayComponent? useDelay, Entity<SolutionComponent> absorbentSoln)
{
if (!TryComp(target, out RefillableSolutionComponent? refillable))
return false;
Expand Down Expand Up @@ -268,56 +279,69 @@ private bool TryTwoWayAbsorbentRefillableTransfer(
/// <summary>
/// Logic for an absorbing entity interacting with a puddle.
/// </summary>
private bool TryPuddleInteract(EntityUid user, EntityUid used, EntityUid target, AbsorbentComponent absorber, UseDelayComponent? useDelay, Entity<SolutionComponent> absorberSoln)
private bool TryPuddleInteract(EntityUid user, EntityUid used, AbsorbentComponent absorber, UseDelayComponent? useDelay, Entity<SolutionComponent> absorberSoln, EntityCoordinates coordinates)
{
if (!TryComp(target, out PuddleComponent? puddle))
// WD EDIT START
if (!_mapManager.TryFindGridAt(coordinates.ToMap(EntityManager, _transform), out var gridUid, out var mapGrid))
return false;

if (!_solutionContainerSystem.ResolveSolution(target, puddle.SolutionName, ref puddle.Solution, out var puddleSolution) || puddleSolution.Volume <= 0)
var tileRef = _mapSystem.GetTileRef(gridUid, mapGrid, coordinates);
var tile = new EntityCoordinates(coordinates.EntityId, new (tileRef.X + 0.5f, tileRef.Y + 0.5f));
var targets = new HashSet<Entity<PuddleComponent>>();
_lookup.GetEntitiesInRange(tile, AbsorptionRange, targets, LookupFlags.Dynamic | LookupFlags.Uncontained);

if (targets.Count == 0)
return false;

// Check if the puddle has any non-evaporative reagents
if (_puddleSystem.CanFullyEvaporate(puddleSolution))
var playSound = false;
// WD EDIT END

foreach (var (entity, component) in targets) // WD EDIT
{
_popups.PopupEntity(Loc.GetString("mopping-system-puddle-evaporate", ("target", target)), user, user);
return true;
}
if (!_solutionContainerSystem.ResolveSolution(entity, component.SolutionName, ref component.Solution, out var puddleSolution) || puddleSolution.Volume <= 0)
continue;

// Check if we have any evaporative reagents on our absorber to transfer
var absorberSolution = absorberSoln.Comp.Solution;
var available = absorberSolution.GetTotalPrototypeQuantity(PuddleSystem.EvaporationReagents);
// Check if the puddle has any non-evaporative reagents
if (_puddleSystem.CanFullyEvaporate(puddleSolution))
continue;

// No material
if (available == FixedPoint2.Zero)
{
_popups.PopupEntity(Loc.GetString("mopping-system-no-water", ("used", used)), user, user);
return true;
}
// Check if we have any evaporative reagents on our absorber to transfer
var absorberSolution = absorberSoln.Comp.Solution;
var available = absorberSolution.GetTotalPrototypeQuantity(PuddleSystem.EvaporationReagents);

var transferMax = absorber.PickupAmount;
var transferAmount = available > transferMax ? transferMax : available;
// No material
if (available == FixedPoint2.Zero)
{
_popups.PopupEntity(Loc.GetString("mopping-system-no-water", ("used", used)), user, user);
break;
}

var puddleSplit = puddleSolution.SplitSolutionWithout(transferAmount, PuddleSystem.EvaporationReagents);
var absorberSplit = absorberSolution.SplitSolutionWithOnly(puddleSplit.Volume, PuddleSystem.EvaporationReagents);
var transferMax = absorber.PickupAmount;
var transferAmount = available > transferMax ? transferMax : available;

// Do tile reactions first
var transform = Transform(target);
var gridUid = transform.GridUid;
if (TryComp(gridUid, out MapGridComponent? mapGrid))
{
var tileRef = _mapSystem.GetTileRef(gridUid.Value, mapGrid, transform.Coordinates);
var puddleSplit = puddleSolution.SplitSolutionWithout(transferAmount, PuddleSystem.EvaporationReagents);
var absorberSplit = absorberSolution.SplitSolutionWithOnly(puddleSplit.Volume, PuddleSystem.EvaporationReagents);

// Do tile reactions first
_puddleSystem.DoTileReactions(tileRef, absorberSplit);

_solutionContainerSystem.AddSolution(component.Solution.Value, absorberSplit);
_solutionContainerSystem.AddSolution(absorberSoln, puddleSplit);

playSound = true; // WD EDIT
}

_solutionContainerSystem.AddSolution(puddle.Solution.Value, absorberSplit);
_solutionContainerSystem.AddSolution(absorberSoln, puddleSplit);
// WD EDIT START
if (!playSound)
return false;
// WD EDIT END
_audio.PlayPvs(absorber.PickupSound, used);

_audio.PlayPvs(absorber.PickupSound, target);
if (useDelay != null)
_useDelay.TryResetDelay((used, useDelay));

var userXform = Transform(user);
var targetPos = _transform.GetWorldPosition(target);
var targetPos = tile.Position; // WD EDIT
var localPos = Vector2.Transform(targetPos, _transform.GetInvWorldMatrix(userXform));
localPos = userXform.LocalRotation.RotateVec(localPos);

Expand Down
8 changes: 5 additions & 3 deletions Content.Server/FootPrint/FootPrintsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
using Content.Shared.Standing;
using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Fluids.Components;
using Content.Shared.Maps;
using Robust.Server.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Random;

Expand All @@ -20,11 +23,11 @@ public sealed class FootPrintsSystem : EntitySystem
[Dependency] private readonly SharedSolutionContainerSystem _solution = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly StandingStateSystem _standingState = default!; // WD EDIT

private EntityQuery<TransformComponent> _transformQuery;
private EntityQuery<MobThresholdsComponent> _mobThresholdQuery;
private EntityQuery<AppearanceComponent> _appearanceQuery;
private EntityQuery<LayingDownComponent> _layingQuery;

public override void Initialize()
{
Expand All @@ -33,7 +36,6 @@ public override void Initialize()
_transformQuery = GetEntityQuery<TransformComponent>();
_mobThresholdQuery = GetEntityQuery<MobThresholdsComponent>();
_appearanceQuery = GetEntityQuery<AppearanceComponent>();
_layingQuery = GetEntityQuery<LayingDownComponent>();

SubscribeLocalEvent<FootPrintsComponent, ComponentStartup>(OnStartupComponent);
SubscribeLocalEvent<FootPrintsComponent, MoveEvent>(OnMove);
Expand All @@ -53,7 +55,7 @@ private void OnMove(EntityUid uid, FootPrintsComponent component, ref MoveEvent
return;

var dragging = mobThreshHolds.CurrentThresholdState is MobState.Critical or MobState.Dead
|| _layingQuery.TryComp(uid, out var laying) && laying.IsCrawlingUnder;
|| _standingState.IsDown(uid); // WD EDIT
var distance = (transform.LocalPosition - component.StepPos).Length();
var stepSize = dragging ? component.DragSize : component.StepSize;

Expand Down
2 changes: 2 additions & 0 deletions Content.Server/FootPrint/PuddleFootPrintsSystem.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Linq;
using Content.Server.Fluids.EntitySystems;
using Content.Shared.FootPrint;
using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Fluids;
using Content.Shared.Fluids.Components;
using Content.Shared.Maps;
using Robust.Shared.Physics.Events;

namespace Content.Server.FootPrint;
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Polymorph/Systems/PolymorphSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Content.Server.Humanoid;
using Content.Server.Inventory;
using Content.Server.Mind.Commands;
using Content.Server.Nutrition;
using Content.Server.Polymorph.Components;
using Content.Shared.Actions;
using Content.Shared.Buckle;
Expand All @@ -13,6 +12,7 @@
using Content.Shared.Mind;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Nutrition;
using Content.Shared.Polymorph;
using Content.Shared.Popups;
using Robust.Server.Audio;
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Vampire/BloodSuckerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
using Content.Shared.Chemistry.EntitySystems;
using Content.Server.Popups;
using Content.Server.DoAfter;
using Content.Server.Nutrition.Components;
using Content.Shared.HealthExaminable;
using Content.Shared.Nutrition.Components;
using Robust.Shared.Prototypes;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Utility;
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/CCVar/CCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,7 @@ public static readonly CVarDef<int>
/// Time in minutes after round start to auto-call the shuttle. Set to zero to disable.
/// </summary>
public static readonly CVarDef<int> EmergencyShuttleAutoCallTime =
CVarDef.Create("shuttle.auto_call_time", 120, CVar.SERVERONLY);
CVarDef.Create("shuttle.auto_call_time", 0, CVar.SERVERONLY); // WD EDIT

/// <summary>
/// Time in minutes after the round was extended (by recalling the shuttle) to call
Expand Down
Loading

0 comments on commit 1cd5b0a

Please sign in to comment.