From 649295dcd211067528da5a3b6ba5035f0620e0cc Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Mon, 7 Aug 2023 19:48:47 +1000 Subject: [PATCH] Call goat protective services (#18812) * Limit reproductivecomponent in confined areas * Slight bump --- .../Nutrition/EntitySystems/AnimalHusbandrySystem.cs | 6 ++++++ .../Nutrition/AnimalHusbandry/ReproductiveComponent.cs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/Content.Server/Nutrition/EntitySystems/AnimalHusbandrySystem.cs b/Content.Server/Nutrition/EntitySystems/AnimalHusbandrySystem.cs index fea72c814c..b5779bfe0a 100644 --- a/Content.Server/Nutrition/EntitySystems/AnimalHusbandrySystem.cs +++ b/Content.Server/Nutrition/EntitySystems/AnimalHusbandrySystem.cs @@ -11,6 +11,7 @@ using Content.Shared.Nutrition.Components; using Content.Shared.Nutrition.EntitySystems; using Content.Shared.Storage; using Robust.Server.GameObjects; +using Robust.Shared.Collections; using Robust.Shared.Random; using Robust.Shared.Timing; @@ -83,7 +84,12 @@ public sealed class AnimalHusbandrySystem : EntitySystem return false; var xform = Transform(uid); + var partners = _entityLookup.GetComponentsInRange(xform.Coordinates, component.BreedRange); + + if (partners.Count >= component.Capacity) + return false; + foreach (var comp in partners) { var partner = comp.Owner; diff --git a/Content.Shared/Nutrition/AnimalHusbandry/ReproductiveComponent.cs b/Content.Shared/Nutrition/AnimalHusbandry/ReproductiveComponent.cs index 4cb1499d4f..4db22da246 100644 --- a/Content.Shared/Nutrition/AnimalHusbandry/ReproductiveComponent.cs +++ b/Content.Shared/Nutrition/AnimalHusbandry/ReproductiveComponent.cs @@ -38,6 +38,12 @@ public sealed class ReproductiveComponent : Component [DataField("breedRange"), ViewVariables(VVAccess.ReadWrite)] public float BreedRange = 3f; + /// + /// How many other entities with this component are allowed in range before we stop. + /// + [DataField("capacity"), ViewVariables(VVAccess.ReadWrite)] + public int Capacity = 6; + /// /// The chance that, on a given attempt, /// for each valid partner, the entity will breed.