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)
|
private float GetScore(NPCBlackboard blackboard, EntityUid targetUid, UtilityConsideration consideration)
|
||||||
{
|
{
|
||||||
|
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
|
||||||
switch (consideration)
|
switch (consideration)
|
||||||
{
|
{
|
||||||
case FoodValueCon:
|
case FoodValueCon:
|
||||||
@@ -128,11 +129,14 @@ public sealed class NPCUtilitySystem : EntitySystem
|
|||||||
if (!TryComp<FoodComponent>(targetUid, out var food))
|
if (!TryComp<FoodComponent>(targetUid, out var food))
|
||||||
return 0f;
|
return 0f;
|
||||||
|
|
||||||
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
|
|
||||||
|
|
||||||
if (!_food.IsDigestibleBy(owner, targetUid, food))
|
if (!_food.IsDigestibleBy(owner, targetUid, food))
|
||||||
return 0f;
|
return 0f;
|
||||||
|
|
||||||
|
// no mouse don't eat the uranium-235
|
||||||
|
var avoidBadFood = !HasComp<IgnoreBadFoodComponent>(owner);
|
||||||
|
if (avoidBadFood && HasComp<BadFoodComponent>(targetUid))
|
||||||
|
return 0f;
|
||||||
|
|
||||||
return 1f;
|
return 1f;
|
||||||
}
|
}
|
||||||
case TargetAccessibleCon:
|
case TargetAccessibleCon:
|
||||||
@@ -160,7 +164,6 @@ public sealed class NPCUtilitySystem : EntitySystem
|
|||||||
}
|
}
|
||||||
case TargetDistanceCon:
|
case TargetDistanceCon:
|
||||||
{
|
{
|
||||||
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
|
|
||||||
var radius = blackboard.GetValueOrDefault<float>(NPCBlackboard.VisionRadius, EntityManager);
|
var radius = blackboard.GetValueOrDefault<float>(NPCBlackboard.VisionRadius, EntityManager);
|
||||||
|
|
||||||
if (!TryComp<TransformComponent>(targetUid, out var targetXform) ||
|
if (!TryComp<TransformComponent>(targetUid, out var targetXform) ||
|
||||||
@@ -183,14 +186,12 @@ public sealed class NPCUtilitySystem : EntitySystem
|
|||||||
}
|
}
|
||||||
case TargetInLOSCon:
|
case TargetInLOSCon:
|
||||||
{
|
{
|
||||||
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
|
|
||||||
var radius = blackboard.GetValueOrDefault<float>(NPCBlackboard.VisionRadius, EntityManager);
|
var radius = blackboard.GetValueOrDefault<float>(NPCBlackboard.VisionRadius, EntityManager);
|
||||||
|
|
||||||
return ExamineSystemShared.InRangeUnOccluded(owner, targetUid, radius + 0.5f, null) ? 1f : 0f;
|
return ExamineSystemShared.InRangeUnOccluded(owner, targetUid, radius + 0.5f, null) ? 1f : 0f;
|
||||||
}
|
}
|
||||||
case TargetInLOSOrCurrentCon:
|
case TargetInLOSOrCurrentCon:
|
||||||
{
|
{
|
||||||
var owner = blackboard.GetValue<EntityUid>(NPCBlackboard.Owner);
|
|
||||||
var radius = blackboard.GetValueOrDefault<float>(NPCBlackboard.VisionRadius, EntityManager);
|
var radius = blackboard.GetValueOrDefault<float>(NPCBlackboard.VisionRadius, EntityManager);
|
||||||
const float bufferRange = 0.5f;
|
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
|
- type: Puller
|
||||||
needsHands: true
|
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
|
- type: entity
|
||||||
parent: MobMouse
|
parent: MobMouse
|
||||||
id: MobMouse1
|
id: MobMouse1
|
||||||
|
|||||||
@@ -156,6 +156,7 @@
|
|||||||
- type: Material
|
- type: Material
|
||||||
- type: Food
|
- type: Food
|
||||||
transferAmount: 10
|
transferAmount: 10
|
||||||
|
- type: BadFood
|
||||||
- type: PhysicalComposition
|
- type: PhysicalComposition
|
||||||
materialComposition:
|
materialComposition:
|
||||||
Uranium: 100
|
Uranium: 100
|
||||||
|
|||||||
@@ -323,6 +323,7 @@
|
|||||||
- banana
|
- banana
|
||||||
- type: Food
|
- type: Food
|
||||||
trash: TrashBananiumPeel
|
trash: TrashBananiumPeel
|
||||||
|
- type: BadFood
|
||||||
- type: SolutionContainerManager
|
- type: SolutionContainerManager
|
||||||
solutions:
|
solutions:
|
||||||
food:
|
food:
|
||||||
|
|||||||
@@ -320,6 +320,7 @@
|
|||||||
transferAmount: null
|
transferAmount: null
|
||||||
eatMessage: food-swallow
|
eatMessage: food-swallow
|
||||||
useSound: /Audio/Items/pill.ogg
|
useSound: /Audio/Items/pill.ogg
|
||||||
|
- type: BadFood
|
||||||
- type: FlavorProfile
|
- type: FlavorProfile
|
||||||
ignoreReagents: []
|
ignoreReagents: []
|
||||||
- type: SolutionContainerManager
|
- type: SolutionContainerManager
|
||||||
|
|||||||
Reference in New Issue
Block a user