let animals drink things (#18236)
* thirst .Owner removal * thirst file scope * drink update + minor refactor * drink file scope * let animals drink things * dont eat/drink when dont need to * admeme mouse override * moo --------- Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Content.Server.NPC.Queries.Considerations;
|
||||||
|
|
||||||
|
public sealed class DrinkValueCon : UtilityConsideration
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ using Content.Server.Storage.Components;
|
|||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Content.Shared.Fluids.Components;
|
using Content.Shared.Fluids.Components;
|
||||||
using Content.Shared.Mobs.Systems;
|
using Content.Shared.Mobs.Systems;
|
||||||
|
using Content.Shared.Nutrition.Components;
|
||||||
using Robust.Server.Containers;
|
using Robust.Server.Containers;
|
||||||
using Robust.Shared.Collections;
|
using Robust.Shared.Collections;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
@@ -23,12 +24,13 @@ namespace Content.Server.NPC.Systems;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class NPCUtilitySystem : EntitySystem
|
public sealed class NPCUtilitySystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
|
||||||
[Dependency] private readonly ContainerSystem _container = default!;
|
[Dependency] private readonly ContainerSystem _container = default!;
|
||||||
|
[Dependency] private readonly DrinkSystem _drink = default!;
|
||||||
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
[Dependency] private readonly EntityLookupSystem _lookup = default!;
|
||||||
[Dependency] private readonly NpcFactionSystem _npcFaction = default!;
|
|
||||||
[Dependency] private readonly FoodSystem _food = default!;
|
[Dependency] private readonly FoodSystem _food = default!;
|
||||||
|
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||||
[Dependency] private readonly MobStateSystem _mobState = default!;
|
[Dependency] private readonly MobStateSystem _mobState = default!;
|
||||||
|
[Dependency] private readonly NpcFactionSystem _npcFaction = default!;
|
||||||
[Dependency] private readonly PuddleSystem _puddle = default!;
|
[Dependency] private readonly PuddleSystem _puddle = default!;
|
||||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||||
[Dependency] private readonly SolutionContainerSystem _solutions = default!;
|
[Dependency] private readonly SolutionContainerSystem _solutions = default!;
|
||||||
@@ -132,13 +134,38 @@ public sealed class NPCUtilitySystem : EntitySystem
|
|||||||
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);
|
var avoidBadFood = !HasComp<IgnoreBadFoodComponent>(owner);
|
||||||
|
|
||||||
|
// only eat when hungry or if it will eat anything
|
||||||
|
if (TryComp<HungerComponent>(owner, out var hunger) && hunger.CurrentThreshold > HungerThreshold.Okay && avoidBadFood)
|
||||||
|
return 0f;
|
||||||
|
|
||||||
|
// no mouse don't eat the uranium-235
|
||||||
if (avoidBadFood && HasComp<BadFoodComponent>(targetUid))
|
if (avoidBadFood && HasComp<BadFoodComponent>(targetUid))
|
||||||
return 0f;
|
return 0f;
|
||||||
|
|
||||||
return 1f;
|
return 1f;
|
||||||
}
|
}
|
||||||
|
case DrinkValueCon:
|
||||||
|
{
|
||||||
|
if (!TryComp<DrinkComponent>(targetUid, out var drink) || !drink.Opened)
|
||||||
|
return 0f;
|
||||||
|
|
||||||
|
// only drink when thirsty
|
||||||
|
if (TryComp<ThirstComponent>(owner, out var thirst) && thirst.CurrentThirstThreshold > ThirstThreshold.Okay)
|
||||||
|
return 0f;
|
||||||
|
|
||||||
|
// no janicow don't drink the blood puddle
|
||||||
|
if (HasComp<BadDrinkComponent>(targetUid))
|
||||||
|
return 0f;
|
||||||
|
|
||||||
|
// needs to have something that will satiate thirst, mice wont try to drink 100% pure mutagen.
|
||||||
|
var hydration = _drink.TotalHydration(targetUid, drink);
|
||||||
|
if (hydration <= 1.0f)
|
||||||
|
return 0f;
|
||||||
|
|
||||||
|
return 1f;
|
||||||
|
}
|
||||||
case TargetAccessibleCon:
|
case TargetAccessibleCon:
|
||||||
{
|
{
|
||||||
if (_container.TryGetContainingContainer(targetUid, out var container))
|
if (_container.TryGetContainingContainer(targetUid, out var container))
|
||||||
|
|||||||
12
Content.Server/Nutrition/Components/BadDrinkComponent.cs
Normal file
12
Content.Server/Nutrition/Components/BadDrinkComponent.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 or cows from wanting to drink something that shouldn't be drank from.
|
||||||
|
/// Including but not limited to: puddles
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent, Access(typeof(DrinkSystem))]
|
||||||
|
public sealed class BadDrinkComponent : Component
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ using Content.Server.Body.Components;
|
|||||||
using Content.Server.Body.Systems;
|
using Content.Server.Body.Systems;
|
||||||
using Content.Server.Chemistry.Components.SolutionManager;
|
using Content.Server.Chemistry.Components.SolutionManager;
|
||||||
using Content.Server.Chemistry.EntitySystems;
|
using Content.Server.Chemistry.EntitySystems;
|
||||||
|
using Content.Server.Chemistry.ReagentEffects;
|
||||||
using Content.Server.Fluids.EntitySystems;
|
using Content.Server.Fluids.EntitySystems;
|
||||||
using Content.Server.Forensics;
|
using Content.Server.Forensics;
|
||||||
using Content.Server.Nutrition.Components;
|
using Content.Server.Nutrition.Components;
|
||||||
@@ -24,421 +25,453 @@ using Content.Shared.Nutrition;
|
|||||||
using Content.Shared.Nutrition.Components;
|
using Content.Shared.Nutrition.Components;
|
||||||
using Content.Shared.Throwing;
|
using Content.Shared.Throwing;
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using JetBrains.Annotations;
|
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Server.Nutrition.EntitySystems
|
namespace Content.Server.Nutrition.EntitySystems;
|
||||||
|
|
||||||
|
public sealed class DrinkSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[UsedImplicitly]
|
[Dependency] private readonly BodySystem _body = default!;
|
||||||
public sealed class DrinkSystem : EntitySystem
|
[Dependency] private readonly FoodSystem _food = default!;
|
||||||
|
[Dependency] private readonly FlavorProfileSystem _flavorProfile = default!;
|
||||||
|
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||||
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
|
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||||
|
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
|
||||||
|
[Dependency] private readonly PopupSystem _popup = default!;
|
||||||
|
[Dependency] private readonly PuddleSystem _puddleSystem = default!;
|
||||||
|
[Dependency] private readonly ReactiveSystem _reaction = default!;
|
||||||
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||||
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||||
|
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
|
||||||
|
[Dependency] private readonly SharedInteractionSystem _interaction = default!;
|
||||||
|
[Dependency] private readonly SolutionContainerSystem _solutionContainer = default!;
|
||||||
|
[Dependency] private readonly StomachSystem _stomach = default!;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
[Dependency] private readonly FoodSystem _foodSystem = default!;
|
base.Initialize();
|
||||||
[Dependency] private readonly FlavorProfileSystem _flavorProfileSystem = default!;
|
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
|
||||||
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
|
|
||||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
|
||||||
[Dependency] private readonly BodySystem _bodySystem = default!;
|
|
||||||
[Dependency] private readonly StomachSystem _stomachSystem = default!;
|
|
||||||
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
|
|
||||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
|
||||||
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
|
|
||||||
[Dependency] private readonly PuddleSystem _puddleSystem = default!;
|
|
||||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
|
||||||
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
|
|
||||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
|
||||||
[Dependency] private readonly ReactiveSystem _reaction = default!;
|
|
||||||
|
|
||||||
public override void Initialize()
|
// TODO add InteractNoHandEvent for entities like mice.
|
||||||
|
SubscribeLocalEvent<DrinkComponent, SolutionChangedEvent>(OnSolutionChange);
|
||||||
|
SubscribeLocalEvent<DrinkComponent, ComponentInit>(OnDrinkInit);
|
||||||
|
SubscribeLocalEvent<DrinkComponent, LandEvent>(HandleLand);
|
||||||
|
SubscribeLocalEvent<DrinkComponent, UseInHandEvent>(OnUse);
|
||||||
|
SubscribeLocalEvent<DrinkComponent, AfterInteractEvent>(AfterInteract);
|
||||||
|
SubscribeLocalEvent<DrinkComponent, GetVerbsEvent<AlternativeVerb>>(AddDrinkVerb);
|
||||||
|
SubscribeLocalEvent<DrinkComponent, ExaminedEvent>(OnExamined);
|
||||||
|
SubscribeLocalEvent<DrinkComponent, SolutionTransferAttemptEvent>(OnTransferAttempt);
|
||||||
|
SubscribeLocalEvent<DrinkComponent, ConsumeDoAfterEvent>(OnDoAfter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private FixedPoint2 DrinkVolume(EntityUid uid, DrinkComponent? component = null)
|
||||||
|
{
|
||||||
|
if (!Resolve(uid, ref component))
|
||||||
|
return FixedPoint2.Zero;
|
||||||
|
|
||||||
|
if (!_solutionContainer.TryGetSolution(uid, component.SolutionName, out var sol))
|
||||||
|
return FixedPoint2.Zero;
|
||||||
|
|
||||||
|
return sol.Volume;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsEmpty(EntityUid uid, DrinkComponent? component = null)
|
||||||
|
{
|
||||||
|
if (!Resolve(uid, ref component))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return DrinkVolume(uid, component) <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the total hydration factor contained in a drink's solution.
|
||||||
|
/// </summary>
|
||||||
|
public float TotalHydration(EntityUid uid, DrinkComponent? comp = null)
|
||||||
|
{
|
||||||
|
if (!Resolve(uid, ref comp))
|
||||||
|
return 0f;
|
||||||
|
|
||||||
|
if (!_solutionContainer.TryGetSolution(uid, comp.SolutionName, out var solution))
|
||||||
|
return 0f;
|
||||||
|
|
||||||
|
var total = 0f;
|
||||||
|
foreach (var quantity in solution.Contents)
|
||||||
{
|
{
|
||||||
base.Initialize();
|
var reagent = _proto.Index<ReagentPrototype>(quantity.ReagentId);
|
||||||
|
if (reagent.Metabolisms == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
// TODO add InteractNoHandEvent for entities like mice.
|
foreach ((var _, var entry) in reagent.Metabolisms)
|
||||||
SubscribeLocalEvent<DrinkComponent, SolutionChangedEvent>(OnSolutionChange);
|
|
||||||
SubscribeLocalEvent<DrinkComponent, ComponentInit>(OnDrinkInit);
|
|
||||||
SubscribeLocalEvent<DrinkComponent, LandEvent>(HandleLand);
|
|
||||||
SubscribeLocalEvent<DrinkComponent, UseInHandEvent>(OnUse);
|
|
||||||
SubscribeLocalEvent<DrinkComponent, AfterInteractEvent>(AfterInteract);
|
|
||||||
SubscribeLocalEvent<DrinkComponent, GetVerbsEvent<AlternativeVerb>>(AddDrinkVerb);
|
|
||||||
SubscribeLocalEvent<DrinkComponent, ExaminedEvent>(OnExamined);
|
|
||||||
SubscribeLocalEvent<DrinkComponent, SolutionTransferAttemptEvent>(OnTransferAttempt);
|
|
||||||
SubscribeLocalEvent<DrinkComponent, ConsumeDoAfterEvent>(OnDoAfter);
|
|
||||||
}
|
|
||||||
|
|
||||||
private FixedPoint2 DrinkVolume(EntityUid uid, DrinkComponent? component = null)
|
|
||||||
{
|
|
||||||
if(!Resolve(uid, ref component))
|
|
||||||
return FixedPoint2.Zero;
|
|
||||||
|
|
||||||
if (!_solutionContainerSystem.TryGetSolution(uid, component.SolutionName, out var sol))
|
|
||||||
return FixedPoint2.Zero;
|
|
||||||
|
|
||||||
return sol.Volume;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsEmpty(EntityUid uid, DrinkComponent? component = null)
|
|
||||||
{
|
|
||||||
if(!Resolve(uid, ref component))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return DrinkVolume(uid, component) <= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnExamined(EntityUid uid, DrinkComponent component, ExaminedEvent args)
|
|
||||||
{
|
|
||||||
if (!component.Opened || !args.IsInDetailsRange || !component.Examinable)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var color = IsEmpty(uid, component) ? "gray" : "yellow";
|
|
||||||
var openedText =
|
|
||||||
Loc.GetString(IsEmpty(uid, component) ? "drink-component-on-examine-is-empty" : "drink-component-on-examine-is-opened");
|
|
||||||
args.Message.AddMarkup($"\n{Loc.GetString("drink-component-on-examine-details-text", ("colorName", color), ("text", openedText))}");
|
|
||||||
if (!IsEmpty(uid, component))
|
|
||||||
{
|
{
|
||||||
if (TryComp<ExaminableSolutionComponent>(uid, out var comp))
|
foreach (var effect in entry.Effects)
|
||||||
{
|
{
|
||||||
//provide exact measurement for beakers
|
// ignores any effect conditions, just cares about how much it can hydrate
|
||||||
args.Message.AddMarkup($" - {Loc.GetString("drink-component-on-examine-exact-volume", ("amount", DrinkVolume(uid, component)))}");
|
if (effect is SatiateThirst thirst)
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//general approximation
|
|
||||||
var remainingString = (int) _solutionContainerSystem.PercentFull(uid) switch
|
|
||||||
{
|
{
|
||||||
100 => "drink-component-on-examine-is-full",
|
total += thirst.HydrationFactor * quantity.Quantity.Float();
|
||||||
> 66 => "drink-component-on-examine-is-mostly-full",
|
}
|
||||||
> 33 => HalfEmptyOrHalfFull(args),
|
|
||||||
_ => "drink-component-on-examine-is-mostly-empty",
|
|
||||||
};
|
|
||||||
args.Message.AddMarkup($" - {Loc.GetString(remainingString)}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetOpen(EntityUid uid, bool opened = false, DrinkComponent? component = null)
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnExamined(EntityUid uid, DrinkComponent component, ExaminedEvent args)
|
||||||
|
{
|
||||||
|
if (!component.Opened || !args.IsInDetailsRange || !component.Examinable)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var color = IsEmpty(uid, component) ? "gray" : "yellow";
|
||||||
|
var openedText =
|
||||||
|
Loc.GetString(IsEmpty(uid, component) ? "drink-component-on-examine-is-empty" : "drink-component-on-examine-is-opened");
|
||||||
|
args.Message.AddMarkup($"\n{Loc.GetString("drink-component-on-examine-details-text", ("colorName", color), ("text", openedText))}");
|
||||||
|
if (!IsEmpty(uid, component))
|
||||||
{
|
{
|
||||||
if(!Resolve(uid, ref component))
|
if (TryComp<ExaminableSolutionComponent>(uid, out var comp))
|
||||||
return;
|
|
||||||
|
|
||||||
if (opened == component.Opened)
|
|
||||||
return;
|
|
||||||
|
|
||||||
component.Opened = opened;
|
|
||||||
|
|
||||||
if (!_solutionContainerSystem.TryGetSolution(uid, component.SolutionName, out _))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (EntityManager.TryGetComponent<AppearanceComponent>(uid, out var appearance))
|
|
||||||
{
|
{
|
||||||
_appearanceSystem.SetData(uid, DrinkCanStateVisual.Opened, opened, appearance);
|
//provide exact measurement for beakers
|
||||||
}
|
args.Message.AddMarkup($" - {Loc.GetString("drink-component-on-examine-exact-volume", ("amount", DrinkVolume(uid, component)))}");
|
||||||
}
|
|
||||||
|
|
||||||
private void AfterInteract(EntityUid uid, DrinkComponent component, AfterInteractEvent args)
|
|
||||||
{
|
|
||||||
if (args.Handled || args.Target == null || !args.CanReach)
|
|
||||||
return;
|
|
||||||
|
|
||||||
args.Handled = TryDrink(args.User, args.Target.Value, component, uid);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnUse(EntityUid uid, DrinkComponent component, UseInHandEvent args)
|
|
||||||
{
|
|
||||||
if (args.Handled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!component.Opened)
|
|
||||||
{
|
|
||||||
//Do the opening stuff like playing the sounds.
|
|
||||||
_audio.PlayPvs(_audio.GetSound(component.OpenSounds), args.User);
|
|
||||||
|
|
||||||
SetOpen(uid, true, component);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
args.Handled = TryDrink(args.User, args.User, component, uid);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void HandleLand(EntityUid uid, DrinkComponent component, ref LandEvent args)
|
|
||||||
{
|
|
||||||
if (component.Pressurized &&
|
|
||||||
!component.Opened &&
|
|
||||||
_random.Prob(0.25f) &&
|
|
||||||
_solutionContainerSystem.TryGetSolution(uid, component.SolutionName, out var interactions))
|
|
||||||
{
|
|
||||||
component.Opened = true;
|
|
||||||
UpdateAppearance(component);
|
|
||||||
|
|
||||||
var solution = _solutionContainerSystem.SplitSolution(uid, interactions, interactions.Volume);
|
|
||||||
_puddleSystem.TrySpillAt(uid, solution, out _);
|
|
||||||
|
|
||||||
_audio.PlayPvs(_audio.GetSound(component.BurstSound), uid, AudioParams.Default.WithVolume(-4));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnDrinkInit(EntityUid uid, DrinkComponent component, ComponentInit args)
|
|
||||||
{
|
|
||||||
SetOpen(uid, component.DefaultToOpened, component);
|
|
||||||
|
|
||||||
if (EntityManager.TryGetComponent(uid, out DrainableSolutionComponent? existingDrainable))
|
|
||||||
{
|
|
||||||
// Beakers have Drink component but they should use the existing Drainable
|
|
||||||
component.SolutionName = existingDrainable.Solution;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_solutionContainerSystem.EnsureSolution(uid, component.SolutionName);
|
//general approximation
|
||||||
}
|
var remainingString = (int) _solutionContainer.PercentFull(uid) switch
|
||||||
|
{
|
||||||
UpdateAppearance(component);
|
100 => "drink-component-on-examine-is-full",
|
||||||
|
> 66 => "drink-component-on-examine-is-mostly-full",
|
||||||
if (TryComp(uid, out RefillableSolutionComponent? refillComp))
|
> 33 => HalfEmptyOrHalfFull(args),
|
||||||
refillComp.Solution = component.SolutionName;
|
_ => "drink-component-on-examine-is-mostly-empty",
|
||||||
|
};
|
||||||
if (TryComp(uid, out DrainableSolutionComponent? drainComp))
|
args.Message.AddMarkup($" - {Loc.GetString(remainingString)}");
|
||||||
drainComp.Solution = component.SolutionName;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnSolutionChange(EntityUid uid, DrinkComponent component, SolutionChangedEvent args)
|
|
||||||
{
|
|
||||||
UpdateAppearance(component);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateAppearance(DrinkComponent component)
|
|
||||||
{
|
|
||||||
if (!EntityManager.TryGetComponent((component).Owner, out AppearanceComponent? appearance) ||
|
|
||||||
!EntityManager.HasComponent<SolutionContainerManagerComponent>((component).Owner))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var drainAvailable = DrinkVolume((component.Owner), component);
|
|
||||||
_appearanceSystem.SetData(component.Owner, FoodVisuals.Visual, drainAvailable.Float(), appearance);
|
|
||||||
_appearanceSystem.SetData(component.Owner, DrinkCanStateVisual.Opened, component.Opened, appearance);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnTransferAttempt(EntityUid uid, DrinkComponent component, SolutionTransferAttemptEvent args)
|
|
||||||
{
|
|
||||||
if (!component.Opened)
|
|
||||||
{
|
|
||||||
args.Cancel(Loc.GetString("drink-component-try-use-drink-not-open",
|
|
||||||
("owner", EntityManager.GetComponent<MetaDataComponent>(component.Owner).EntityName)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryDrink(EntityUid user, EntityUid target, DrinkComponent drink, EntityUid item)
|
private void SetOpen(EntityUid uid, bool opened = false, DrinkComponent? component = null)
|
||||||
|
{
|
||||||
|
if(!Resolve(uid, ref component))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (opened == component.Opened)
|
||||||
|
return;
|
||||||
|
|
||||||
|
component.Opened = opened;
|
||||||
|
|
||||||
|
if (!_solutionContainer.TryGetSolution(uid, component.SolutionName, out _))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (EntityManager.TryGetComponent<AppearanceComponent>(uid, out var appearance))
|
||||||
{
|
{
|
||||||
if (!EntityManager.HasComponent<BodyComponent>(target))
|
_appearance.SetData(uid, DrinkCanStateVisual.Opened, opened, appearance);
|
||||||
return false;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!drink.Opened)
|
private void AfterInteract(EntityUid uid, DrinkComponent component, AfterInteractEvent args)
|
||||||
{
|
{
|
||||||
_popupSystem.PopupEntity(Loc.GetString("drink-component-try-use-drink-not-open",
|
if (args.Handled || args.Target == null || !args.CanReach)
|
||||||
("owner", EntityManager.GetComponent<MetaDataComponent>(item).EntityName)), item, user);
|
return;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_solutionContainerSystem.TryGetSolution(item, drink.SolutionName, out var drinkSolution) ||
|
args.Handled = TryDrink(args.User, args.Target.Value, component, uid);
|
||||||
drinkSolution.Volume <= 0)
|
}
|
||||||
{
|
|
||||||
_popupSystem.PopupEntity(Loc.GetString("drink-component-try-use-drink-is-empty",
|
|
||||||
("entity", EntityManager.GetComponent<MetaDataComponent>(item).EntityName)), item, user);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (drinkSolution.Name == null)
|
private void OnUse(EntityUid uid, DrinkComponent component, UseInHandEvent args)
|
||||||
return false;
|
{
|
||||||
|
if (args.Handled)
|
||||||
|
return;
|
||||||
|
|
||||||
if (_foodSystem.IsMouthBlocked(target, user))
|
if (!component.Opened)
|
||||||
return true;
|
{
|
||||||
|
//Do the opening stuff like playing the sounds.
|
||||||
|
_audio.PlayPvs(_audio.GetSound(component.OpenSounds), args.User);
|
||||||
|
|
||||||
if (!_interactionSystem.InRangeUnobstructed(user, item, popup: true))
|
SetOpen(uid, true, component);
|
||||||
return true;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var forceDrink = user != target;
|
args.Handled = TryDrink(args.User, args.User, component, uid);
|
||||||
|
}
|
||||||
|
|
||||||
if (forceDrink)
|
private void HandleLand(EntityUid uid, DrinkComponent component, ref LandEvent args)
|
||||||
{
|
{
|
||||||
var userName = Identity.Entity(user, EntityManager);
|
if (component.Pressurized &&
|
||||||
|
!component.Opened &&
|
||||||
|
_random.Prob(0.25f) &&
|
||||||
|
_solutionContainer.TryGetSolution(uid, component.SolutionName, out var interactions))
|
||||||
|
{
|
||||||
|
component.Opened = true;
|
||||||
|
UpdateAppearance(uid, component);
|
||||||
|
|
||||||
_popupSystem.PopupEntity(Loc.GetString("drink-component-force-feed", ("user", userName)),
|
var solution = _solutionContainer.SplitSolution(uid, interactions, interactions.Volume);
|
||||||
user, target);
|
_puddleSystem.TrySpillAt(uid, solution, out _);
|
||||||
|
|
||||||
// logging
|
_audio.PlayPvs(_audio.GetSound(component.BurstSound), uid, AudioParams.Default.WithVolume(-4));
|
||||||
_adminLogger.Add(LogType.ForceFeed, LogImpact.Medium, $"{ToPrettyString(user):user} is forcing {ToPrettyString(target):target} to drink {ToPrettyString(item):drink} {SolutionContainerSystem.ToPrettyString(drinkSolution)}");
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// log voluntary drinking
|
|
||||||
_adminLogger.Add(LogType.Ingestion, LogImpact.Low, $"{ToPrettyString(target):target} is drinking {ToPrettyString(item):drink} {SolutionContainerSystem.ToPrettyString(drinkSolution)}");
|
|
||||||
}
|
|
||||||
|
|
||||||
var flavors = _flavorProfileSystem.GetLocalizedFlavorsMessage(user, drinkSolution);
|
private void OnDrinkInit(EntityUid uid, DrinkComponent component, ComponentInit args)
|
||||||
|
{
|
||||||
|
SetOpen(uid, component.DefaultToOpened, component);
|
||||||
|
|
||||||
var doAfterEventArgs = new DoAfterArgs(
|
if (EntityManager.TryGetComponent(uid, out DrainableSolutionComponent? existingDrainable))
|
||||||
user,
|
{
|
||||||
forceDrink ? drink.ForceFeedDelay : drink.Delay,
|
// Beakers have Drink component but they should use the existing Drainable
|
||||||
new ConsumeDoAfterEvent(drinkSolution.Name, flavors),
|
component.SolutionName = existingDrainable.Solution;
|
||||||
eventTarget: item,
|
}
|
||||||
target: target,
|
else
|
||||||
used: item)
|
{
|
||||||
{
|
_solutionContainer.EnsureSolution(uid, component.SolutionName);
|
||||||
BreakOnUserMove = forceDrink,
|
}
|
||||||
BreakOnDamage = true,
|
|
||||||
BreakOnTargetMove = forceDrink,
|
|
||||||
MovementThreshold = 0.01f,
|
|
||||||
DistanceThreshold = 1.0f,
|
|
||||||
// Mice and the like can eat without hands.
|
|
||||||
// TODO maybe set this based on some CanEatWithoutHands event or component?
|
|
||||||
NeedHand = forceDrink,
|
|
||||||
};
|
|
||||||
|
|
||||||
_doAfterSystem.TryStartDoAfter(doAfterEventArgs);
|
UpdateAppearance(uid, component);
|
||||||
|
|
||||||
|
if (TryComp(uid, out RefillableSolutionComponent? refillComp))
|
||||||
|
refillComp.Solution = component.SolutionName;
|
||||||
|
|
||||||
|
if (TryComp(uid, out DrainableSolutionComponent? drainComp))
|
||||||
|
drainComp.Solution = component.SolutionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnSolutionChange(EntityUid uid, DrinkComponent component, SolutionChangedEvent args)
|
||||||
|
{
|
||||||
|
UpdateAppearance(uid, component);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateAppearance(EntityUid uid, DrinkComponent component)
|
||||||
|
{
|
||||||
|
if (!TryComp<AppearanceComponent>(uid, out var appearance) ||
|
||||||
|
!HasComp<SolutionContainerManagerComponent>(uid))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var drainAvailable = DrinkVolume(uid, component);
|
||||||
|
_appearance.SetData(uid, FoodVisuals.Visual, drainAvailable.Float(), appearance);
|
||||||
|
_appearance.SetData(uid, DrinkCanStateVisual.Opened, component.Opened, appearance);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTransferAttempt(EntityUid uid, DrinkComponent component, SolutionTransferAttemptEvent args)
|
||||||
|
{
|
||||||
|
if (!component.Opened)
|
||||||
|
{
|
||||||
|
args.Cancel(Loc.GetString("drink-component-try-use-drink-not-open", ("owner", uid)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool TryDrink(EntityUid user, EntityUid target, DrinkComponent drink, EntityUid item)
|
||||||
|
{
|
||||||
|
if (!EntityManager.HasComponent<BodyComponent>(target))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!drink.Opened)
|
||||||
|
{
|
||||||
|
_popup.PopupEntity(Loc.GetString("drink-component-try-use-drink-not-open",
|
||||||
|
("owner", EntityManager.GetComponent<MetaDataComponent>(item).EntityName)), item, user);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
if (!_solutionContainer.TryGetSolution(item, drink.SolutionName, out var drinkSolution) ||
|
||||||
/// Raised directed at a victim when someone has force fed them a drink.
|
drinkSolution.Volume <= 0)
|
||||||
/// </summary>
|
|
||||||
private void OnDoAfter(EntityUid uid, DrinkComponent component, ConsumeDoAfterEvent args)
|
|
||||||
{
|
{
|
||||||
if (args.Handled || args.Cancelled || component.Deleted)
|
_popup.PopupEntity(Loc.GetString("drink-component-try-use-drink-is-empty",
|
||||||
return;
|
("entity", EntityManager.GetComponent<MetaDataComponent>(item).EntityName)), item, user);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!TryComp<BodyComponent>(args.Target, out var body))
|
if (drinkSolution.Name == null)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
if (!_solutionContainerSystem.TryGetSolution(args.Used, args.Solution, out var solution))
|
if (_food.IsMouthBlocked(target, user))
|
||||||
return;
|
return true;
|
||||||
|
|
||||||
// TODO this should really be checked every tick.
|
if (!_interaction.InRangeUnobstructed(user, item, popup: true))
|
||||||
if (_foodSystem.IsMouthBlocked(args.Target.Value))
|
return true;
|
||||||
return;
|
|
||||||
|
|
||||||
// TODO this should really be checked every tick.
|
var forceDrink = user != target;
|
||||||
if (!_interactionSystem.InRangeUnobstructed(args.User, args.Target.Value))
|
|
||||||
return;
|
|
||||||
|
|
||||||
var transferAmount = FixedPoint2.Min(component.TransferAmount, solution.Volume);
|
if (forceDrink)
|
||||||
var drained = _solutionContainerSystem.SplitSolution(uid, solution, transferAmount);
|
{
|
||||||
var forceDrink = args.User != args.Target;
|
var userName = Identity.Entity(user, EntityManager);
|
||||||
|
|
||||||
args.Handled = true;
|
_popup.PopupEntity(Loc.GetString("drink-component-force-feed", ("user", userName)),
|
||||||
if (transferAmount <= 0)
|
user, target);
|
||||||
return;
|
|
||||||
|
|
||||||
if (!_bodySystem.TryGetBodyOrganComponents<StomachComponent>(args.Target.Value, out var stomachs, body))
|
// logging
|
||||||
|
_adminLogger.Add(LogType.ForceFeed, LogImpact.Medium, $"{ToPrettyString(user):user} is forcing {ToPrettyString(target):target} to drink {ToPrettyString(item):drink} {SolutionContainerSystem.ToPrettyString(drinkSolution)}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// log voluntary drinking
|
||||||
|
_adminLogger.Add(LogType.Ingestion, LogImpact.Low, $"{ToPrettyString(target):target} is drinking {ToPrettyString(item):drink} {SolutionContainerSystem.ToPrettyString(drinkSolution)}");
|
||||||
|
}
|
||||||
|
|
||||||
|
var flavors = _flavorProfile.GetLocalizedFlavorsMessage(user, drinkSolution);
|
||||||
|
|
||||||
|
var doAfterEventArgs = new DoAfterArgs(
|
||||||
|
user,
|
||||||
|
forceDrink ? drink.ForceFeedDelay : drink.Delay,
|
||||||
|
new ConsumeDoAfterEvent(drinkSolution.Name, flavors),
|
||||||
|
eventTarget: item,
|
||||||
|
target: target,
|
||||||
|
used: item)
|
||||||
|
{
|
||||||
|
BreakOnUserMove = forceDrink,
|
||||||
|
BreakOnDamage = true,
|
||||||
|
BreakOnTargetMove = forceDrink,
|
||||||
|
MovementThreshold = 0.01f,
|
||||||
|
DistanceThreshold = 1.0f,
|
||||||
|
// Mice and the like can eat without hands.
|
||||||
|
// TODO maybe set this based on some CanEatWithoutHands event or component?
|
||||||
|
NeedHand = forceDrink,
|
||||||
|
};
|
||||||
|
|
||||||
|
_doAfter.TryStartDoAfter(doAfterEventArgs);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raised directed at a victim when someone has force fed them a drink.
|
||||||
|
/// </summary>
|
||||||
|
private void OnDoAfter(EntityUid uid, DrinkComponent component, ConsumeDoAfterEvent args)
|
||||||
|
{
|
||||||
|
if (args.Handled || args.Cancelled || component.Deleted)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!TryComp<BodyComponent>(args.Target, out var body))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!_solutionContainer.TryGetSolution(args.Used, args.Solution, out var solution))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// TODO this should really be checked every tick.
|
||||||
|
if (_food.IsMouthBlocked(args.Target.Value))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// TODO this should really be checked every tick.
|
||||||
|
if (!_interaction.InRangeUnobstructed(args.User, args.Target.Value))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var transferAmount = FixedPoint2.Min(component.TransferAmount, solution.Volume);
|
||||||
|
var drained = _solutionContainer.SplitSolution(uid, solution, transferAmount);
|
||||||
|
var forceDrink = args.User != args.Target;
|
||||||
|
|
||||||
|
args.Handled = true;
|
||||||
|
if (transferAmount <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!_body.TryGetBodyOrganComponents<StomachComponent>(args.Target.Value, out var stomachs, body))
|
||||||
|
{
|
||||||
|
_popup.PopupEntity(forceDrink ? Loc.GetString("drink-component-try-use-drink-cannot-drink-other") : Loc.GetString("drink-component-try-use-drink-had-enough"), args.Target.Value, args.User);
|
||||||
|
|
||||||
|
if (HasComp<RefillableSolutionComponent>(args.Target.Value))
|
||||||
{
|
{
|
||||||
_popupSystem.PopupEntity(forceDrink ? Loc.GetString("drink-component-try-use-drink-cannot-drink-other") : Loc.GetString("drink-component-try-use-drink-had-enough"), args.Target.Value, args.User);
|
_puddleSystem.TrySpillAt(args.User, drained, out _);
|
||||||
|
|
||||||
if (HasComp<RefillableSolutionComponent>(args.Target.Value))
|
|
||||||
{
|
|
||||||
_puddleSystem.TrySpillAt(args.User, drained, out _);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_solutionContainerSystem.Refill(args.Target.Value, solution, drained);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var firstStomach = stomachs.FirstOrNull(stomach => _stomachSystem.CanTransferSolution(stomach.Comp.Owner, drained));
|
_solutionContainer.Refill(args.Target.Value, solution, drained);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//All stomachs are full or can't handle whatever solution we have.
|
var firstStomach = stomachs.FirstOrNull(stomach => _stomach.CanTransferSolution(stomach.Comp.Owner, drained));
|
||||||
if (firstStomach == null)
|
|
||||||
{
|
|
||||||
_popupSystem.PopupEntity(Loc.GetString("drink-component-try-use-drink-had-enough"), args.Target.Value, args.Target.Value);
|
|
||||||
|
|
||||||
if (forceDrink)
|
//All stomachs are full or can't handle whatever solution we have.
|
||||||
{
|
if (firstStomach == null)
|
||||||
_popupSystem.PopupEntity(Loc.GetString("drink-component-try-use-drink-had-enough-other"), args.Target.Value, args.User);
|
{
|
||||||
_puddleSystem.TrySpillAt(args.Target.Value, drained, out _);
|
_popup.PopupEntity(Loc.GetString("drink-component-try-use-drink-had-enough"), args.Target.Value, args.Target.Value);
|
||||||
}
|
|
||||||
else
|
|
||||||
_solutionContainerSystem.TryAddSolution(uid, solution, drained);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var flavors = args.FlavorMessage;
|
|
||||||
|
|
||||||
if (forceDrink)
|
if (forceDrink)
|
||||||
{
|
{
|
||||||
var targetName = Identity.Entity(args.Target.Value, EntityManager);
|
_popup.PopupEntity(Loc.GetString("drink-component-try-use-drink-had-enough-other"), args.Target.Value, args.User);
|
||||||
var userName = Identity.Entity(args.User, EntityManager);
|
_puddleSystem.TrySpillAt(args.Target.Value, drained, out _);
|
||||||
|
|
||||||
_popupSystem.PopupEntity(Loc.GetString("drink-component-force-feed-success", ("user", userName), ("flavors", flavors)), args.Target.Value, args.Target.Value);
|
|
||||||
|
|
||||||
_popupSystem.PopupEntity(
|
|
||||||
Loc.GetString("drink-component-force-feed-success-user", ("target", targetName)),
|
|
||||||
args.User, args.User);
|
|
||||||
|
|
||||||
// log successful forced drinking
|
|
||||||
_adminLogger.Add(LogType.ForceFeed, LogImpact.Medium, $"{ToPrettyString(uid):user} forced {ToPrettyString(args.User):target} to drink {ToPrettyString(component.Owner):drink}");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
_solutionContainer.TryAddSolution(uid, solution, drained);
|
||||||
_popupSystem.PopupEntity(
|
|
||||||
Loc.GetString("drink-component-try-use-drink-success-slurp-taste", ("flavors", flavors)), args.User,
|
|
||||||
args.User);
|
|
||||||
_popupSystem.PopupEntity(
|
|
||||||
Loc.GetString("drink-component-try-use-drink-success-slurp"), args.User, Filter.PvsExcept(args.User), true);
|
|
||||||
|
|
||||||
// log successful voluntary drinking
|
return;
|
||||||
_adminLogger.Add(LogType.Ingestion, LogImpact.Low, $"{ToPrettyString(args.User):target} drank {ToPrettyString(uid):drink}");
|
|
||||||
}
|
|
||||||
|
|
||||||
_audio.PlayPvs(_audio.GetSound(component.UseSound), args.Target.Value, AudioParams.Default.WithVolume(-2f));
|
|
||||||
|
|
||||||
_reaction.DoEntityReaction(args.Target.Value, solution, ReactionMethod.Ingestion);
|
|
||||||
//TODO: Grab the stomach UIDs somehow without using Owner
|
|
||||||
_stomachSystem.TryTransferSolution(firstStomach.Value.Comp.Owner, drained, firstStomach.Value.Comp);
|
|
||||||
|
|
||||||
var comp = EnsureComp<ForensicsComponent>(uid);
|
|
||||||
if (TryComp<DnaComponent>(args.Target, out var dna))
|
|
||||||
comp.DNAs.Add(dna.DNA);
|
|
||||||
|
|
||||||
if (!forceDrink && solution.Volume > 0)
|
|
||||||
args.Repeat = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddDrinkVerb(EntityUid uid, DrinkComponent component, GetVerbsEvent<AlternativeVerb> ev)
|
var flavors = args.FlavorMessage;
|
||||||
|
|
||||||
|
if (forceDrink)
|
||||||
{
|
{
|
||||||
if (uid == ev.User ||
|
var targetName = Identity.Entity(args.Target.Value, EntityManager);
|
||||||
!ev.CanInteract ||
|
var userName = Identity.Entity(args.User, EntityManager);
|
||||||
!ev.CanAccess ||
|
|
||||||
!EntityManager.TryGetComponent(ev.User, out BodyComponent? body) ||
|
|
||||||
!_bodySystem.TryGetBodyOrganComponents<StomachComponent>(ev.User, out var stomachs, body))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (EntityManager.TryGetComponent<MobStateComponent>(uid, out var mobState) && _mobStateSystem.IsAlive(uid, mobState))
|
_popup.PopupEntity(Loc.GetString("drink-component-force-feed-success", ("user", userName), ("flavors", flavors)), args.Target.Value, args.Target.Value);
|
||||||
return;
|
|
||||||
|
|
||||||
AlternativeVerb verb = new()
|
_popup.PopupEntity(
|
||||||
{
|
Loc.GetString("drink-component-force-feed-success-user", ("target", targetName)),
|
||||||
Act = () =>
|
args.User, args.User);
|
||||||
{
|
|
||||||
TryDrink(ev.User, ev.User, component, uid);
|
|
||||||
},
|
|
||||||
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/drink.svg.192dpi.png")),
|
|
||||||
Text = Loc.GetString("drink-system-verb-drink"),
|
|
||||||
Priority = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
ev.Verbs.Add(verb);
|
// log successful forced drinking
|
||||||
|
_adminLogger.Add(LogType.ForceFeed, LogImpact.Medium, $"{ToPrettyString(uid):user} forced {ToPrettyString(args.User):target} to drink {ToPrettyString(uid):drink}");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
// some see half empty, and others see half full
|
|
||||||
private string HalfEmptyOrHalfFull(ExaminedEvent args)
|
|
||||||
{
|
{
|
||||||
string remainingString = "drink-component-on-examine-is-half-full";
|
_popup.PopupEntity(
|
||||||
|
Loc.GetString("drink-component-try-use-drink-success-slurp-taste", ("flavors", flavors)), args.User,
|
||||||
|
args.User);
|
||||||
|
_popup.PopupEntity(
|
||||||
|
Loc.GetString("drink-component-try-use-drink-success-slurp"), args.User, Filter.PvsExcept(args.User), true);
|
||||||
|
|
||||||
if (TryComp<MetaDataComponent>(args.Examiner, out var examiner) && examiner.EntityName.Length > 0
|
// log successful voluntary drinking
|
||||||
&& string.Compare(examiner.EntityName.Substring(0, 1), "m", StringComparison.InvariantCultureIgnoreCase) > 0)
|
_adminLogger.Add(LogType.Ingestion, LogImpact.Low, $"{ToPrettyString(args.User):target} drank {ToPrettyString(uid):drink}");
|
||||||
remainingString = "drink-component-on-examine-is-half-empty";
|
|
||||||
|
|
||||||
return remainingString;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_audio.PlayPvs(_audio.GetSound(component.UseSound), args.Target.Value, AudioParams.Default.WithVolume(-2f));
|
||||||
|
|
||||||
|
_reaction.DoEntityReaction(args.Target.Value, solution, ReactionMethod.Ingestion);
|
||||||
|
//TODO: Grab the stomach UIDs somehow without using Owner
|
||||||
|
_stomach.TryTransferSolution(firstStomach.Value.Comp.Owner, drained, firstStomach.Value.Comp);
|
||||||
|
|
||||||
|
var comp = EnsureComp<ForensicsComponent>(uid);
|
||||||
|
if (TryComp<DnaComponent>(args.Target, out var dna))
|
||||||
|
comp.DNAs.Add(dna.DNA);
|
||||||
|
|
||||||
|
if (!forceDrink && solution.Volume > 0)
|
||||||
|
args.Repeat = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddDrinkVerb(EntityUid uid, DrinkComponent component, GetVerbsEvent<AlternativeVerb> ev)
|
||||||
|
{
|
||||||
|
if (uid == ev.User ||
|
||||||
|
!ev.CanInteract ||
|
||||||
|
!ev.CanAccess ||
|
||||||
|
!EntityManager.TryGetComponent(ev.User, out BodyComponent? body) ||
|
||||||
|
!_body.TryGetBodyOrganComponents<StomachComponent>(ev.User, out var stomachs, body))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (EntityManager.TryGetComponent<MobStateComponent>(uid, out var mobState) && _mobStateSystem.IsAlive(uid, mobState))
|
||||||
|
return;
|
||||||
|
|
||||||
|
AlternativeVerb verb = new()
|
||||||
|
{
|
||||||
|
Act = () =>
|
||||||
|
{
|
||||||
|
TryDrink(ev.User, ev.User, component, uid);
|
||||||
|
},
|
||||||
|
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/drink.svg.192dpi.png")),
|
||||||
|
Text = Loc.GetString("drink-system-verb-drink"),
|
||||||
|
Priority = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
ev.Verbs.Add(verb);
|
||||||
|
}
|
||||||
|
|
||||||
|
// some see half empty, and others see half full
|
||||||
|
private string HalfEmptyOrHalfFull(ExaminedEvent args)
|
||||||
|
{
|
||||||
|
string remainingString = "drink-component-on-examine-is-half-full";
|
||||||
|
|
||||||
|
if (TryComp<MetaDataComponent>(args.Examiner, out var examiner) && examiner.EntityName.Length > 0
|
||||||
|
&& string.Compare(examiner.EntityName.Substring(0, 1), "m", StringComparison.InvariantCultureIgnoreCase) > 0)
|
||||||
|
remainingString = "drink-component-on-examine-is-half-empty";
|
||||||
|
|
||||||
|
return remainingString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,167 +6,170 @@ using Content.Shared.Alert;
|
|||||||
using Content.Shared.Movement.Systems;
|
using Content.Shared.Movement.Systems;
|
||||||
using Content.Shared.Rejuvenate;
|
using Content.Shared.Rejuvenate;
|
||||||
|
|
||||||
namespace Content.Server.Nutrition.EntitySystems
|
namespace Content.Server.Nutrition.EntitySystems;
|
||||||
|
|
||||||
|
[UsedImplicitly]
|
||||||
|
public sealed class ThirstSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[UsedImplicitly]
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
public sealed class ThirstSystem : EntitySystem
|
[Dependency] private readonly AlertsSystem _alerts = default!;
|
||||||
|
[Dependency] private readonly MovementSpeedModifierSystem _movement = default!;
|
||||||
|
[Dependency] private readonly SharedJetpackSystem _jetpack = default!;
|
||||||
|
|
||||||
|
private ISawmill _sawmill = default!;
|
||||||
|
private float _accumulatedFrameTime;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
base.Initialize();
|
||||||
[Dependency] private readonly AlertsSystem _alerts = default!;
|
|
||||||
[Dependency] private readonly MovementSpeedModifierSystem _movement = default!;
|
|
||||||
[Dependency] private readonly SharedJetpackSystem _jetpack = default!;
|
|
||||||
|
|
||||||
private ISawmill _sawmill = default!;
|
_sawmill = Logger.GetSawmill("thirst");
|
||||||
private float _accumulatedFrameTime;
|
|
||||||
|
|
||||||
public override void Initialize()
|
SubscribeLocalEvent<ThirstComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed);
|
||||||
|
SubscribeLocalEvent<ThirstComponent, ComponentStartup>(OnComponentStartup);
|
||||||
|
SubscribeLocalEvent<ThirstComponent, RejuvenateEvent>(OnRejuvenate);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnComponentStartup(EntityUid uid, ThirstComponent component, ComponentStartup args)
|
||||||
|
{
|
||||||
|
// Do not change behavior unless starting value is explicitly defined
|
||||||
|
if (component.CurrentThirst < 0)
|
||||||
{
|
{
|
||||||
base.Initialize();
|
component.CurrentThirst = _random.Next(
|
||||||
|
(int) component.ThirstThresholds[ThirstThreshold.Thirsty] + 10,
|
||||||
_sawmill = Logger.GetSawmill("thirst");
|
(int) component.ThirstThresholds[ThirstThreshold.Okay] - 1);
|
||||||
SubscribeLocalEvent<ThirstComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed);
|
|
||||||
SubscribeLocalEvent<ThirstComponent, ComponentStartup>(OnComponentStartup);
|
|
||||||
SubscribeLocalEvent<ThirstComponent, RejuvenateEvent>(OnRejuvenate);
|
|
||||||
}
|
}
|
||||||
private void OnComponentStartup(EntityUid uid, ThirstComponent component, ComponentStartup args)
|
component.CurrentThirstThreshold = GetThirstThreshold(component, component.CurrentThirst);
|
||||||
|
component.LastThirstThreshold = ThirstThreshold.Okay; // TODO: Potentially change this -> Used Okay because no effects.
|
||||||
|
// TODO: Check all thresholds make sense and throw if they don't.
|
||||||
|
UpdateEffects(uid, component);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRefreshMovespeed(EntityUid uid, ThirstComponent component, RefreshMovementSpeedModifiersEvent args)
|
||||||
|
{
|
||||||
|
// TODO: This should really be taken care of somewhere else
|
||||||
|
if (_jetpack.IsUserFlying(uid))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var mod = component.CurrentThirstThreshold <= ThirstThreshold.Parched ? 0.75f : 1.0f;
|
||||||
|
args.ModifySpeed(mod, mod);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRejuvenate(EntityUid uid, ThirstComponent component, RejuvenateEvent args)
|
||||||
|
{
|
||||||
|
ResetThirst(component);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ThirstThreshold GetThirstThreshold(ThirstComponent component, float amount)
|
||||||
|
{
|
||||||
|
ThirstThreshold result = ThirstThreshold.Dead;
|
||||||
|
var value = component.ThirstThresholds[ThirstThreshold.OverHydrated];
|
||||||
|
foreach (var threshold in component.ThirstThresholds)
|
||||||
{
|
{
|
||||||
// Do not change behavior unless starting value is explicitly defined
|
if (threshold.Value <= value && threshold.Value >= amount)
|
||||||
if (component.CurrentThirst < 0)
|
|
||||||
{
|
{
|
||||||
component.CurrentThirst = _random.Next(
|
result = threshold.Key;
|
||||||
(int) component.ThirstThresholds[ThirstThreshold.Thirsty] + 10,
|
value = threshold.Value;
|
||||||
(int) component.ThirstThresholds[ThirstThreshold.Okay] - 1);
|
|
||||||
}
|
}
|
||||||
component.CurrentThirstThreshold = GetThirstThreshold(component, component.CurrentThirst);
|
|
||||||
component.LastThirstThreshold = ThirstThreshold.Okay; // TODO: Potentially change this -> Used Okay because no effects.
|
|
||||||
// TODO: Check all thresholds make sense and throw if they don't.
|
|
||||||
UpdateEffects(component);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRefreshMovespeed(EntityUid uid, ThirstComponent component, RefreshMovementSpeedModifiersEvent args)
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateThirst(ThirstComponent component, float amount)
|
||||||
|
{
|
||||||
|
component.CurrentThirst = Math.Clamp(component.CurrentThirst + amount, component.ThirstThresholds[ThirstThreshold.Dead], component.ThirstThresholds[ThirstThreshold.OverHydrated]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ResetThirst(ThirstComponent component)
|
||||||
|
{
|
||||||
|
component.CurrentThirst = component.ThirstThresholds[ThirstThreshold.Okay];
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool IsMovementThreshold(ThirstThreshold threshold)
|
||||||
|
{
|
||||||
|
switch (threshold)
|
||||||
{
|
{
|
||||||
// TODO: This should really be taken care of somewhere else
|
case ThirstThreshold.Dead:
|
||||||
if (_jetpack.IsUserFlying(component.Owner))
|
case ThirstThreshold.Parched:
|
||||||
|
return true;
|
||||||
|
case ThirstThreshold.Thirsty:
|
||||||
|
case ThirstThreshold.Okay:
|
||||||
|
case ThirstThreshold.OverHydrated:
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException(nameof(threshold), threshold, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateEffects(EntityUid uid, ThirstComponent component)
|
||||||
|
{
|
||||||
|
if (IsMovementThreshold(component.LastThirstThreshold) != IsMovementThreshold(component.CurrentThirstThreshold) &&
|
||||||
|
TryComp(uid, out MovementSpeedModifierComponent? movementSlowdownComponent))
|
||||||
|
{
|
||||||
|
_movement.RefreshMovementSpeedModifiers(uid, movementSlowdownComponent);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update UI
|
||||||
|
if (ThirstComponent.ThirstThresholdAlertTypes.TryGetValue(component.CurrentThirstThreshold, out var alertId))
|
||||||
|
{
|
||||||
|
_alerts.ShowAlert(uid, alertId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_alerts.ClearAlertCategory(uid, AlertCategory.Thirst);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (component.CurrentThirstThreshold)
|
||||||
|
{
|
||||||
|
case ThirstThreshold.OverHydrated:
|
||||||
|
component.LastThirstThreshold = component.CurrentThirstThreshold;
|
||||||
|
component.ActualDecayRate = component.BaseDecayRate * 1.2f;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var mod = component.CurrentThirstThreshold <= ThirstThreshold.Parched ? 0.75f : 1.0f;
|
case ThirstThreshold.Okay:
|
||||||
args.ModifySpeed(mod, mod);
|
component.LastThirstThreshold = component.CurrentThirstThreshold;
|
||||||
}
|
component.ActualDecayRate = component.BaseDecayRate;
|
||||||
|
return;
|
||||||
|
|
||||||
private void OnRejuvenate(EntityUid uid, ThirstComponent component, RejuvenateEvent args)
|
case ThirstThreshold.Thirsty:
|
||||||
{
|
// Same as okay except with UI icon saying drink soon.
|
||||||
ResetThirst(component);
|
component.LastThirstThreshold = component.CurrentThirstThreshold;
|
||||||
}
|
component.ActualDecayRate = component.BaseDecayRate * 0.8f;
|
||||||
|
return;
|
||||||
|
case ThirstThreshold.Parched:
|
||||||
|
_movement.RefreshMovementSpeedModifiers(uid);
|
||||||
|
component.LastThirstThreshold = component.CurrentThirstThreshold;
|
||||||
|
component.ActualDecayRate = component.BaseDecayRate * 0.6f;
|
||||||
|
return;
|
||||||
|
|
||||||
private ThirstThreshold GetThirstThreshold(ThirstComponent component, float amount)
|
case ThirstThreshold.Dead:
|
||||||
|
return;
|
||||||
|
|
||||||
|
default:
|
||||||
|
_sawmill.Error($"No thirst threshold found for {component.CurrentThirstThreshold}");
|
||||||
|
throw new ArgumentOutOfRangeException($"No thirst threshold found for {component.CurrentThirstThreshold}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Update(float frameTime)
|
||||||
|
{
|
||||||
|
_accumulatedFrameTime += frameTime;
|
||||||
|
|
||||||
|
if (_accumulatedFrameTime > 1)
|
||||||
{
|
{
|
||||||
ThirstThreshold result = ThirstThreshold.Dead;
|
var query = EntityManager.EntityQueryEnumerator<ThirstComponent>();
|
||||||
var value = component.ThirstThresholds[ThirstThreshold.OverHydrated];
|
while (query.MoveNext(out var uid, out var comp))
|
||||||
foreach (var threshold in component.ThirstThresholds)
|
|
||||||
{
|
{
|
||||||
if (threshold.Value <= value && threshold.Value >= amount)
|
UpdateThirst(comp, - comp.ActualDecayRate);
|
||||||
|
var calculatedThirstThreshold = GetThirstThreshold(comp, comp.CurrentThirst);
|
||||||
|
if (calculatedThirstThreshold != comp.CurrentThirstThreshold)
|
||||||
{
|
{
|
||||||
result = threshold.Key;
|
comp.CurrentThirstThreshold = calculatedThirstThreshold;
|
||||||
value = threshold.Value;
|
UpdateEffects(uid, comp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_accumulatedFrameTime -= 1;
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateThirst(ThirstComponent component, float amount)
|
|
||||||
{
|
|
||||||
component.CurrentThirst = Math.Clamp(component.CurrentThirst + amount, component.ThirstThresholds[ThirstThreshold.Dead], component.ThirstThresholds[ThirstThreshold.OverHydrated]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ResetThirst(ThirstComponent component)
|
|
||||||
{
|
|
||||||
component.CurrentThirst = component.ThirstThresholds[ThirstThreshold.Okay];
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool IsMovementThreshold(ThirstThreshold threshold)
|
|
||||||
{
|
|
||||||
switch (threshold)
|
|
||||||
{
|
|
||||||
case ThirstThreshold.Dead:
|
|
||||||
case ThirstThreshold.Parched:
|
|
||||||
return true;
|
|
||||||
case ThirstThreshold.Thirsty:
|
|
||||||
case ThirstThreshold.Okay:
|
|
||||||
case ThirstThreshold.OverHydrated:
|
|
||||||
return false;
|
|
||||||
default:
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(threshold), threshold, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateEffects(ThirstComponent component)
|
|
||||||
{
|
|
||||||
if (IsMovementThreshold(component.LastThirstThreshold) != IsMovementThreshold(component.CurrentThirstThreshold) &&
|
|
||||||
TryComp(component.Owner, out MovementSpeedModifierComponent? movementSlowdownComponent))
|
|
||||||
{
|
|
||||||
_movement.RefreshMovementSpeedModifiers(component.Owner, movementSlowdownComponent);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update UI
|
|
||||||
if (ThirstComponent.ThirstThresholdAlertTypes.TryGetValue(component.CurrentThirstThreshold, out var alertId))
|
|
||||||
{
|
|
||||||
_alerts.ShowAlert(component.Owner, alertId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_alerts.ClearAlertCategory(component.Owner, AlertCategory.Thirst);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (component.CurrentThirstThreshold)
|
|
||||||
{
|
|
||||||
case ThirstThreshold.OverHydrated:
|
|
||||||
component.LastThirstThreshold = component.CurrentThirstThreshold;
|
|
||||||
component.ActualDecayRate = component.BaseDecayRate * 1.2f;
|
|
||||||
return;
|
|
||||||
|
|
||||||
case ThirstThreshold.Okay:
|
|
||||||
component.LastThirstThreshold = component.CurrentThirstThreshold;
|
|
||||||
component.ActualDecayRate = component.BaseDecayRate;
|
|
||||||
return;
|
|
||||||
|
|
||||||
case ThirstThreshold.Thirsty:
|
|
||||||
// Same as okay except with UI icon saying drink soon.
|
|
||||||
component.LastThirstThreshold = component.CurrentThirstThreshold;
|
|
||||||
component.ActualDecayRate = component.BaseDecayRate * 0.8f;
|
|
||||||
return;
|
|
||||||
case ThirstThreshold.Parched:
|
|
||||||
_movement.RefreshMovementSpeedModifiers(component.Owner);
|
|
||||||
component.LastThirstThreshold = component.CurrentThirstThreshold;
|
|
||||||
component.ActualDecayRate = component.BaseDecayRate * 0.6f;
|
|
||||||
return;
|
|
||||||
|
|
||||||
case ThirstThreshold.Dead:
|
|
||||||
return;
|
|
||||||
|
|
||||||
default:
|
|
||||||
_sawmill.Error($"No thirst threshold found for {component.CurrentThirstThreshold}");
|
|
||||||
throw new ArgumentOutOfRangeException($"No thirst threshold found for {component.CurrentThirstThreshold}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public override void Update(float frameTime)
|
|
||||||
{
|
|
||||||
_accumulatedFrameTime += frameTime;
|
|
||||||
|
|
||||||
if (_accumulatedFrameTime > 1)
|
|
||||||
{
|
|
||||||
foreach (var component in EntityManager.EntityQuery<ThirstComponent>())
|
|
||||||
{
|
|
||||||
UpdateThirst(component, - component.ActualDecayRate);
|
|
||||||
var calculatedThirstThreshold = GetThirstThreshold(component, component.CurrentThirst);
|
|
||||||
if (calculatedThirstThreshold != component.CurrentThirstThreshold)
|
|
||||||
{
|
|
||||||
component.CurrentThirstThreshold = calculatedThirstThreshold;
|
|
||||||
UpdateEffects(component);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_accumulatedFrameTime -= 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
parent: Puddle
|
parent: Puddle
|
||||||
abstract: true
|
abstract: true
|
||||||
components:
|
components:
|
||||||
- type: Transform
|
- type: Transform
|
||||||
anchored: true
|
anchored: true
|
||||||
noRot: false
|
noRot: false
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: PuddleSmear
|
id: PuddleSmear
|
||||||
@@ -16,67 +16,67 @@
|
|||||||
id: PuddleVomit
|
id: PuddleVomit
|
||||||
parent: PuddleTemporary
|
parent: PuddleTemporary
|
||||||
components:
|
components:
|
||||||
- type: SolutionContainerManager
|
- type: SolutionContainerManager
|
||||||
solutions:
|
solutions:
|
||||||
puddle:
|
puddle:
|
||||||
maxVol: 1000
|
maxVol: 1000
|
||||||
reagents:
|
reagents:
|
||||||
- ReagentId: Nutriment
|
- ReagentId: Nutriment
|
||||||
Quantity: 5
|
Quantity: 5
|
||||||
- ReagentId: Water
|
- ReagentId: Water
|
||||||
Quantity: 5
|
Quantity: 5
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: PuddleEgg
|
id: PuddleEgg
|
||||||
parent: PuddleTemporary
|
parent: PuddleTemporary
|
||||||
components:
|
components:
|
||||||
- type: SolutionContainerManager
|
- type: SolutionContainerManager
|
||||||
solutions:
|
solutions:
|
||||||
puddle:
|
puddle:
|
||||||
maxVol: 1000
|
maxVol: 1000
|
||||||
reagents:
|
reagents:
|
||||||
- ReagentId: Egg
|
- ReagentId: Egg
|
||||||
Quantity: 6 # same as when cooking
|
Quantity: 6 # same as when cooking
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: PuddleTomato
|
id: PuddleTomato
|
||||||
parent: PuddleTemporary
|
parent: PuddleTemporary
|
||||||
components:
|
components:
|
||||||
- type: SolutionContainerManager
|
- type: SolutionContainerManager
|
||||||
solutions:
|
solutions:
|
||||||
puddle:
|
puddle:
|
||||||
maxVol: 1000
|
maxVol: 1000
|
||||||
reagents:
|
reagents:
|
||||||
- ReagentId: Nutriment
|
- ReagentId: Nutriment
|
||||||
Quantity: 5
|
Quantity: 5
|
||||||
- ReagentId: Water
|
- ReagentId: Water
|
||||||
Quantity: 5
|
Quantity: 5
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: PuddleWatermelon
|
id: PuddleWatermelon
|
||||||
parent: PuddleTemporary
|
parent: PuddleTemporary
|
||||||
components:
|
components:
|
||||||
- type: SolutionContainerManager
|
- type: SolutionContainerManager
|
||||||
solutions:
|
solutions:
|
||||||
puddle:
|
puddle:
|
||||||
maxVol: 1000
|
maxVol: 1000
|
||||||
reagents:
|
reagents:
|
||||||
- ReagentId: Nutriment
|
- ReagentId: Nutriment
|
||||||
Quantity: 15
|
Quantity: 15
|
||||||
- ReagentId: Water
|
- ReagentId: Water
|
||||||
Quantity: 15
|
Quantity: 15
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: PuddleFlour
|
id: PuddleFlour
|
||||||
parent: PuddleTemporary
|
parent: PuddleTemporary
|
||||||
components:
|
components:
|
||||||
- type: SolutionContainerManager
|
- type: SolutionContainerManager
|
||||||
solutions:
|
solutions:
|
||||||
puddle:
|
puddle:
|
||||||
maxVol: 1000
|
maxVol: 1000
|
||||||
reagents:
|
reagents:
|
||||||
- ReagentId: Flour
|
- ReagentId: Flour
|
||||||
Quantity: 15
|
Quantity: 15
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
id: PuddleSparkle
|
id: PuddleSparkle
|
||||||
@@ -105,57 +105,58 @@
|
|||||||
placement:
|
placement:
|
||||||
mode: SnapgridCenter
|
mode: SnapgridCenter
|
||||||
components:
|
components:
|
||||||
- type: Clickable
|
- type: Clickable
|
||||||
- type: FootstepModifier
|
- type: FootstepModifier
|
||||||
footstepSoundCollection:
|
footstepSoundCollection:
|
||||||
collection: FootstepWater
|
collection: FootstepWater
|
||||||
params:
|
params:
|
||||||
volume: 6
|
volume: 6
|
||||||
- type: Slippery
|
- type: Slippery
|
||||||
launchForwardsMultiplier: 2.0
|
launchForwardsMultiplier: 2.0
|
||||||
- type: Transform
|
- type: Transform
|
||||||
noRot: true
|
noRot: true
|
||||||
anchored: true
|
anchored: true
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
layers:
|
layers:
|
||||||
- sprite: Fluids/puddle.rsi
|
- sprite: Fluids/puddle.rsi
|
||||||
state: splat0
|
state: splat0
|
||||||
drawdepth: FloorObjects
|
drawdepth: FloorObjects
|
||||||
color: "#FFFFFF80"
|
color: "#FFFFFF80"
|
||||||
- type: Physics
|
- type: Physics
|
||||||
bodyType: Static
|
bodyType: Static
|
||||||
- type: Fixtures
|
- type: Fixtures
|
||||||
fixtures:
|
fixtures:
|
||||||
slipFixture:
|
slipFixture:
|
||||||
shape:
|
shape:
|
||||||
!type:PhysShapeAabb
|
!type:PhysShapeAabb
|
||||||
bounds: "-0.4,-0.4,0.4,0.4"
|
bounds: "-0.4,-0.4,0.4,0.4"
|
||||||
mask:
|
mask:
|
||||||
- ItemMask
|
- ItemMask
|
||||||
layer:
|
layer:
|
||||||
- SlipLayer
|
- SlipLayer
|
||||||
hard: false
|
hard: false
|
||||||
- type: IconSmooth
|
- type: IconSmooth
|
||||||
key: puddles
|
key: puddles
|
||||||
base: splat
|
base: splat
|
||||||
mode: CardinalFlags
|
mode: CardinalFlags
|
||||||
- type: SolutionContainerManager
|
- type: SolutionContainerManager
|
||||||
solutions:
|
solutions:
|
||||||
puddle: { maxVol: 1000 }
|
puddle: { maxVol: 1000 }
|
||||||
- type: Puddle
|
- type: Puddle
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
- type: EdgeSpreader
|
- type: EdgeSpreader
|
||||||
- type: StepTrigger
|
- type: StepTrigger
|
||||||
- type: NodeContainer
|
- type: NodeContainer
|
||||||
nodes:
|
nodes:
|
||||||
puddle:
|
puddle:
|
||||||
!type:SpreaderNode
|
!type:SpreaderNode
|
||||||
nodeGroupID: Spreader
|
nodeGroupID: Spreader
|
||||||
- type: Drink
|
- type: Drink
|
||||||
isOpen: true
|
isOpen: true
|
||||||
delay: 3
|
delay: 3
|
||||||
transferAmount: 1
|
transferAmount: 1
|
||||||
solution: puddle
|
solution: puddle
|
||||||
examinable: false
|
examinable: false
|
||||||
- type: ExaminableSolution
|
- type: ExaminableSolution
|
||||||
solution: puddle
|
solution: puddle
|
||||||
|
- type: BadDrink
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
- type: htnCompound
|
- type: htnCompound
|
||||||
id: FoodCompound
|
id: FoodCompound
|
||||||
branches:
|
branches:
|
||||||
- tasks:
|
- tasks:
|
||||||
- id: PickFoodTargetPrimitive
|
- id: PickFoodTargetPrimitive
|
||||||
- id: MoveToCombatTargetPrimitive
|
- id: MoveToCombatTargetPrimitive
|
||||||
- id: EatPrimitive
|
- id: EatPrimitive
|
||||||
- id: WaitIdleTimePrimitive
|
- id: WaitIdleTimePrimitive
|
||||||
|
- tasks:
|
||||||
|
- id: PickDrinkTargetPrimitive
|
||||||
|
- id: MoveToCombatTargetPrimitive
|
||||||
|
- id: EatPrimitive
|
||||||
|
- id: WaitIdleTimePrimitive
|
||||||
|
|
||||||
|
|
||||||
- type: htnPrimitive
|
- type: htnPrimitive
|
||||||
@@ -13,9 +18,14 @@
|
|||||||
operator: !type:UtilityOperator
|
operator: !type:UtilityOperator
|
||||||
proto: NearbyFood
|
proto: NearbyFood
|
||||||
|
|
||||||
|
- type: htnPrimitive
|
||||||
|
id: PickDrinkTargetPrimitive
|
||||||
|
operator: !type:UtilityOperator
|
||||||
|
proto: NearbyDrink
|
||||||
|
|
||||||
- type: htnPrimitive
|
- type: htnPrimitive
|
||||||
id: EatPrimitive
|
id: EatPrimitive
|
||||||
preconditions:
|
preconditions:
|
||||||
- !type:KeyExistsPrecondition
|
- !type:KeyExistsPrecondition
|
||||||
key: CombatTarget
|
key: CombatTarget
|
||||||
operator: !type:AltInteractOperator
|
operator: !type:AltInteractOperator
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
query:
|
query:
|
||||||
- !type:ComponentQuery
|
- !type:ComponentQuery
|
||||||
components:
|
components:
|
||||||
- type: Food
|
- type: Food
|
||||||
considerations:
|
considerations:
|
||||||
- !type:TargetIsAliveCon
|
- !type:TargetIsAliveCon
|
||||||
curve: !type:InverseBoolCurve
|
curve: !type:InverseBoolCurve
|
||||||
@@ -17,6 +17,25 @@
|
|||||||
- !type:TargetAccessibleCon
|
- !type:TargetAccessibleCon
|
||||||
curve: !type:BoolCurve
|
curve: !type:BoolCurve
|
||||||
|
|
||||||
|
- type: utilityQuery
|
||||||
|
id: NearbyDrink
|
||||||
|
query:
|
||||||
|
- !type:ComponentQuery
|
||||||
|
components:
|
||||||
|
- type: Drink
|
||||||
|
considerations:
|
||||||
|
- !type:TargetIsAliveCon
|
||||||
|
curve: !type:InverseBoolCurve
|
||||||
|
- !type:TargetDistanceCon
|
||||||
|
curve: !type:PresetCurve
|
||||||
|
preset: TargetDistance
|
||||||
|
- !type:DrinkValueCon
|
||||||
|
curve: !type:QuadraticCurve
|
||||||
|
slope: 1.0
|
||||||
|
exponent: 0.4
|
||||||
|
- !type:TargetAccessibleCon
|
||||||
|
curve: !type:BoolCurve
|
||||||
|
|
||||||
- type: utilityQuery
|
- type: utilityQuery
|
||||||
id: NearbyMeleeTargets
|
id: NearbyMeleeTargets
|
||||||
query:
|
query:
|
||||||
|
|||||||
Reference in New Issue
Block a user