ECS botany except for plantholder (#6466)
This commit is contained in:
@@ -1,37 +1,19 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Random.Helpers;
|
||||
using Content.Shared.Tag;
|
||||
using Content.Server.Botany.Systems;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.Botany.Components
|
||||
namespace Content.Server.Botany.Components;
|
||||
// TODO: This should probably be merged with SliceableFood somehow or made into a more generic Choppable.
|
||||
|
||||
[RegisterComponent]
|
||||
[Friend(typeof(LogSystem))]
|
||||
public sealed class LogComponent : Component
|
||||
{
|
||||
[RegisterComponent]
|
||||
public class LogComponent : Component, IInteractUsing
|
||||
{
|
||||
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
|
||||
{
|
||||
if (!EntitySystem.Get<ActionBlockerSystem>().CanInteract(eventArgs.User))
|
||||
return false;
|
||||
[DataField("spawnedPrototype", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string SpawnedPrototype = "MaterialWoodPlank1";
|
||||
|
||||
var entMan = IoCManager.Resolve<IEntityManager>();
|
||||
|
||||
if (eventArgs.Using.HasTag("BotanySharp"))
|
||||
{
|
||||
for (var i = 0; i < 2; i++)
|
||||
{
|
||||
var plank = entMan.SpawnEntity("MaterialWoodPlank1", entMan.GetComponent<TransformComponent>(Owner).Coordinates);
|
||||
plank.RandomOffset(0.25f);
|
||||
}
|
||||
|
||||
entMan.QueueDeleteEntity(Owner);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
[DataField("spawnCount")] public int SpawnCount = 2;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user