Separate Udder examine into ExamineableHunger (#35164)
* Separate udder hunger examine into ExamineableHunger * Fluent grammar improvements * Add ExamineableHunger to chickens and ducks. * Use starving message as "dead" message
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
@@ -32,7 +31,6 @@ public sealed class UdderSystem : EntitySystem
|
||||
SubscribeLocalEvent<UdderComponent, MapInitEvent>(OnMapInit);
|
||||
SubscribeLocalEvent<UdderComponent, GetVerbsEvent<AlternativeVerb>>(AddMilkVerb);
|
||||
SubscribeLocalEvent<UdderComponent, MilkingDoAfterEvent>(OnDoAfter);
|
||||
SubscribeLocalEvent<UdderComponent, ExaminedEvent>(OnExamine);
|
||||
}
|
||||
|
||||
private void OnMapInit(EntityUid uid, UdderComponent component, MapInitEvent args)
|
||||
@@ -140,50 +138,4 @@ public sealed class UdderSystem : EntitySystem
|
||||
};
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the text provided on examine.
|
||||
/// Changes depending on the amount of hunger the target has.
|
||||
/// </summary>
|
||||
private void OnExamine(Entity<UdderComponent> entity, ref ExaminedEvent args)
|
||||
{
|
||||
|
||||
var entityIdentity = Identity.Entity(args.Examined, EntityManager);
|
||||
|
||||
string message;
|
||||
|
||||
// Check if the target has hunger, otherwise return not hungry.
|
||||
if (!TryComp<HungerComponent>(entity, out var hunger))
|
||||
{
|
||||
message = Loc.GetString("udder-system-examine-none", ("entity", entityIdentity));
|
||||
args.PushMarkup(message);
|
||||
return;
|
||||
}
|
||||
|
||||
// Choose the correct examine string based on HungerThreshold.
|
||||
switch (_hunger.GetHungerThreshold(hunger))
|
||||
{
|
||||
case >= HungerThreshold.Overfed:
|
||||
message = Loc.GetString("udder-system-examine-overfed", ("entity", entityIdentity));
|
||||
break;
|
||||
|
||||
case HungerThreshold.Okay:
|
||||
message = Loc.GetString("udder-system-examine-okay", ("entity", entityIdentity));
|
||||
break;
|
||||
|
||||
case HungerThreshold.Peckish:
|
||||
message = Loc.GetString("udder-system-examine-hungry", ("entity", entityIdentity));
|
||||
break;
|
||||
|
||||
// There's a final hunger threshold called "dead" but animals don't actually die so we'll re-use this.
|
||||
case <= HungerThreshold.Starving:
|
||||
message = Loc.GetString("udder-system-examine-starved", ("entity", entityIdentity));
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
args.PushMarkup(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
using Content.Shared.Nutrition.EntitySystems;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Nutrition.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Adds text to the entity's description box based on its current hunger threshold.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
[Access(typeof(ExamineableHungerSystem))]
|
||||
public sealed partial class ExamineableHungerComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Dictionary of hunger thresholds to LocIds of the messages to display.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public Dictionary<HungerThreshold, LocId> Descriptions = new()
|
||||
{
|
||||
{ HungerThreshold.Overfed, "examineable-hunger-component-examine-overfed"},
|
||||
{ HungerThreshold.Okay, "examineable-hunger-component-examine-okay"},
|
||||
{ HungerThreshold.Peckish, "examineable-hunger-component-examine-peckish"},
|
||||
{ HungerThreshold.Starving, "examineable-hunger-component-examine-starving"},
|
||||
{ HungerThreshold.Dead, "examineable-hunger-component-examine-starving"}
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// LocId of a fallback message to display if the entity has no <see cref="HungerComponent"/>
|
||||
/// or does not have a value in <see cref="Descriptions"/> for the current threshold.
|
||||
/// </summary>
|
||||
public LocId NoHungerDescription = "examineable-hunger-component-examine-none";
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Nutrition.Components;
|
||||
|
||||
namespace Content.Shared.Nutrition.EntitySystems;
|
||||
|
||||
/// <inheritdoc cref="ExamineableHungerComponent"/>
|
||||
public sealed class ExamineableHungerSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly HungerSystem _hunger = default!;
|
||||
private EntityQuery<HungerComponent> _hungerQuery;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_hungerQuery = GetEntityQuery<HungerComponent>();
|
||||
|
||||
SubscribeLocalEvent<ExamineableHungerComponent, ExaminedEvent>(OnExamine);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the text provided on examine.
|
||||
/// Changes depending on the amount of hunger the target has.
|
||||
/// </summary>
|
||||
private void OnExamine(Entity<ExamineableHungerComponent> entity, ref ExaminedEvent args)
|
||||
{
|
||||
var identity = Identity.Entity(entity, EntityManager);
|
||||
|
||||
if (!_hungerQuery.TryComp(entity, out var hungerComp)
|
||||
|| !entity.Comp.Descriptions.TryGetValue(_hunger.GetHungerThreshold(hungerComp), out var locId))
|
||||
{
|
||||
// Use a fallback message if the entity has no HungerComponent
|
||||
// or is missing a description for the current threshold
|
||||
locId = entity.Comp.NoHungerDescription;
|
||||
}
|
||||
|
||||
var msg = Loc.GetString(locId, ("entity", identity));
|
||||
args.PushMarkup(msg);
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,3 @@ udder-system-success = You fill {THE($target)} with {$amount}u from the udder.
|
||||
udder-system-dry = The udder is dry.
|
||||
|
||||
udder-system-verb-milk = Milk
|
||||
|
||||
udder-system-examine-overfed = {CAPITALIZE(SUBJECT($entity))} looks stuffed!
|
||||
udder-system-examine-okay = {CAPITALIZE(SUBJECT($entity))} looks content.
|
||||
udder-system-examine-hungry = {CAPITALIZE(SUBJECT($entity))} looks hungry.
|
||||
udder-system-examine-starved = {CAPITALIZE(SUBJECT($entity))} looks starved!
|
||||
udder-system-examine-none = {CAPITALIZE(SUBJECT($entity))} seems not to get hungry.
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
examineable-hunger-component-examine-overfed = {CAPITALIZE(SUBJECT($entity))} {CONJUGATE-BASIC($entity, "look", "looks")} stuffed!
|
||||
examineable-hunger-component-examine-okay = {CAPITALIZE(SUBJECT($entity))} {CONJUGATE-BASIC($entity, "look", "looks")} content.
|
||||
examineable-hunger-component-examine-peckish = {CAPITALIZE(SUBJECT($entity))} {CONJUGATE-BASIC($entity, "look", "looks")} hungry.
|
||||
examineable-hunger-component-examine-starving = {CAPITALIZE(SUBJECT($entity))} {CONJUGATE-BASIC($entity, "look", "looks")} starved!
|
||||
examineable-hunger-component-examine-none = {CAPITALIZE(SUBJECT($entity))} {CONJUGATE-BASIC($entity, "seem", "seems")} not to get hungry.
|
||||
@@ -229,6 +229,7 @@
|
||||
- type: EggLayer
|
||||
eggSpawn:
|
||||
- id: FoodEgg
|
||||
- type: ExamineableHunger
|
||||
- type: ReplacementAccent
|
||||
accent: chicken
|
||||
- type: SentienceTarget
|
||||
@@ -663,6 +664,7 @@
|
||||
- type: EggLayer
|
||||
eggSpawn:
|
||||
- id: FoodEgg
|
||||
- type: ExamineableHunger
|
||||
- type: ReplacementAccent
|
||||
accent: duck
|
||||
- type: SentienceTarget
|
||||
@@ -828,6 +830,7 @@
|
||||
reagentId: Milk
|
||||
quantityPerUpdate: 25
|
||||
growthDelay: 30
|
||||
- type: ExamineableHunger
|
||||
- type: Butcherable
|
||||
spawned:
|
||||
- id: FoodMeat
|
||||
@@ -984,6 +987,7 @@
|
||||
reagentId: MilkGoat
|
||||
quantityPerUpdate: 25
|
||||
growthDelay: 20
|
||||
- type: ExamineableHunger
|
||||
- type: Wooly
|
||||
- type: Food
|
||||
solution: wool
|
||||
|
||||
Reference in New Issue
Block a user