Files
crystall-punk-14/Content.Shared/_CP14/DestroyedByTool/CP14DestroyedByToolSystem.cs
Ed 8cbd26ae2f Farming WIP (#269)
* setup planting doafter

* spawn plants after use seed

* some work

* move comps to separate folder

* public check daylight

* daylight plant energy regeneration

* some fixes

* bruh, im thinking

* added ingame soil

* added hoe

* attaching plants

* hoe system

* block plant dublicating

* some planting refactor

* shovel as pant + soil remover

* plant growing visualizer

* soil resprite

* split farming system to second partial class

* update throught event refactor

* tring sync update plant with update visuals

* finish visual sync

* plants growing

* more partial splitting, naming work, clean up

* Update FARMINGTEST.yml

* Update FARMINGTEST.yml

* fix typo

* prototype value validating

* Оно бухает воду!

* solution visualizer in soil

* forgot some fix

* part of Tornado review fix

* destroy RemovePlantComponent

* more fixes

* simple harvesting

* refactor plant component values changing

* harvest redo

* gather on destroyByTool

* sickle resprite

* plant fading

* fading per minute!

* wheat sprites

* YML restruct

* fixes

* auto root plants

* add comments

* move sprites

* split structures from object textures

* wheat farming!

* Update CP14FarmingSystem.Interactions.cs

* seedbed (#297)

seedbed :^)

* a

* Update soil.yml

---------

Co-authored-by: Jaraten <116667537+Jaraten@users.noreply.github.com>
2024-07-15 23:58:03 +03:00

60 lines
1.8 KiB
C#

using Content.Shared.DoAfter;
using Content.Shared.Interaction;
using Content.Shared.Tools.Components;
using Content.Shared.Tools.Systems;
using Robust.Shared.Serialization;
namespace Content.Shared._CP14.DestroyedByTool;
public sealed partial class CP14DestroyedByToolSystem : EntitySystem
{
[Dependency] private readonly SharedToolSystem _tool = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CP14DestroyedByToolComponent, CP14DestroyedByToolDoAfterEvent>(OnDestroyDoAfter);
SubscribeLocalEvent<CP14DestroyedByToolComponent, InteractUsingEvent>(OnInteractUsing);
}
private void OnInteractUsing(Entity<CP14DestroyedByToolComponent> ent, ref InteractUsingEvent args)
{
if (args.Handled)
return;
if (ent.Comp.Tool == null || !_tool.HasQuality(args.Used, ent.Comp.Tool))
return;
if (TryComp<ToolComponent>(args.Used, out var tool))
{
_tool.PlayToolSound(args.Used, tool, args.User);
}
var doAfterArgs =
new DoAfterArgs(EntityManager, args.User, ent.Comp.RemoveTime, new CP14DestroyedByToolDoAfterEvent(), args.Target)
{
BreakOnDamage = true,
BlockDuplicate = true,
BreakOnMove = true,
BreakOnHandChange = true,
};
_doAfter.TryStartDoAfter(doAfterArgs);
}
private void OnDestroyDoAfter(Entity<CP14DestroyedByToolComponent> ent, ref CP14DestroyedByToolDoAfterEvent args)
{
if (args.Cancelled || args.Handled)
return;
QueueDel(ent);
args.Handled = true;
}
}
[Serializable, NetSerializable]
public sealed partial class CP14DestroyedByToolDoAfterEvent : SimpleDoAfterEvent
{
}