mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-13 04:11:13 +03:00
* Restarting files from scratch * reduce file count, more progress * Additional partial work * update 1 * update 2 * TODO execution * fix * Update PlantGrowthComponent.cs * fix 1 * growth correction * PlantGrowthComponent * update 99 * last update * oops * Update vegan-meatball.yml * Data loss * ToxinsComponent * Default components * minor fix * PlantTraitsComponent * fix error * fix error 2 * Copy growth components * last update within this PR * AutoHarvestGrowth remote * Viable * fix * Fix growth rate * Improvements to the YAML * merge update * fix * code cleanup * TODO * fix * oops * oops 2 * more TODO * fix names * fix names oops * Harvest bug fixes * fix tests * refactor: cleanup after mering master * Update ConsumeExudeGasGrowthSystem.cs * refactor: make this piece of happiness and ponies work * review * oops * fix <summary> * Separation of plant components into PlantComponent and PlantTraitsComponent and cleaning * EnsureUniqueSeed * refactor: change Resolve to TryComp where appropriate * refactor: review comments - try get for components, clenaups * refactor: minor yaml cleanups * fixing trifles * botany-rework-part-3 * API and mutations * minor fixes * Update WeedPestGrowthSystem.cs * Update plants.yml * PlantChemicals * YAMLLinter * review and some lost code * YAMLLinter part 2 * plants.yml * Aaaa tests * seedId * clone plant component * Update clone.yml * refactor: remove suppress possible null reference exception * refactor: changed HasPlantAlive to TryGetAlivePlant, minor cleanup * Separation of tray and plant * oops * PlantingPlant * a little more cleaning * oops 2 * botany-rework-part-4 * predict and API * Field OldAgeDamage * oops * YMAL * YMAL 2 * YMAAAAAL * Update PlantToxinsSystem.cs * review * Update randomMutations.yml * minor fix design * Updates the plants visuals not every frame * bug fixes * some fixes * bugfix and renames * Dirty * Replace ComponentRegistry * unnecessary API * fix merge * build * build 2 * Review by AJCM * del PlantDataComponent and fix harvest * fix all * final review * Update PlantTrayVisualizerSystem.cs * fix merge * Update PlantTraitsComponent.cs * Traits LocId fix * Update SpawnEntitiesBehavior.cs * aaaaaaaaa * fix all part 2 * PlantDataComponent revert * aoao * fix all part 3 * Update PlantTraitsComponent.cs * Update clone.yml * Reviews --------- Co-authored-by: PraxisMapper <praxismapper@gmail.com> Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru> Co-authored-by: Princess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com> Co-authored-by: AJCM-git <ajcm_mail@disroot.org>
84 lines
3.1 KiB
C#
84 lines
3.1 KiB
C#
using JetBrains.Annotations;
|
|
using Content.Shared.Botany.Components;
|
|
using Content.Shared.Botany.Items.Components;
|
|
using Content.Shared.EntityEffects;
|
|
using Content.Shared.Examine;
|
|
using Content.Shared.FixedPoint;
|
|
using Content.Shared.Random.Helpers;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Shared.Botany.Systems;
|
|
|
|
public sealed partial class BotanySystem
|
|
{
|
|
[Dependency] private SharedEntityEffectsSystem _entityEffects = default!;
|
|
|
|
[SubscribeLocalEvent]
|
|
private void OnProduceExamined(Entity<ProduceComponent> ent, ref ExaminedEvent args)
|
|
{
|
|
if (!TryGetPlantComponent<PlantComponent>(ent.Comp.PlantData, ent.Comp.PlantProtoId, out var plant))
|
|
return;
|
|
|
|
using (args.PushGroup(nameof(ProduceComponent)))
|
|
{
|
|
foreach (var m in plant.Mutations)
|
|
{
|
|
// Don't show mutations that have no effect on produce (sentience)
|
|
if (!m.AppliesToProduce)
|
|
continue;
|
|
|
|
if (m.Description != null)
|
|
args.PushMarkup(Loc.GetString(m.Description));
|
|
}
|
|
}
|
|
}
|
|
|
|
private void ProduceGrown(Entity<ProduceComponent> ent)
|
|
{
|
|
if (!TryGetPlantComponent<PlantComponent>(ent.Comp.PlantData, ent.Comp.PlantProtoId, out var plant)
|
|
|| !TryGetPlantComponent<PlantChemicalsComponent>(ent.Comp.PlantData, ent.Comp.PlantProtoId, out var chems))
|
|
return;
|
|
|
|
foreach (var mutation in plant.Mutations)
|
|
{
|
|
if (mutation.AppliesToProduce)
|
|
_entityEffects.TryApplyEffect(ent.Owner, mutation.Effect);
|
|
}
|
|
|
|
_solutionContainer.EnsureSolution(ent.Owner, ent.Comp.TargetSolution, out var solution);
|
|
solution.Comp.Solution.RemoveAllSolution();
|
|
|
|
foreach (var (chem, quantity) in chems.Chemicals)
|
|
{
|
|
var amount = quantity.Min;
|
|
if (quantity.PotencyDivisor > 0 && plant.Potency > 0)
|
|
amount += plant.Potency / quantity.PotencyDivisor;
|
|
amount = FixedPoint2.Clamp(amount, quantity.Min, quantity.Max);
|
|
solution.Comp.Solution.MaxVolume += amount;
|
|
solution.Comp.Solution.AddReagent(chem, amount);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Spawns a produce item from a plant and produces the produce.
|
|
/// </summary>
|
|
[PublicAPI]
|
|
public void SpawnProduce(Entity<PlantComponent?, PlantDataComponent?> ent, EntityCoordinates position)
|
|
{
|
|
if (!Resolve(ent, ref ent.Comp1, ref ent.Comp2, false))
|
|
return;
|
|
|
|
var random = SharedRandomExtensions.PredictedRandom(_timing, GetNetEntity(ent));
|
|
var product = random.Pick(ent.Comp2.ProductPrototypes);
|
|
var entity = PredictedSpawnAtPosition(product, position);
|
|
_randomHelper.RandomOffset(entity, 0.25f, random);
|
|
|
|
var produce = EnsureComp<ProduceComponent>(entity);
|
|
produce.PlantProtoId = MetaData(ent.Owner).EntityPrototype!.ID;
|
|
produce.PlantData = ClonePlantSnapshotData(ent.Owner, parent: entity);
|
|
Dirty(entity, produce);
|
|
ProduceGrown((entity, produce));
|
|
_appearance.SetData(entity, ProduceVisuals.Potency, ent.Comp1.Potency);
|
|
}
|
|
}
|