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>
This commit is contained in:
48
Content.Client/_CP14/Farming/ClientCP14FarmingSystem.cs
Normal file
48
Content.Client/_CP14/Farming/ClientCP14FarmingSystem.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using Content.Shared._CP14.Farming;
|
||||
using Content.Shared.Rounding;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
namespace Content.Client._CP14.Farming;
|
||||
|
||||
public sealed class ClientCP14FarmingSystem : CP14SharedFarmingSystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<CP14PlantVisualsComponent, ComponentInit>(OnPlantVisualInit);
|
||||
SubscribeLocalEvent<CP14PlantComponent, AfterAutoHandleStateEvent>(OnAutoHandleState);
|
||||
}
|
||||
|
||||
private void OnAutoHandleState(Entity<CP14PlantComponent> plant, ref AfterAutoHandleStateEvent args)
|
||||
{
|
||||
if (!TryComp<CP14PlantVisualsComponent>(plant, out var visuals))
|
||||
return;
|
||||
|
||||
UpdateVisuals(new Entity<CP14PlantVisualsComponent>(plant, visuals));
|
||||
}
|
||||
|
||||
private void OnPlantVisualInit(Entity<CP14PlantVisualsComponent> visuals, ref ComponentInit args)
|
||||
{
|
||||
UpdateVisuals(visuals);
|
||||
}
|
||||
|
||||
private void UpdateVisuals(Entity<CP14PlantVisualsComponent> visuals)
|
||||
{
|
||||
if (!TryComp<SpriteComponent>(visuals, out var sprite))
|
||||
return;
|
||||
|
||||
if (!TryComp<CP14PlantComponent>(visuals, out var plant))
|
||||
return;
|
||||
|
||||
var growthState = ContentHelpers.RoundToNearestLevels(plant.GrowthLevel, 1, visuals.Comp.GrowthSteps);
|
||||
if (growthState == 0)
|
||||
growthState++;
|
||||
|
||||
if (sprite.LayerMapTryGet(PlantVisualLayers.Base, out _))
|
||||
sprite.LayerSetState(PlantVisualLayers.Base, $"{visuals.Comp.GrowState}{growthState}");
|
||||
|
||||
if (sprite.LayerMapTryGet(PlantVisualLayers.BaseUnshaded, out _))
|
||||
sprite.LayerSetState(PlantVisualLayers.BaseUnshaded, $"{visuals.Comp.GrowUnshadedState}{growthState}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user