make mice not eat uranium bananium and pills (#17110)
Co-authored-by: deltanedas <@deltanedas:kde.org> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -121,6 +121,7 @@ public sealed class NPCUtilitySystem : EntitySystem
|
||||
|
||||
private float GetScore(NPCBlackboard blackboard, EntityUid targetUid, UtilityConsideration consideration)
|
||||
{
|
||||
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
|
||||
switch (consideration)
|
||||
{
|
||||
case FoodValueCon:
|
||||
@@ -128,11 +129,14 @@ public sealed class NPCUtilitySystem : EntitySystem
|
||||
if (!TryComp<FoodComponent>(targetUid, out var food))
|
||||
return 0f;
|
||||
|
||||
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
|
||||
|
||||
if (!_food.IsDigestibleBy(owner, targetUid, food))
|
||||
return 0f;
|
||||
|
||||
// no mouse don't eat the uranium-235
|
||||
var avoidBadFood = !HasComp<IgnoreBadFoodComponent>(owner);
|
||||
if (avoidBadFood && HasComp<BadFoodComponent>(targetUid))
|
||||
return 0f;
|
||||
|
||||
return 1f;
|
||||
}
|
||||
case TargetAccessibleCon:
|
||||
@@ -160,7 +164,6 @@ public sealed class NPCUtilitySystem : EntitySystem
|
||||
}
|
||||
case TargetDistanceCon:
|
||||
{
|
||||
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
|
||||
var radius = blackboard.GetValueOrDefault<float>(NPCBlackboard.VisionRadius, EntityManager);
|
||||
|
||||
if (!TryComp<TransformComponent>(targetUid, out var targetXform) ||
|
||||
@@ -183,14 +186,12 @@ public sealed class NPCUtilitySystem : EntitySystem
|
||||
}
|
||||
case TargetInLOSCon:
|
||||
{
|
||||
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
|
||||
var radius = blackboard.GetValueOrDefault<float>(NPCBlackboard.VisionRadius, EntityManager);
|
||||
|
||||
return ExamineSystemShared.InRangeUnOccluded(owner, targetUid, radius + 0.5f, null) ? 1f : 0f;
|
||||
}
|
||||
case TargetInLOSOrCurrentCon:
|
||||
{
|
||||
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
|
||||
var radius = blackboard.GetValueOrDefault<float>(NPCBlackboard.VisionRadius, EntityManager);
|
||||
const float bufferRange = 0.5f;
|
||||
|
||||
|
||||
12
Content.Server/Nutrition/Components/BadFoodComponent.cs
Normal file
12
Content.Server/Nutrition/Components/BadFoodComponent.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Content.Server.Nutrition.EntitySystems;
|
||||
|
||||
namespace Content.Server.Nutrition.Components;
|
||||
|
||||
/// <summary>
|
||||
/// This component prevents NPC mobs like mice from wanting to eat something that is edible but is not exactly food.
|
||||
/// Including but not limited to: uranium, death pills, insulation
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(FoodSystem))]
|
||||
public sealed class BadFoodComponent : Component
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using Content.Server.Nutrition.EntitySystems;
|
||||
|
||||
namespace Content.Server.Nutrition.Components;
|
||||
|
||||
/// <summary>
|
||||
/// This component allows NPC mobs to eat food with BadFoodComponent.
|
||||
/// See MobMouseAdmeme for usage.
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(FoodSystem))]
|
||||
public sealed class IgnoreBadFoodComponent : Component
|
||||
{
|
||||
}
|
||||
@@ -945,6 +945,17 @@
|
||||
- type: Puller
|
||||
needsHands: true
|
||||
|
||||
- type: entity
|
||||
parent: MobMouse
|
||||
id: MobMouseAdmeme
|
||||
suffix: Admeme
|
||||
components:
|
||||
# allow admeme mouse to eat pills
|
||||
- type: IgnoreBadFood
|
||||
# intended for swarms that eat pills so only temporary
|
||||
- type: TimedDespawn
|
||||
lifetime: 60
|
||||
|
||||
- type: entity
|
||||
parent: MobMouse
|
||||
id: MobMouse1
|
||||
|
||||
@@ -156,6 +156,7 @@
|
||||
- type: Material
|
||||
- type: Food
|
||||
transferAmount: 10
|
||||
- type: BadFood
|
||||
- type: PhysicalComposition
|
||||
materialComposition:
|
||||
Uranium: 100
|
||||
|
||||
@@ -323,6 +323,7 @@
|
||||
- banana
|
||||
- type: Food
|
||||
trash: TrashBananiumPeel
|
||||
- type: BadFood
|
||||
- type: SolutionContainerManager
|
||||
solutions:
|
||||
food:
|
||||
|
||||
@@ -320,6 +320,7 @@
|
||||
transferAmount: null
|
||||
eatMessage: food-swallow
|
||||
useSound: /Audio/Items/pill.ogg
|
||||
- type: BadFood
|
||||
- type: FlavorProfile
|
||||
ignoreReagents: []
|
||||
- type: SolutionContainerManager
|
||||
|
||||
Reference in New Issue
Block a user