Files
crystall-punk-14/Content.Shared/_CP14/Farming/CP14PlantComponent.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

76 lines
2.0 KiB
C#

using Robust.Shared.GameStates;
namespace Content.Shared._CP14.Farming;
/// <summary>
/// The backbone of any plant. Provides common variables for the plant to other components, and a link to the soil
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true), Access(typeof(CP14SharedFarmingSystem))]
public sealed partial class CP14PlantComponent : Component
{
/// <summary>
/// Soil link. May be null, as not all plants in the world grow on entity soil (e.g. wild shrubs)
/// </summary>
public EntityUid? SoilUid;
/// <summary>
/// The ability to consume a resource for growing
/// </summary>
[DataField]
public float Energy = 0f;
[DataField]
public float EnergyMax = 100f;
/// <summary>
/// resource consumed for growth
/// </summary>
[DataField]
public float Resource = 0f;
[DataField]
public float ResourceMax = 100f;
/// <summary>
/// Plant growth status, 0 to 1
/// </summary>
[DataField, AutoNetworkedField]
public float GrowthLevel = 0f;
[DataField(serverOnly: true)]
public float UpdateFrequency = 60f;
[DataField(serverOnly: true)]
public TimeSpan NextUpdateTime = TimeSpan.Zero;
[DataField(serverOnly: true)]
public TimeSpan Age = TimeSpan.Zero;
}
/// <summary>
/// Is called periodically at random intervals on the plant.
/// </summary>
public sealed class CP14PlantUpdateEvent : EntityEventArgs
{
public readonly Entity<CP14PlantComponent> Plant;
public float EnergyDelta = 0f;
public float ResourceDelta = 0f;
public CP14PlantUpdateEvent(Entity<CP14PlantComponent> comp)
{
Plant = comp;
}
}
/// <summary>
/// is called after CP14PlantUpdateEvent when all value changes have already been calculated.
/// </summary>
public sealed class CP14AfterPlantUpdateEvent : EntityEventArgs
{
public readonly Entity<CP14PlantComponent> Plant;
public CP14AfterPlantUpdateEvent(Entity<CP14PlantComponent> comp)
{
Plant = comp;
}
}