Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LogSystem/SharpSystem replaced by SliceableSystem/ButcherableSystem, etc. #34851

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Content.IntegrationTests/Tests/CargoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
using Content.Server.Nutrition.Components;
using Content.Server.Nutrition.EntitySystems;
using Content.Shared.Cargo.Prototypes;
using Content.Shared.IdentityManagement;
using Content.Shared.Stacks;
using Content.Shared.Tag;
using Content.Shared.Whitelist;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public abstract partial class InteractionTest
protected const string Weld = "WelderExperimental";
protected const string Pry = "Crowbar";
protected const string Cut = "Wirecutter";
protected const string Slicing = "ButchCleaver";

// Materials/stacks
protected const string Steel = "Steel";
Expand Down
92 changes: 92 additions & 0 deletions Content.IntegrationTests/Tests/ToolQualities/SlicingTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using System.Linq;
using Content.IntegrationTests.Tests.Interaction;
using Content.Shared.Damage;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Nutrition.Components;
using Content.Shared.Storage;
using Robust.Shared.GameObjects;

namespace Content.IntegrationTests.Tests.ToolQualities;

public sealed class SlicingTests : InteractionTest
{
private const string ButcherableTarget = "MobCorgiIan";
private const string SliceableTarget = "Log";
private const string NonsliceableTarget = "LockerCaptain";

[Test]
public async Task TestButcherableSystemOnDeadTarget()
{
var damageableSystem = SEntMan.System<DamageableSystem>();
var mobStateSystem = SEntMan.System<MobStateSystem>();

// Spawn Ian
await SpawnTarget(ButcherableTarget);
AssertExists(Target);

// Kill him with a brick or something
var butcherableComp = Comp<ButcherableComponent>();
var mobStateComp = Comp<MobStateComponent>();
var mobThresholdsComp = Comp<MobThresholdsComponent>();
var damageableComp = Comp<DamageableComponent>();
var lethalDamageThreshold = mobThresholdsComp.Thresholds.Keys.Last();
var lethalDamage = new DamageSpecifier();
lethalDamage.DamageDict.Add("Blunt", lethalDamageThreshold);
await Server.WaitAssertion(() =>
{
damageableSystem.SetDamage(STarget.Value, damageableComp, lethalDamage);
Assert.That(mobStateSystem.IsDead(STarget.Value, mobStateComp));
});

// Try to butcher the dead dog
await InteractUsing(Slicing);
AssertDeleted(Target);

var spawnedEntities = new EntitySpecifierCollection();
spawnedEntities.Add("FoodMeatCorgi", 2);
spawnedEntities.Add("MaterialHideCorgi", 1);
// we're looking for items, so we use sundries
// looking for everything will include the blood puddles that spawn as well and trip the assertion
await AssertEntityLookup(spawnedEntities, flags: LookupFlags.Sundries);
}

[Test]
public async Task TestButcherableSystemOnLivingTarget()
{
// Spawn Ian
await SpawnTarget(ButcherableTarget);
AssertExists(Target);

// Don't beat him with a brick

// Try to butcher the living dog
await InteractUsing(Slicing);
AssertExists(Target);
}

[Test]
public async Task TestSliceableSystemOnSliceableEntity()
{
await SpawnTarget(SliceableTarget);
AssertExists(Target);

await InteractUsing(Slicing);
AssertDeleted(Target);

var spawnedEntities = new EntitySpecifierCollection();
spawnedEntities.Add("MaterialWoodPlank1", 2);
await AssertEntityLookup(spawnedEntities);
}

[Test]
public async Task TestSliceableSystemOnNonsliceableEntity()
{
await SpawnTarget(NonsliceableTarget);
AssertExists(Target);

// Sadly we can't katana slash our way into the Captain's locker
await InteractUsing(Slicing);
AssertExists(Target);
}
}
17 changes: 0 additions & 17 deletions Content.Server/Botany/Components/LogComponent.cs

This file was deleted.

4 changes: 4 additions & 0 deletions Content.Server/Botany/SeedPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Shared.Atmos;
using Content.Shared.EntityEffects;
using Content.Shared.Random;
using Content.Shared.Tools;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
Expand Down Expand Up @@ -195,6 +196,9 @@ public partial class SeedData
/// </summary>
[DataField] public bool Ligneous;

[DataField] public ProtoId<ToolQualityPrototype> LigneousToolQuality = "Slicing";


// No, I'm not removing these.
// if you re-add these, make sure that they get cloned.
//public PlantSpread Spread { get; set; }
Expand Down
14 changes: 8 additions & 6 deletions Content.Server/Botany/Systems/BotanySystem.Seed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@
using Robust.Shared.Random;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Shared.Tools.Components;
using Content.Shared.Tools.Systems;

namespace Content.Server.Botany.Systems;

public sealed partial class BotanySystem : EntitySystem
{
[Dependency] private readonly AppearanceSystem _appearance = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly AppearanceSystem _appearance = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly RandomHelperSystem _randomHelper = default!;
[Dependency] private readonly SharedHandsSystem _hands = default!;
[Dependency] private readonly SharedPointLightSystem _light = default!;
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly FixtureSystem _fixtureSystem = default!;
[Dependency] private readonly RandomHelperSystem _randomHelper = default!;
[Dependency] private readonly SharedToolSystem _tool = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -184,7 +185,8 @@ public IEnumerable<EntityUid> GenerateProduct(SeedData proto, EntityCoordinates

public bool CanHarvest(SeedData proto, EntityUid? held = null)
{
return !proto.Ligneous || proto.Ligneous && held != null && HasComp<SharpComponent>(held);
return !proto.Ligneous || proto.Ligneous && held != null && TryComp<ToolComponent>(held, out var toolComponent)
&& _tool.HasQuality(held.Value, proto.LigneousToolQuality, toolComponent);
}

#endregion
Expand Down
50 changes: 0 additions & 50 deletions Content.Server/Botany/Systems/LogSystem.cs

This file was deleted.

17 changes: 10 additions & 7 deletions Content.Server/Botany/Systems/PlantHolderSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
using Content.Shared.Popups;
using Content.Shared.Random;
using Content.Shared.Tag;
using Content.Shared.Tools.Components;
using Content.Shared.Tools.Systems;
using Robust.Server.GameObjects;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Player;
Expand All @@ -27,19 +29,19 @@ namespace Content.Server.Botany.Systems;

public sealed class PlantHolderSystem : EntitySystem
{
[Dependency] private readonly AppearanceSystem _appearance = default!;
[Dependency] private readonly AtmosphereSystem _atmosphere = default!;
[Dependency] private readonly BotanySystem _botany = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly MutationSystem _mutation = default!;
[Dependency] private readonly AppearanceSystem _appearance = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly RandomHelperSystem _randomHelper = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!;
[Dependency] private readonly SharedToolSystem _tool = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
[Dependency] private readonly RandomHelperSystem _randomHelper = default!;
[Dependency] private readonly IRobustRandom _random = default!;


public const float HydroponicsSpeedMultiplier = 1f;
public const float HydroponicsConsumptionMultiplier = 2f;
Expand Down Expand Up @@ -287,7 +289,8 @@ private void OnInteractUsing(Entity<PlantHolderComponent> entity, ref InteractUs
return;
}

if (HasComp<SharpComponent>(args.Used))
if (TryComp<ToolComponent>(args.Used, out var toolComponent) &&
_tool.HasQuality(args.Used, "Slicing", toolComponent))
{
args.Handled = true;
DoHarvest(uid, args.User, component);
Expand Down
15 changes: 0 additions & 15 deletions Content.Server/Kitchen/Components/SharpComponent.cs

This file was deleted.

19 changes: 11 additions & 8 deletions Content.Server/Kitchen/EntitySystems/KitchenSpikeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
using Content.Shared.Nutrition.Components;
using Content.Shared.Popups;
using Content.Shared.Storage;
using Content.Shared.Tools.Components;
using Content.Shared.Tools.Systems;
using Robust.Server.GameObjects;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Player;
Expand All @@ -27,17 +29,18 @@ namespace Content.Server.Kitchen.EntitySystems
{
public sealed class KitchenSpikeSystem : SharedKitchenSpikeSystem
{
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly BodySystem _bodySystem = default!;
[Dependency] private readonly IAdminLogManager _logger = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly TransformSystem _transform = default!;
[Dependency] private readonly BodySystem _bodySystem = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly SharedSuicideSystem _suicide = default!;
[Dependency] private readonly SharedToolSystem _tool = default!;
[Dependency] private readonly TransformSystem _transform = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -169,13 +172,13 @@ private void Spike(EntityUid uid, EntityUid userUid, EntityUid victimUid,
}

private bool TryGetPiece(EntityUid uid, EntityUid user, EntityUid used,
KitchenSpikeComponent? component = null, SharpComponent? sharp = null)
KitchenSpikeComponent? component = null, ToolComponent? tool = null)
{
if (!Resolve(uid, ref component) || component.PrototypesToSpawn == null || component.PrototypesToSpawn.Count == 0)
return false;

// Is using knife
if (!Resolve(used, ref sharp, false) )
if (!Resolve(used, ref tool, false) || !_tool.HasQuality(used, "Slicing"))
{
return false;
}
Expand Down
Loading
Loading