ReagentEntityReaction uses EntityUid
This commit is contained in:
@@ -20,15 +20,15 @@ namespace Content.Server.Chemistry.ReagentEntityReactions
|
|||||||
// ReSharper disable once CollectionNeverUpdated.Local
|
// ReSharper disable once CollectionNeverUpdated.Local
|
||||||
private readonly HashSet<string> _reagents = new();
|
private readonly HashSet<string> _reagents = new();
|
||||||
|
|
||||||
protected override void React(IEntity entity, ReagentPrototype reagent, FixedPoint2 volume, Solution? source)
|
protected override void React(EntityUid uid, ReagentPrototype reagent, FixedPoint2 volume, Solution? source, IEntityManager entityManager)
|
||||||
{
|
{
|
||||||
// TODO see if this is correct
|
// TODO see if this is correct
|
||||||
if (!EntitySystem.Get<SolutionContainerSystem>()
|
if (!EntitySystem.Get<SolutionContainerSystem>()
|
||||||
.TryGetSolution(entity.Uid, _solution, out var solutionContainer)
|
.TryGetSolution(uid, _solution, out var solutionContainer)
|
||||||
|| (_reagents.Count > 0 && !_reagents.Contains(reagent.ID))) return;
|
|| (_reagents.Count > 0 && !_reagents.Contains(reagent.ID))) return;
|
||||||
|
|
||||||
if (EntitySystem.Get<SolutionContainerSystem>()
|
if (EntitySystem.Get<SolutionContainerSystem>()
|
||||||
.TryAddReagent(entity.Uid, solutionContainer, reagent.ID, volume, out var accepted))
|
.TryAddReagent(uid, solutionContainer, reagent.ID, volume, out var accepted))
|
||||||
source?.RemoveReagent(reagent.ID, accepted);
|
source?.RemoveReagent(reagent.ID, accepted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,13 +18,13 @@ namespace Content.Server.Chemistry.ReagentEntityReactions
|
|||||||
// ReSharper disable once CollectionNeverUpdated.Local
|
// ReSharper disable once CollectionNeverUpdated.Local
|
||||||
private readonly HashSet<string> _reagents = new ();
|
private readonly HashSet<string> _reagents = new ();
|
||||||
|
|
||||||
protected override void React(IEntity entity, ReagentPrototype reagent, FixedPoint2 volume, Solution? source)
|
protected override void React(EntityUid uid, ReagentPrototype reagent, FixedPoint2 volume, Solution? source, IEntityManager entityManager)
|
||||||
{
|
{
|
||||||
if (!entity.TryGetComponent(out FlammableComponent? flammable) || !_reagents.Contains(reagent.ID)) return;
|
if (!entityManager.TryGetComponent(uid, out FlammableComponent? flammable) || !_reagents.Contains(reagent.ID)) return;
|
||||||
|
|
||||||
var flammableSystem = EntitySystem.Get<FlammableSystem>();
|
var flammableSystem = EntitySystem.Get<FlammableSystem>();
|
||||||
flammableSystem.Extinguish(entity.Uid, flammable);
|
flammableSystem.Extinguish(uid, flammable);
|
||||||
flammableSystem.AdjustFireStacks(entity.Uid, -1.5f, flammable);
|
flammableSystem.AdjustFireStacks(uid, -1.5f, flammable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ namespace Content.Server.Chemistry.ReagentEntityReactions
|
|||||||
// ReSharper disable once CollectionNeverUpdated.Local
|
// ReSharper disable once CollectionNeverUpdated.Local
|
||||||
private readonly HashSet<string> _reagents = new ();
|
private readonly HashSet<string> _reagents = new ();
|
||||||
|
|
||||||
protected override void React(IEntity entity, ReagentPrototype reagent, FixedPoint2 volume, Solution? source)
|
protected override void React(EntityUid uid, ReagentPrototype reagent, FixedPoint2 volume, Solution? source, IEntityManager entityManager)
|
||||||
{
|
{
|
||||||
if (!entity.TryGetComponent(out FlammableComponent? flammable) || !_reagents.Contains(reagent.ID)) return;
|
if (!entityManager.TryGetComponent(uid, out FlammableComponent? flammable) || !_reagents.Contains(reagent.ID)) return;
|
||||||
|
|
||||||
EntitySystem.Get<FlammableSystem>().AdjustFireStacks(entity.Uid, volume.Float() / 10f, flammable);
|
EntitySystem.Get<FlammableSystem>().AdjustFireStacks(uid, volume.Float() / 10f, flammable);
|
||||||
source?.RemoveReagent(reagent.ID, volume);
|
source?.RemoveReagent(reagent.ID, volume);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ namespace Content.Server.Chemistry.ReagentEntityReactions
|
|||||||
// ReSharper disable once CollectionNeverUpdated.Local
|
// ReSharper disable once CollectionNeverUpdated.Local
|
||||||
private readonly HashSet<string> _reagents = new ();
|
private readonly HashSet<string> _reagents = new ();
|
||||||
|
|
||||||
protected override void React(IEntity entity, ReagentPrototype reagent, FixedPoint2 volume, Solution? source)
|
protected override void React(EntityUid uid, ReagentPrototype reagent, FixedPoint2 volume, Solution? source, IEntityManager entityManager)
|
||||||
{
|
{
|
||||||
if (!entity.TryGetComponent(out CreamPiedComponent? creamPied) || !_reagents.Contains(reagent.ID)) return;
|
if (!entityManager.TryGetComponent(uid, out CreamPiedComponent? creamPied) || !_reagents.Contains(reagent.ID)) return;
|
||||||
|
|
||||||
EntitySystem.Get<CreamPieSystem>().SetCreamPied(entity.Uid, creamPied, false);
|
EntitySystem.Get<CreamPieSystem>().SetCreamPied(uid, creamPied, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace Content.Shared.Chemistry
|
|||||||
foreach (var reaction in reactive.Reactions)
|
foreach (var reaction in reactive.Reactions)
|
||||||
{
|
{
|
||||||
// If we have a source solution, use the reagent quantity we have left. Otherwise, use the reaction volume specified.
|
// If we have a source solution, use the reagent quantity we have left. Otherwise, use the reaction volume specified.
|
||||||
reaction.React(method, entity, reagent, source?.GetReagentQuantity(reagent.ID) ?? reactVolume, source);
|
reaction.React(method, entity.Uid, reagent, source?.GetReagentQuantity(reagent.ID) ?? reactVolume, source, EntityManager);
|
||||||
|
|
||||||
// Make sure we still have enough reagent to go...
|
// Make sure we still have enough reagent to go...
|
||||||
if (source != null && !source.ContainsReagent(reagent.ID))
|
if (source != null && !source.ContainsReagent(reagent.ID))
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace Content.Shared.Chemistry.Reagent
|
|||||||
[DataField("ingestion")]
|
[DataField("ingestion")]
|
||||||
public bool Ingestion { get; } = false;
|
public bool Ingestion { get; } = false;
|
||||||
|
|
||||||
public void React(ReactionMethod method, IEntity entity, ReagentPrototype reagent, FixedPoint2 volume, Components.Solution? source)
|
public void React(ReactionMethod method, EntityUid uid, ReagentPrototype reagent, FixedPoint2 volume, Components.Solution? source, IEntityManager entityManager)
|
||||||
{
|
{
|
||||||
switch (method)
|
switch (method)
|
||||||
{
|
{
|
||||||
@@ -48,9 +48,9 @@ namespace Content.Shared.Chemistry.Reagent
|
|||||||
throw new ArgumentOutOfRangeException(nameof(method), method, null);
|
throw new ArgumentOutOfRangeException(nameof(method), method, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
React(entity, reagent, volume, source);
|
React(uid, reagent, volume, source, entityManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void React(IEntity entity, ReagentPrototype reagent, FixedPoint2 volume, Components.Solution? source);
|
protected abstract void React(EntityUid uid, ReagentPrototype reagent, FixedPoint2 volume, Components.Solution? source, IEntityManager entityManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user