Add round reset cleanup for PlantSystem

It now repopulates the entire seed database.
This commit is contained in:
Víctor Aguilera Puerto
2020-10-27 22:17:56 +01:00
parent d8d0889807
commit a1c6d08b87

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using Content.Server.Botany;
using Content.Server.GameObjects.Components.Botany;
using Content.Shared.GameTicking;
using JetBrains.Annotations;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
@@ -12,7 +13,7 @@ using Robust.Shared.Prototypes;
namespace Content.Server.GameObjects.EntitySystems
{
[UsedImplicitly]
public class PlantSystem : EntitySystem
public class PlantSystem : EntitySystem, IResettingEntitySystem
{
[Dependency] private readonly IComponentManager _componentManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
@@ -29,6 +30,15 @@ namespace Content.Server.GameObjects.EntitySystems
{
base.Initialize();
PopulateDatabase();
}
private void PopulateDatabase()
{
_nextUid = 0;
_seeds.Clear();
foreach (var seed in _prototypeManager.EnumeratePrototypes<Seed>())
{
AddSeedToDatabase(seed);
@@ -66,5 +76,10 @@ namespace Content.Server.GameObjects.EntitySystems
plantHolder.Update();
}
}
public void Reset()
{
PopulateDatabase();
}
}
}