Skip to content

Commit

Permalink
Merge branch 'master' into Languages
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxxoTrystan authored May 7, 2024
2 parents 566d861 + 467b21a commit 146c32f
Show file tree
Hide file tree
Showing 32 changed files with 317 additions and 64 deletions.
9 changes: 9 additions & 0 deletions Content.Client/Weapons/Ranged/Systems/GunSystem.Magazine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ protected override void InitializeMagazine()
{
base.InitializeMagazine();
SubscribeLocalEvent<MagazineAmmoProviderComponent, UpdateAmmoCounterEvent>(OnMagazineAmmoUpdate);
SubscribeLocalEvent<MagazineAmmoProviderComponent, AmmoCounterControlEvent>(OnMagazineControl);
}

private void OnMagazineAmmoUpdate(EntityUid uid, MagazineAmmoProviderComponent component, UpdateAmmoCounterEvent args)
Expand All @@ -26,4 +27,12 @@ private void OnMagazineAmmoUpdate(EntityUid uid, MagazineAmmoProviderComponent c

RaiseLocalEvent(ent.Value, args, false);
}

private void OnMagazineControl(EntityUid uid, MagazineAmmoProviderComponent component, AmmoCounterControlEvent args)
{
var ent = GetMagazineEntity(uid);
if (ent == null)
return;
RaiseLocalEvent(ent.Value, args, false);
}
}
35 changes: 25 additions & 10 deletions Content.Server/Administration/Systems/AdminVerbSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public sealed partial class AdminVerbSystem : EntitySystem
[Dependency] private readonly StationSystem _stations = default!;
[Dependency] private readonly StationSpawningSystem _spawning = default!;

private readonly Dictionary<ICommonSession, EditSolutionsEui> _openSolutionUis = new();
private readonly Dictionary<ICommonSession, List<EditSolutionsEui>> _openSolutionUis = new();

public override void Initialize()
{
Expand Down Expand Up @@ -486,10 +486,13 @@ private void AddDebugVerbs(GetVerbsEvent<Verb> args)
#region SolutionsEui
private void OnSolutionChanged(Entity<SolutionContainerManagerComponent> entity, ref SolutionContainerChangedEvent args)
{
foreach (var eui in _openSolutionUis.Values)
foreach (var list in _openSolutionUis.Values)
{
if (eui.Target == entity.Owner)
eui.StateDirty();
foreach (var eui in list)
{
if (eui.Target == entity.Owner)
eui.StateDirty();
}
}
}

Expand All @@ -498,21 +501,33 @@ public void OpenEditSolutionsEui(ICommonSession session, EntityUid uid)
if (session.AttachedEntity == null)
return;

if (_openSolutionUis.ContainsKey(session))
_openSolutionUis[session].Close();

var eui = _openSolutionUis[session] = new EditSolutionsEui(uid);
var eui = new EditSolutionsEui(uid);
_euiManager.OpenEui(eui, session);
eui.StateDirty();

if (!_openSolutionUis.ContainsKey(session)) {
_openSolutionUis[session] = new List<EditSolutionsEui>();
}

_openSolutionUis[session].Add(eui);
}

public void OnEditSolutionsEuiClosed(ICommonSession session)
public void OnEditSolutionsEuiClosed(ICommonSession session, EditSolutionsEui eui)
{
_openSolutionUis.Remove(session, out var eui);
_openSolutionUis[session].Remove(eui);
if (_openSolutionUis[session].Count == 0)
_openSolutionUis.Remove(session);
}

private void Reset(RoundRestartCleanupEvent ev)
{
foreach (var euis in _openSolutionUis.Values)
{
foreach (var eui in euis.ToList())
{
eui.Close();
}
}
_openSolutionUis.Clear();
}
#endregion
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Administration/UI/EditSolutionsEui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public override void Opened()
public override void Closed()
{
base.Closed();
_entityManager.System<AdminVerbSystem>().OnEditSolutionsEuiClosed(Player);
_entityManager.System<AdminVerbSystem>().OnEditSolutionsEuiClosed(Player, this);
}

public override EuiStateBase GetNewState()
Expand Down
27 changes: 16 additions & 11 deletions Content.Server/Kitchen/EntitySystems/SharpSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Content.Shared.Database;
using Content.Shared.Interaction;
using Content.Shared.Nutrition.Components;
using Content.Server.Nutrition.EntitySystems;
using Content.Shared.Popups;
using Content.Shared.Storage;
using Content.Shared.Verbs;
Expand Down Expand Up @@ -34,39 +35,42 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<SharpComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<SharpComponent, AfterInteractEvent>(OnAfterInteract, before: new[] { typeof(UtensilSystem) });
SubscribeLocalEvent<SharpComponent, SharpDoAfterEvent>(OnDoAfter);

SubscribeLocalEvent<ButcherableComponent, GetVerbsEvent<InteractionVerb>>(OnGetInteractionVerbs);
}

private void OnAfterInteract(EntityUid uid, SharpComponent component, AfterInteractEvent args)
{
if (args.Handled)
return;

if (args.Target is null || !args.CanReach)
return;

TryStartButcherDoafter(uid, args.Target.Value, args.User);
args.Handled = TryStartButcherDoAfter(uid, args.Target.Value, args.User);
}

private void TryStartButcherDoafter(EntityUid knife, EntityUid target, EntityUid user)
private bool TryStartButcherDoAfter(EntityUid knife, EntityUid target, EntityUid user)
{
if (!TryComp<ButcherableComponent>(target, out var butcher))
return;
return false;

if (!TryComp<SharpComponent>(knife, out var sharp))
return;
return false;

if (TryComp<MobStateComponent>(target, out var mobState) && !_mobStateSystem.IsDead(target, mobState))
return false;

if (butcher.Type != ButcheringType.Knife)
{
_popupSystem.PopupEntity(Loc.GetString("butcherable-different-tool", ("target", target)), knife, user);
return;
return true;
}

if (TryComp<MobStateComponent>(target, out var mobState) && !_mobStateSystem.IsDead(target, mobState))
return;

if (!sharp.Butchering.Add(target))
return;
return true;

var doAfter =
new DoAfterArgs(EntityManager, user, sharp.ButcherDelayModifier * butcher.ButcherDelay, new SharpDoAfterEvent(), knife, target: target, used: knife)
Expand All @@ -77,6 +81,7 @@ private void TryStartButcherDoafter(EntityUid knife, EntityUid target, EntityUid
NeedHand = true
};
_doAfterSystem.TryStartDoAfter(doAfter);
return true;
}

private void OnDoAfter(EntityUid uid, SharpComponent component, DoAfterEvent args)
Expand Down Expand Up @@ -161,7 +166,7 @@ private void OnGetInteractionVerbs(EntityUid uid, ButcherableComponent component
Act = () =>
{
if (!disabled)
TryStartButcherDoafter(args.Using!.Value, args.Target, args.User);
TryStartButcherDoAfter(args.Using!.Value, args.Target, args.User);
},
Message = message,
Disabled = disabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public sealed partial class BiomassReclaimerComponent : Component
/// <summary>
/// The interval for <see cref="RandomMessTimer"/>.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("randomMessInterval")]
[ViewVariables(VVAccess.ReadWrite), DataField]
public TimeSpan RandomMessInterval = TimeSpan.FromSeconds(5);

/// <summary>
Expand All @@ -28,9 +28,10 @@ public sealed partial class BiomassReclaimerComponent : Component
/// <summary>
/// Amount of biomass that the mob being processed will yield.
/// This is calculated from the YieldPerUnitMass.
/// Also stores non-integer leftovers.
/// </summary>
[ViewVariables]
public int CurrentExpectedYield = default;
public float CurrentExpectedYield = 0f;

/// <summary>
/// The reagent that will be spilled while processing a mob.
Expand All @@ -49,6 +50,18 @@ public sealed partial class BiomassReclaimerComponent : Component
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float YieldPerUnitMass = 0.4f;

/// <summary>
/// How many seconds to take to insert an entity per unit of its mass.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float BaseInsertionDelay = 0.1f;

/// <summary>
/// How much to multiply biomass yield from botany produce.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float ProduceYieldMultiplier = 0.25f;

/// <summary>
/// The time it takes to process a mob, per mass.
/// </summary>
Expand All @@ -58,7 +71,7 @@ public sealed partial class BiomassReclaimerComponent : Component
/// <summary>
/// Will this refuse to gib a living mob?
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("safetyEnabled")]
[ViewVariables(VVAccess.ReadWrite), DataField]
public bool SafetyEnabled = true;
}
}
37 changes: 29 additions & 8 deletions Content.Server/Medical/BiomassReclaimer/BiomassReclaimerSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Numerics;
using Content.Server.Body.Components;
using Content.Server.Botany.Components;
using Content.Server.Fluids.EntitySystems;
using Content.Server.Materials;
using Content.Server.Power.Components;
Expand All @@ -17,6 +18,7 @@
using Content.Shared.Jittering;
using Content.Shared.Medical;
using Content.Shared.Mind;
using Content.Shared.Materials;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Nutrition.Components;
Expand All @@ -26,6 +28,7 @@
using Robust.Shared.Audio.Systems;
using Robust.Shared.Configuration;
using Robust.Shared.Physics.Components;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;

namespace Content.Server.Medical.BiomassReclaimer
Expand All @@ -47,6 +50,9 @@ public sealed class BiomassReclaimerSystem : EntitySystem
[Dependency] private readonly MaterialStorageSystem _material = default!;
[Dependency] private readonly SharedMindSystem _minds = default!;

[ValidatePrototypeId<MaterialPrototype>]
public const string BiomassPrototype = "Biomass";

public override void Update(float frameTime)
{
base.Update(frameTime);
Expand Down Expand Up @@ -79,7 +85,9 @@ public override void Update(float frameTime)
continue;
}

_material.SpawnMultipleFromMaterial(reclaimer.CurrentExpectedYield, "Biomass", Transform(uid).Coordinates);
var actualYield = (int) (reclaimer.CurrentExpectedYield); // can only have integer biomass
reclaimer.CurrentExpectedYield = reclaimer.CurrentExpectedYield - actualYield; // store non-integer leftovers
_material.SpawnMultipleFromMaterial(actualYield, BiomassPrototype, Transform(uid).Coordinates);

reclaimer.BloodReagent = null;
reclaimer.SpawnedEntities.Clear();
Expand Down Expand Up @@ -148,10 +156,14 @@ private void OnAfterInteractUsing(Entity<BiomassReclaimerComponent> reclaimer, r
if (!args.CanReach || args.Target == null)
return;

if (!HasComp<MobStateComponent>(args.Used) || !CanGib(reclaimer, args.Used))
if (!CanGib(reclaimer, args.Used))
return;

if (!TryComp<PhysicsComponent>(args.Used, out var physics))
return;

_doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, 7f, new ReclaimerDoAfterEvent(), reclaimer, target: args.Target, used: args.Used)
var delay = reclaimer.Comp.BaseInsertionDelay * physics.FixturesMass;
_doAfterSystem.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, delay, new ReclaimerDoAfterEvent(), reclaimer, target: args.Target, used: args.Used)
{
BreakOnTargetMove = true,
BreakOnUserMove = true,
Expand All @@ -174,11 +186,14 @@ private void OnClimbedOn(Entity<BiomassReclaimerComponent> reclaimer, ref Climbe

private void OnDoAfter(Entity<BiomassReclaimerComponent> reclaimer, ref ReclaimerDoAfterEvent args)
{
if (args.Handled || args.Cancelled || args.Args.Target == null || HasComp<BiomassReclaimerComponent>(args.Args.Target.Value))
if (args.Handled || args.Cancelled)
return;

if (args.Args.Used == null || args.Args.Target == null || !HasComp<BiomassReclaimerComponent>(args.Args.Target.Value))
return;

_adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{ToPrettyString(args.Args.User):player} used a biomass reclaimer to gib {ToPrettyString(args.Args.Target.Value):target} in {ToPrettyString(reclaimer):reclaimer}");
StartProcessing(args.Args.Target.Value, reclaimer);
StartProcessing(args.Args.Used.Value, reclaimer);

args.Handled = true;
}
Expand All @@ -200,8 +215,13 @@ private void StartProcessing(EntityUid toProcess, Entity<BiomassReclaimerCompone
component.SpawnedEntities = butcherableComponent.SpawnedEntities;
}

component.CurrentExpectedYield = (int) Math.Max(0, physics.FixturesMass * component.YieldPerUnitMass);
var expectedYield = physics.FixturesMass * component.YieldPerUnitMass;
if (HasComp<ProduceComponent>(toProcess))
expectedYield *= component.ProduceYieldMultiplier;
component.CurrentExpectedYield += expectedYield;

component.ProcessingTimer = physics.FixturesMass * component.ProcessingTimePerUnitMass;

QueueDel(toProcess);
}

Expand All @@ -210,7 +230,8 @@ private bool CanGib(Entity<BiomassReclaimerComponent> reclaimer, EntityUid dragg
if (HasComp<ActiveBiomassReclaimerComponent>(reclaimer))
return false;

if (!HasComp<MobStateComponent>(dragged))
bool isPlant = HasComp<ProduceComponent>(dragged);
if (!isPlant && !HasComp<MobStateComponent>(dragged))
return false;

if (!Transform(reclaimer).Anchored)
Expand All @@ -219,7 +240,7 @@ private bool CanGib(Entity<BiomassReclaimerComponent> reclaimer, EntityUid dragg
if (TryComp<ApcPowerReceiverComponent>(reclaimer, out var power) && !power.Powered)
return false;

if (reclaimer.Comp.SafetyEnabled && !_mobState.IsDead(dragged))
if (!isPlant && reclaimer.Comp.SafetyEnabled && !_mobState.IsDead(dragged))
return false;

// Reject souled bodies in easy mode.
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Nutrition/EntitySystems/DrinkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ private void OnDoAfter(Entity<DrinkComponent> entity, ref ConsumeDoAfterEvent ar
if (args.Used is null || !_solutionContainer.TryGetSolution(args.Used.Value, args.Solution, out var soln, out var solution))
return;

if (_openable.IsClosed(args.Used.Value, args.Target.Value))
return;

// TODO this should really be checked every tick.
if (_food.IsMouthBlocked(args.Target.Value))
return;
Expand Down
6 changes: 5 additions & 1 deletion Content.Server/Nutrition/EntitySystems/UtensilSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Shared.Containers.ItemSlots;
using Content.Server.Nutrition.Components;
using Content.Shared.Nutrition.Components;
using Content.Shared.Nutrition.EntitySystems;
Expand Down Expand Up @@ -25,14 +26,17 @@ public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<UtensilComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<UtensilComponent, AfterInteractEvent>(OnAfterInteract, after: new[] { typeof(ItemSlotsSystem) });
}

/// <summary>
/// Clicked with utensil
/// </summary>
private void OnAfterInteract(EntityUid uid, UtensilComponent component, AfterInteractEvent ev)
{
if (ev.Handled)
return;

if (ev.Target == null || !ev.CanReach)
return;

Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Zombies/ZombieSystem.Transform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ public void ZombifyEntity(EntityUid target, MobStateComponent? mobState = null)
var melee = EnsureComp<MeleeWeaponComponent>(target);
melee.Animation = zombiecomp.AttackAnimation;
melee.WideAnimation = zombiecomp.AttackAnimation;
melee.AltDisarm = false;
melee.Range = 1.2f;
melee.Angle = 0.0f;
melee.HitSound = zombiecomp.BiteSound;

if (mobState.CurrentState == MobState.Alive)
{
Expand Down
3 changes: 1 addition & 2 deletions Content.Shared/Chemistry/Components/InjectorComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ public sealed partial class InjectorComponent : Component
/// The maximum amount of solution that can be transferred at once from this solution.
/// </summary>
[DataField("maxTransferAmount")]
[ViewVariables(VVAccess.ReadWrite)]
public FixedPoint2 MaximumTransferAmount = FixedPoint2.New(50);
public FixedPoint2 MaximumTransferAmount = FixedPoint2.New(15);

/// <summary>
/// Amount to inject or draw on each usage. If the injector is inject only, it will
Expand Down
Loading

0 comments on commit 146c32f

Please sign in to comment.