* 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:
Víctor Aguilera Puerto
2020-10-26 23:19:46 +01:00
committed by GitHub
parent 7c57d10531
commit 484eb0bba4
250 changed files with 3297 additions and 72 deletions

View File

@@ -23,9 +23,11 @@ namespace Content.Shared.Chemistry
private string _description;
private string _physicalDescription;
private Color _substanceColor;
private List<IMetabolizable> _metabolism;
private string _spritePath;
private List<IMetabolizable> _metabolism;
private List<ITileReaction> _tileReactions;
private List<IPlantMetabolizable> _plantMetabolism;
private float _customPlantMetabolism = 1f;
public string ID => _id;
public string Name => _name;
@@ -34,8 +36,9 @@ namespace Content.Shared.Chemistry
public Color SubstanceColor => _substanceColor;
//List of metabolism effects this reagent has, should really only be used server-side.
public List<IMetabolizable> Metabolism => _metabolism;
public List<ITileReaction> TileReactions => _tileReactions;
public IReadOnlyList<IMetabolizable> Metabolism => _metabolism;
public IReadOnlyList<ITileReaction> TileReactions => _tileReactions;
public IReadOnlyList<IPlantMetabolizable> PlantMetabolism => _plantMetabolism;
public string SpriteReplacementPath => _spritePath;
public ReagentPrototype()
@@ -53,16 +56,19 @@ namespace Content.Shared.Chemistry
serializer.DataField(ref _physicalDescription, "physicalDesc", string.Empty);
serializer.DataField(ref _substanceColor, "color", Color.White);
serializer.DataField(ref _spritePath, "spritePath", string.Empty);
serializer.DataField(ref _customPlantMetabolism, "customPlantMetabolism", 1f);
if (_moduleManager.IsServerModule)
{
serializer.DataField(ref _metabolism, "metabolism", new List<IMetabolizable> { new DefaultMetabolizable() });
serializer.DataField(ref _tileReactions, "tileReactions", new List<ITileReaction> { });
serializer.DataField(ref _plantMetabolism, "plantMetabolism", new List<IPlantMetabolizable> { });
}
else
{
_metabolism = new List<IMetabolizable> { new DefaultMetabolizable() };
_tileReactions = new List<ITileReaction>();
_tileReactions = new List<ITileReaction>(0);
_plantMetabolism = new List<IPlantMetabolizable>(0);
}
}
@@ -136,5 +142,16 @@ namespace Content.Shared.Chemistry
return removed;
}
public void ReactionPlant(IEntity plantHolder)
{
if (plantHolder == null || plantHolder.Deleted)
return;
foreach (var plantMetabolizable in _plantMetabolism)
{
plantMetabolizable.Metabolize(plantHolder, _customPlantMetabolism);
}
}
}
}

View File

@@ -0,0 +1,16 @@
using System;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Botany
{
[Serializable, NetSerializable]
public enum PlantHolderVisuals
{
Plant,
HealthLight,
WaterLight,
NutritionLight,
AlertLight,
HarvestLight,
}
}

View File

@@ -127,6 +127,7 @@ namespace Content.Shared.GameObjects.Components
Glass,
Plasteel,
Cable,
Wood,
MVCable,
HVCable,
Gold,

View File

@@ -0,0 +1,17 @@
using Content.Shared.Chemistry;
using JetBrains.Annotations;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Serialization;
namespace Content.Shared.Interfaces.Chemistry
{
public interface IPlantMetabolizable : IExposeData
{
/// <summary>
/// Metabolize <paramref name="customPlantMetabolism"/> unit(s) of a reagent.
/// </summary>
/// <param name="plantHolder">Entity holding the plant</param>
/// <param name="customPlantMetabolism">Units to metabolize</param>
void Metabolize(IEntity plantHolder, float customPlantMetabolism = 1f);
}
}

View File

@@ -0,0 +1,32 @@
#nullable enable
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
namespace Content.Shared.Utility
{
public static class EntityPrototypeHelpers
{
public static bool HasComponent<T>(string prototype, IPrototypeManager? prototypeManager = null, IComponentFactory? componentFactory = null) where T : IComponent
{
return HasComponent(prototype, typeof(T), prototypeManager, componentFactory);
}
public static bool HasComponent(string prototype, Type component, IPrototypeManager? prototypeManager = null, IComponentFactory? componentFactory = null)
{
prototypeManager ??= IoCManager.Resolve<IPrototypeManager>();
componentFactory ??= IoCManager.Resolve<IComponentFactory>();
var registration = componentFactory.GetRegistration(component);
if (!prototypeManager.TryIndex(prototype, out EntityPrototype proto))
{
return proto.Components.ContainsKey(registration.Name);
}
return false;
}
}
}