rebase
This commit is contained in:
@@ -34,6 +34,7 @@ public sealed class MetabolizerSystem : SharedMetabolizerSystem
|
||||
[Dependency] private readonly SharedEntityConditionsSystem _entityConditions = default!;
|
||||
[Dependency] private readonly SharedEntityEffectsSystem _entityEffects = default!;
|
||||
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!;
|
||||
[Dependency] private readonly Content.Shared.StatusEffectNew.StatusEffectsSystem _statusEffects = default!;
|
||||
|
||||
private EntityQuery<OrganComponent> _organQuery;
|
||||
private EntityQuery<SolutionContainerManagerComponent> _solutionQuery;
|
||||
@@ -129,7 +130,7 @@ public sealed class MetabolizerSystem : SharedMetabolizerSystem
|
||||
if (solutionEntityUid is null
|
||||
|| soln is null
|
||||
|| solution is null
|
||||
|| solution.Contents.Count == 0)
|
||||
|| (solution.Contents.Count == 0 && ent.Comp1.MetabolizingReagents.Count == 0 && ent.Comp1.Metabolites.Count == 0)) // Offbrand - we need to ensure we clear out metabolizing reagents
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -139,6 +140,7 @@ public sealed class MetabolizerSystem : SharedMetabolizerSystem
|
||||
var list = solution.Contents.ToArray();
|
||||
_random.Shuffle(list);
|
||||
|
||||
var metabolized = new HashSet<ProtoId<ReagentPrototype>>(); // Offbrand
|
||||
int reagents = 0;
|
||||
foreach (var (reagent, quantity) in list)
|
||||
{
|
||||
@@ -156,10 +158,13 @@ public sealed class MetabolizerSystem : SharedMetabolizerSystem
|
||||
continue;
|
||||
}
|
||||
|
||||
// Offbrand - keep processing for status effects and metabolites
|
||||
// we're done here entirely if this is true
|
||||
if (reagents >= ent.Comp1.MaxReagentsProcessable)
|
||||
return;
|
||||
// if (reagents >= ent.Comp1.MaxReagentsProcessable)
|
||||
// return;
|
||||
|
||||
metabolized.Add(reagent.Prototype);
|
||||
// End Offbrand
|
||||
|
||||
// loop over all our groups and see which ones apply
|
||||
if (ent.Comp1.MetabolismGroups is null)
|
||||
@@ -194,6 +199,16 @@ public sealed class MetabolizerSystem : SharedMetabolizerSystem
|
||||
|
||||
var actualEntity = ent.Comp2?.Body ?? solutionEntityUid.Value;
|
||||
|
||||
// Begin Offbrand - status effects
|
||||
foreach (var effect in entry.StatusEffects)
|
||||
{
|
||||
if (!_entityConditions.TryConditions(actualEntity, effect.Conditions))
|
||||
_statusEffects.TryRemoveStatusEffect(actualEntity, effect.StatusEffect);
|
||||
else
|
||||
_statusEffects.TryUpdateStatusEffectDuration(actualEntity, effect.StatusEffect, out _);
|
||||
}
|
||||
// End Offbrand - status effects
|
||||
|
||||
// do all effects, if conditions apply
|
||||
foreach (var effect in entry.Effects)
|
||||
{
|
||||
@@ -232,13 +247,80 @@ public sealed class MetabolizerSystem : SharedMetabolizerSystem
|
||||
// remove a certain amount of reagent
|
||||
if (mostToRemove > FixedPoint2.Zero)
|
||||
{
|
||||
solution.RemoveReagent(reagent, mostToRemove);
|
||||
var removed = solution.RemoveReagent(reagent, mostToRemove); // Offbrand
|
||||
|
||||
// We have processed a reagant, so count it towards the cap
|
||||
reagents += 1;
|
||||
|
||||
// Begin Offbrand - track metabbolites
|
||||
if (!ent.Comp1.Metabolites.ContainsKey(reagent.Prototype))
|
||||
ent.Comp1.Metabolites[reagent.Prototype] = 0;
|
||||
ent.Comp1.Metabolites[reagent.Prototype] += removed;
|
||||
// End Offbrand - track metabbolites
|
||||
}
|
||||
}
|
||||
|
||||
// Begin Offbrand
|
||||
foreach (var reagent in ent.Comp1.MetabolizingReagents)
|
||||
{
|
||||
if (metabolized.Contains(reagent))
|
||||
continue;
|
||||
|
||||
var proto = _prototypeManager.Index(reagent);
|
||||
var actualEntity = ent.Comp2?.Body ?? solutionEntityUid.Value;
|
||||
|
||||
if (ent.Comp1.MetabolismGroups is null)
|
||||
continue;
|
||||
|
||||
foreach (var group in ent.Comp1.MetabolismGroups)
|
||||
{
|
||||
if (proto.Metabolisms is null)
|
||||
continue;
|
||||
|
||||
if (!proto.Metabolisms.TryGetValue(group.Id, out var entry))
|
||||
continue;
|
||||
|
||||
foreach (var effect in entry.StatusEffects)
|
||||
{
|
||||
_statusEffects.TryRemoveStatusEffect(actualEntity, effect.StatusEffect);
|
||||
}
|
||||
}
|
||||
}
|
||||
ent.Comp1.MetabolizingReagents = metabolized;
|
||||
|
||||
foreach (var metaboliteReagent in ent.Comp1.Metabolites.Keys)
|
||||
{
|
||||
if (ent.Comp1.MetabolizingReagents.Contains(metaboliteReagent))
|
||||
continue;
|
||||
|
||||
if (!_prototypeManager.Resolve(metaboliteReagent, out var proto) || proto.Metabolisms is not { } metabolisms)
|
||||
continue;
|
||||
|
||||
if (ent.Comp1.MetabolismGroups is null)
|
||||
continue;
|
||||
|
||||
ReagentEffectsEntry? entry = null;
|
||||
var metabolismRateModifier = FixedPoint2.Zero;
|
||||
foreach (var group in ent.Comp1.MetabolismGroups)
|
||||
{
|
||||
if (!proto.Metabolisms.TryGetValue(group.Id, out entry))
|
||||
continue;
|
||||
|
||||
metabolismRateModifier = group.MetabolismRateModifier;
|
||||
break;
|
||||
}
|
||||
|
||||
if (entry is not { } metabolismEntry)
|
||||
continue;
|
||||
|
||||
var rate = metabolismEntry.MetabolismRate * metabolismRateModifier * ent.Comp1.MetaboliteDecayFactor;
|
||||
ent.Comp1.Metabolites[metaboliteReagent] -= rate;
|
||||
|
||||
if (ent.Comp1.Metabolites[metaboliteReagent] <= 0)
|
||||
ent.Comp1.Metabolites.Remove(metaboliteReagent);
|
||||
}
|
||||
// End Offbrand
|
||||
|
||||
_solutionContainerSystem.UpdateChemicals(soln.Value);
|
||||
}
|
||||
|
||||
|
||||
@@ -259,12 +259,12 @@ namespace Content.Server.Zombies
|
||||
args.Handled = true;
|
||||
continue;
|
||||
}
|
||||
else if (!HasComp<WoundableComponent>(entity)) // Offbrand
|
||||
else if (!HasComp<WoundableComponent>(uid)) // Offbrand
|
||||
{
|
||||
if (!HasComp<ZombieImmuneComponent>(entity) && !HasComp<NonSpreaderZombieComponent>(args.User) && _random.Prob(GetZombieInfectionChance(entity, component)))
|
||||
if (!HasComp<ZombieImmuneComponent>(uid) && !cannotSpread && _random.Prob(GetZombieInfectionChance(uid, entity.Comp)))
|
||||
{
|
||||
EnsureComp<PendingZombieComponent>(entity);
|
||||
EnsureComp<ZombifyOnDeathComponent>(entity);
|
||||
EnsureComp<PendingZombieComponent>(uid);
|
||||
EnsureComp<ZombifyOnDeathComponent>(uid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,48 +1,50 @@
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Shared._Offbrand.EntityEffects;
|
||||
using Content.Shared.EntityEffects;
|
||||
using Content.Shared.Body.Organ;
|
||||
using Content.Shared.Chemistry.Components.SolutionManager;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.EntityConditions;
|
||||
using Content.Shared.FixedPoint;
|
||||
|
||||
namespace Content.Server._Offbrand.EntityEffects;
|
||||
|
||||
public sealed class MetaboliteThresholdSystem : EntitySystem
|
||||
public sealed class MetaboliteThresholdEntityConditionSystem : EntityConditionSystem<MetabolizerComponent, MetaboliteThresholdCondition>
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainer = default!;
|
||||
|
||||
SubscribeLocalEvent<CheckEntityEffectConditionEvent<MetaboliteThreshold>>(OnCheckMetaboliteThreshold);
|
||||
private Solution? GetSolution(Entity<MetabolizerComponent, OrganComponent?> ent)
|
||||
{
|
||||
if (!Resolve(ent, ref ent.Comp2, false))
|
||||
return null;
|
||||
|
||||
if (ent.Comp1.SolutionOnBody)
|
||||
{
|
||||
if (ent.Comp2.Body is { } body && _solutionContainer.TryGetSolution(body, ent.Comp1.SolutionName, out _, out var solution))
|
||||
return solution;
|
||||
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_solutionContainer.TryGetSolution(ent.Owner, ent.Comp1.SolutionName, out _, out var solution))
|
||||
return solution;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void OnCheckMetaboliteThreshold(ref CheckEntityEffectConditionEvent<MetaboliteThreshold> args)
|
||||
protected override void Condition(Entity<MetabolizerComponent> ent, ref EntityConditionEvent<MetaboliteThresholdCondition> args)
|
||||
{
|
||||
if (args.Args is not EntityEffectReagentArgs reagentArgs)
|
||||
throw new NotImplementedException();
|
||||
|
||||
var reagent = args.Condition.Reagent;
|
||||
if (reagent == null)
|
||||
reagent = reagentArgs.Reagent?.ID;
|
||||
|
||||
if (reagent is not { } metaboliteReagent)
|
||||
{
|
||||
args.Result = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TryComp<MetabolizerComponent>(reagentArgs.OrganEntity, out var metabolizer))
|
||||
{
|
||||
args.Result = true;
|
||||
return;
|
||||
}
|
||||
|
||||
var metabolites = metabolizer.Metabolites;
|
||||
var metabolites = ent.Comp.Metabolites;
|
||||
|
||||
var quant = FixedPoint2.Zero;
|
||||
metabolites.TryGetValue(metaboliteReagent, out quant);
|
||||
metabolites.TryGetValue(reagent, out quant);
|
||||
|
||||
if (args.Condition.IncludeBloodstream && reagentArgs.Source != null)
|
||||
if (args.Condition.IncludeBloodstream && GetSolution((ent, ent.Comp, null)) is { } solution)
|
||||
{
|
||||
quant += reagentArgs.Source.GetTotalPrototypeQuantity(metaboliteReagent);
|
||||
quant += solution.GetTotalPrototypeQuantity(reagent);
|
||||
}
|
||||
|
||||
args.Result = quant >= args.Condition.Min && quant <= args.Condition.Max;
|
||||
|
||||
@@ -4,19 +4,12 @@ using Content.Shared.EntityEffects;
|
||||
|
||||
namespace Content.Server._Offbrand.EntityEffects;
|
||||
|
||||
public sealed class ZombifySystem : EntitySystem
|
||||
public sealed class ZombifySystem : EntityEffectSystem<MetaDataComponent, Zombify>
|
||||
{
|
||||
[Dependency] private readonly ZombieSystem _zombie = default!;
|
||||
|
||||
public override void Initialize()
|
||||
protected override void Effect(Entity<MetaDataComponent> ent, ref EntityEffectEvent<Zombify> args)
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<ExecuteEntityEffectEvent<Zombify>>(OnExecuteZombify);
|
||||
}
|
||||
|
||||
private void OnExecuteZombify(ref ExecuteEntityEffectEvent<Zombify> args)
|
||||
{
|
||||
_zombie.ZombifyEntity(args.Args.TargetEntity);
|
||||
_zombie.ZombifyEntity(ent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.EUI;
|
||||
using Content.Shared._Offbrand.MMI;
|
||||
using Content.Shared._Offbrand.Wounds;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Body.Systems;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Interaction;
|
||||
@@ -17,12 +17,12 @@ namespace Content.Server._Offbrand.MMI;
|
||||
public sealed class MMIExtractorSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly BrainDamageSystem _brainDamage = default!;
|
||||
[Dependency] private readonly ChatSystem _chat = default!;
|
||||
[Dependency] private readonly EntityWhitelistSystem _whitelist = default!;
|
||||
[Dependency] private readonly EuiManager _eui = default!;
|
||||
[Dependency] private readonly ISharedPlayerManager _player = default!;
|
||||
[Dependency] private readonly ItemSlotsSystem _slots = default!;
|
||||
[Dependency] private readonly SharedBodySystem _body = default!;
|
||||
[Dependency] private readonly SharedChatSystem _chat = default!;
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
|
||||
[Dependency] private readonly SharedMindSystem _mind = default!;
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
using Content.Server.Temperature.Components;
|
||||
using Content.Shared._Offbrand.Wounds;
|
||||
using Content.Shared.Body.Events;
|
||||
using Content.Shared.Body.Systems;
|
||||
using Content.Shared.Medical.Cryogenics;
|
||||
using Content.Shared.Temperature;
|
||||
|
||||
namespace Content.Server._Offbrand.Wounds;
|
||||
|
||||
public sealed class CryostasisFactorSystem : EntitySystem
|
||||
{
|
||||
[Dependency] protected readonly SharedMetabolizerSystem _metabolizer = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<CryostasisFactorComponent, OnTemperatureChangeEvent>(OnTemperatureChange);
|
||||
SubscribeLocalEvent<CryostasisFactorComponent, GetMetabolicMultiplierEvent>(OnGetMetabolicMultiplier);
|
||||
}
|
||||
|
||||
private void OnTemperatureChange(Entity<CryostasisFactorComponent> ent, ref OnTemperatureChangeEvent args)
|
||||
{
|
||||
_metabolizer.UpdateMetabolicMultiplier(ent);
|
||||
}
|
||||
|
||||
private void OnGetMetabolicMultiplier(Entity<CryostasisFactorComponent> ent, ref GetMetabolicMultiplierEvent args)
|
||||
{
|
||||
if (!TryComp<TemperatureComponent>(ent, out var temp))
|
||||
return;
|
||||
|
||||
args.Multiplier *= Math.Max(ent.Comp.TemperatureCoefficient * temp.CurrentTemperature + ent.Comp.TemperatureConstant, 1);
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
using Content.Server.Temperature.Components;
|
||||
using Content.Shared._Offbrand.Wounds;
|
||||
|
||||
namespace Content.Server._Offbrand.Wounds;
|
||||
|
||||
public sealed class LungDamageTemperatureSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly LungDamageSystem _lungDamage = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<LungDamageOnInhaledAirTemperatureComponent, BeforeInhaledGasEvent>(OnBeforeInhaledGas);
|
||||
}
|
||||
|
||||
private void OnBeforeInhaledGas(Entity<LungDamageOnInhaledAirTemperatureComponent> ent, ref BeforeInhaledGasEvent args)
|
||||
{
|
||||
var temperature = Comp<TemperatureComponent>(ent);
|
||||
|
||||
var heatDamageThreshold = temperature.ParentHeatDamageThreshold ?? temperature.HeatDamageThreshold;
|
||||
var coldDamageThreshold = temperature.ParentColdDamageThreshold ?? temperature.ColdDamageThreshold;
|
||||
|
||||
if (args.Gas.Temperature >= heatDamageThreshold)
|
||||
{
|
||||
var damage = ent.Comp.HeatCoefficient * args.Gas.Temperature + ent.Comp.HeatConstant;
|
||||
_lungDamage.TryModifyDamage(ent.Owner, damage);
|
||||
}
|
||||
else if (args.Gas.Temperature <= coldDamageThreshold)
|
||||
{
|
||||
var damage = ent.Comp.ColdCoefficient * args.Gas.Temperature + ent.Comp.ColdConstant;
|
||||
_lungDamage.TryModifyDamage(ent.Owner, damage);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user