Allow solutions to store extra reagent data (#19323)

This commit is contained in:
Leon Friedrich
2023-09-05 09:55:10 +12:00
committed by GitHub
parent a6b81058d0
commit e4ca6f4fb9
52 changed files with 932 additions and 538 deletions

View File

@@ -101,7 +101,7 @@ public sealed class DrinkSystem : EntitySystem
var total = 0f;
foreach (var quantity in solution.Contents)
{
var reagent = _proto.Index<ReagentPrototype>(quantity.ReagentId);
var reagent = _proto.Index<ReagentPrototype>(quantity.Reagent.Prototype);
if (reagent.Metabolisms == null)
continue;

View File

@@ -84,9 +84,9 @@ public sealed class FlavorProfileSystem : EntitySystem
private HashSet<string> GetFlavorsFromReagents(Solution solution, int desiredAmount, HashSet<string>? toIgnore = null)
{
var flavors = new HashSet<string>();
foreach (var reagent in solution.Contents)
foreach (var (reagent, quantity) in solution.GetReagentPrototypes(_prototypeManager))
{
if (toIgnore != null && toIgnore.Contains(reagent.ReagentId))
if (toIgnore != null && toIgnore.Contains(reagent.ID))
{
continue;
}
@@ -96,15 +96,14 @@ public sealed class FlavorProfileSystem : EntitySystem
break;
}
var proto = _prototypeManager.Index<ReagentPrototype>(reagent.ReagentId);
// don't care if the quantity is negligible
if (reagent.Quantity < proto.FlavorMinimum)
if (quantity < reagent.FlavorMinimum)
{
continue;
}
if (proto.Flavor != null)
flavors.Add(proto.Flavor);
if (reagent.Flavor != null)
flavors.Add(reagent.Flavor);
}
return flavors;

View File

@@ -35,7 +35,7 @@ namespace Content.Server.Nutrition.EntitySystems
SubscribeLocalEvent<VapeComponent, GotEmaggedEvent>(OnEmagged);
}
private void OnVapeInteraction(EntityUid uid, VapeComponent comp, AfterInteractEvent args)
private void OnVapeInteraction(EntityUid uid, VapeComponent comp, AfterInteractEvent args)
{
_solutionContainerSystem.TryGetRefillableSolution(uid, out var solution);
@@ -44,11 +44,12 @@ namespace Content.Server.Nutrition.EntitySystems
var exploded = false;
if (!args.CanReach
|| solution == null
|| comp.CancelToken != null
|| !TryComp<BloodstreamComponent>(args.Target, out var _)
|| _foodSystem.IsMouthBlocked(args.Target.Value, args.User))
|| solution == null
|| !HasComp<BloodstreamComponent>(args.Target)
|| _foodSystem.IsMouthBlocked(args.Target.Value, args.User))
{
return;
}
if (solution.Contents.Count == 0)
{
@@ -72,9 +73,14 @@ namespace Content.Server.Nutrition.EntitySystems
}
else
{
// All vapes explode if they contain anything other than pure water???
// WTF is this? Why is this? Am I going insane?
// Who the fuck vapes pure water?
// If this isn't how this is meant to work and this is meant to be for vapes with plasma or something,
// just re-use the existing RiggableSystem.
foreach (var name in solution.Contents)
{
if (name.ReagentId != comp.SolutionNeeded)
if (name.Reagent.Prototype != comp.SolutionNeeded)
{
exploded = true;
_explosionSystem.QueueExplosion(uid, "Default", comp.ExplosionIntensity, 0.5f, 3, canCreateVacuum: false);
@@ -92,7 +98,7 @@ namespace Content.Server.Nutrition.EntitySystems
_popupSystem.PopupEntity(
Loc.GetString("vape-component-try-use-vape-forced", ("user", userName)), args.Target.Value,
args.Target.Value);
_popupSystem.PopupEntity(
Loc.GetString("vape-component-try-use-vape-forced-user", ("target", targetName)), args.User,
args.User);
@@ -106,8 +112,6 @@ namespace Content.Server.Nutrition.EntitySystems
if (!exploded)
{
comp.CancelToken = new CancellationTokenSource();
var vapeDoAfterEvent = new VapeDoAfterEvent(solution, forced);
_doAfterSystem.TryStartDoAfter(new DoAfterArgs(args.User, delay, vapeDoAfterEvent, uid, target: args.Target, used: uid)
{
@@ -121,14 +125,6 @@ namespace Content.Server.Nutrition.EntitySystems
private void OnVapeDoAfter(EntityUid uid, VapeComponent comp, VapeDoAfterEvent args)
{
if (args.Cancelled)
{
comp.CancelToken = null;
return;
}
comp.CancelToken = null;
if (args.Handled
|| args.Args.Target == null)
return;
@@ -148,7 +144,7 @@ namespace Content.Server.Nutrition.EntitySystems
_atmosphereSystem.Merge(environment, merger);
args.Solution.RemoveAllSolution();
if (args.Forced)
{
var targetName = Identity.Entity(args.Args.Target.Value, EntityManager);
@@ -157,7 +153,7 @@ namespace Content.Server.Nutrition.EntitySystems
_popupSystem.PopupEntity(
Loc.GetString("vape-component-vape-success-forced", ("user", userName)), args.Args.Target.Value,
args.Args.Target.Value);
_popupSystem.PopupEntity(
Loc.GetString("vape-component-vape-success-user-forced", ("target", targetName)), args.Args.User,
args.Args.Target.Value);