Botany (#2357)
* plants and seeds go brrrr * update plants * P L A N T * brrrr * Hydroponics actually work! How about that? * Reuse resource path in visualizer * They lied to us. * Several stuffs * more werk * Add a bunch of plants * Logs go brr. * Brrr moment. * Remove unused method * Important comment. * Seed inventory, yo! * tomato moment * Balance consumption * Makes hydroponics pourable * Adds plant metabolism effect for sugar, the same as glucose. * Eggplant moment * Apple moment * Corn moment * Chanterelle mushroom moment * prototype tweaks * Seed extractor moment * typo * IPlantMetabolizable doc improvement * I should trust my gut instinct more often. * egg-plant..... * localization * Make WaterLevel and NutritionLevel setters private * Less code repetition! Wooo!
This commit is contained in:
committed by
GitHub
parent
7c57d10531
commit
484eb0bba4
70
Content.Server/GameObjects/EntitySystems/PlantSystem.cs
Normal file
70
Content.Server/GameObjects/EntitySystems/PlantSystem.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Botany;
|
||||
using Content.Server.GameObjects.Components.Botany;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Timing;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.GameObjects.EntitySystems
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class PlantSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IComponentManager _componentManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
private int _nextUid = 0;
|
||||
private readonly Dictionary<int, Seed> _seeds = new Dictionary<int,Seed>();
|
||||
|
||||
private float _timer = 0f;
|
||||
|
||||
public IReadOnlyDictionary<int, Seed> Seeds => _seeds;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
foreach (var seed in _prototypeManager.EnumeratePrototypes<Seed>())
|
||||
{
|
||||
AddSeedToDatabase(seed);
|
||||
}
|
||||
}
|
||||
|
||||
public bool AddSeedToDatabase(Seed seed)
|
||||
{
|
||||
// If it's not -1, it's already in the database. Probably.
|
||||
if (seed.Uid != -1)
|
||||
return false;
|
||||
|
||||
seed.Uid = GetNextSeedUid();
|
||||
_seeds[seed.Uid] = seed;
|
||||
return true;
|
||||
}
|
||||
|
||||
private int GetNextSeedUid()
|
||||
{
|
||||
return _nextUid++;
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
_timer += frameTime;
|
||||
if (_timer < 3f)
|
||||
return;
|
||||
|
||||
_timer = 0f;
|
||||
|
||||
foreach (var plantHolder in _componentManager.EntityQuery<PlantHolderComponent>())
|
||||
{
|
||||
plantHolder.Update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user