Animals obey conservation of matter unless they are undead (#21922)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using Content.Shared.Storage;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.Animals.Components;
|
||||
|
||||
@@ -9,28 +8,29 @@ namespace Content.Server.Animals.Components;
|
||||
/// This component handles animals which lay eggs (or some other item) on a timer, using up hunger to do so.
|
||||
/// It also grants an action to players who are controlling these entities, allowing them to do it manually.
|
||||
/// </summary>
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class EggLayerComponent : Component
|
||||
{
|
||||
[DataField("eggLayAction", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string EggLayAction = "ActionAnimalLayEgg";
|
||||
[DataField]
|
||||
public EntProtoId EggLayAction = "ActionAnimalLayEgg";
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("hungerUsage")]
|
||||
/// <summary>
|
||||
/// The amount of nutrient consumed on update.
|
||||
/// </summary>
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public float HungerUsage = 60f;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum cooldown used for the automatic egg laying.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("eggLayCooldownMin")]
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public float EggLayCooldownMin = 60f;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum cooldown used for the automatic egg laying.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("eggLayCooldownMax")]
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public float EggLayCooldownMax = 120f;
|
||||
|
||||
/// <summary>
|
||||
@@ -39,14 +39,13 @@ public sealed partial class EggLayerComponent : Component
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float CurrentEggLayCooldown;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("eggSpawn", required: true)]
|
||||
[DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
|
||||
public List<EntitySpawnEntry> EggSpawn = default!;
|
||||
|
||||
[DataField("eggLaySound")]
|
||||
[DataField]
|
||||
public SoundSpecifier EggLaySound = new SoundPathSpecifier("/Audio/Effects/pop.ogg");
|
||||
|
||||
[DataField("accumulatedFrametime")]
|
||||
[DataField]
|
||||
public float AccumulatedFrametime;
|
||||
|
||||
[DataField] public EntityUid? Action;
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
using Content.Server.Animals.Systems;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||
|
||||
|
||||
namespace Content.Server.Animals.Components
|
||||
|
||||
/// <summary>
|
||||
/// Lets an entity produce milk. Uses hunger if present.
|
||||
/// </summary>
|
||||
{
|
||||
[RegisterComponent, Access(typeof(UdderSystem))]
|
||||
internal sealed partial class UdderComponent : Component
|
||||
@@ -11,31 +17,37 @@ namespace Content.Server.Animals.Components
|
||||
/// <summary>
|
||||
/// The reagent to produce.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
[DataField("reagentId", customTypeSerializer:typeof(PrototypeIdSerializer<ReagentPrototype>))]
|
||||
public string ReagentId = "Milk";
|
||||
[DataField, ViewVariables(VVAccess.ReadOnly)]
|
||||
public ProtoId<ReagentPrototype> ReagentId = "Milk";
|
||||
|
||||
/// <summary>
|
||||
/// The solution to add reagent to.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
[DataField("targetSolution")]
|
||||
public string TargetSolutionName = "udder";
|
||||
[DataField, ViewVariables(VVAccess.ReadOnly)]
|
||||
public string Solution = "udder";
|
||||
|
||||
/// <summary>
|
||||
/// The amount of reagent to be generated on update.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
[DataField("quantity")]
|
||||
public FixedPoint2 QuantityPerUpdate = 1;
|
||||
[DataField, ViewVariables(VVAccess.ReadOnly)]
|
||||
public FixedPoint2 QuantityPerUpdate = 25;
|
||||
|
||||
/// <summary>
|
||||
/// The time between updates (in seconds).
|
||||
/// The amount of nutrient consumed on update.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
[DataField("updateRate")]
|
||||
public float UpdateRate = 5;
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public float HungerUsage = 10f;
|
||||
|
||||
public float AccumulatedFrameTime;
|
||||
/// <summary>
|
||||
/// How long to wait before producing.
|
||||
/// </summary>
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public TimeSpan GrowthDelay = TimeSpan.FromMinutes(1);
|
||||
|
||||
/// <summary>
|
||||
/// When to next try to produce.
|
||||
/// </summary>
|
||||
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
|
||||
public TimeSpan NextGrowth = TimeSpan.FromSeconds(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,38 +4,47 @@ using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||
|
||||
namespace Content.Server.Animals.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Lets an animal grow a wool solution when not hungry.
|
||||
/// Lets an entity produce wool fibers. Uses hunger if present.
|
||||
/// </summary>
|
||||
|
||||
[RegisterComponent, Access(typeof(WoolySystem))]
|
||||
public sealed partial class WoolyComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// What reagent to grow.
|
||||
/// The reagent to grow.
|
||||
/// </summary>
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField, ViewVariables(VVAccess.ReadOnly)]
|
||||
public ProtoId<ReagentPrototype> ReagentId = "Fiber";
|
||||
|
||||
/// <summary>
|
||||
/// How much wool to grow at every growth cycle.
|
||||
/// The solution to add reagent to.
|
||||
/// </summary>
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public FixedPoint2 Quantity = 25;
|
||||
|
||||
/// <summary>
|
||||
/// What solution to add the wool reagent to.
|
||||
/// </summary>
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField, ViewVariables(VVAccess.ReadOnly)]
|
||||
public string Solution = "wool";
|
||||
|
||||
/// <summary>
|
||||
/// How long to wait before growing wool.
|
||||
/// The amount of reagent to be generated on update.
|
||||
/// </summary>
|
||||
[DataField, ViewVariables(VVAccess.ReadOnly)]
|
||||
public FixedPoint2 Quantity = 25;
|
||||
|
||||
/// <summary>
|
||||
/// The amount of nutrient consumed on update.
|
||||
/// </summary>
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public float HungerUsage = 10f;
|
||||
|
||||
/// <summary>
|
||||
/// How long to wait before growing wool.
|
||||
/// </summary>
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public TimeSpan GrowthDelay = TimeSpan.FromMinutes(1);
|
||||
|
||||
/// <summary>
|
||||
/// When to next try growing wool.
|
||||
/// When to next try growing wool.
|
||||
/// </summary>
|
||||
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
|
||||
public TimeSpan NextGrowth = TimeSpan.FromSeconds(0);
|
||||
|
||||
Reference in New Issue
Block a user