Mobstate Refactor (#13389)

Refactors mobstate and moves mob health thresholds to their own component

Co-authored-by: DrSmugleaf <drsmugleaf@gmail.com>
This commit is contained in:
Jezithyr
2023-01-13 16:57:10 -08:00
committed by GitHub
parent 97e4c477bd
commit eeb5b17b34
148 changed files with 1517 additions and 1290 deletions

View File

@@ -1,5 +1,4 @@
using System.Threading;
using Content.Shared.MobState.Components;
using Content.Shared.Interaction;
using Content.Shared.Audio;
using Content.Shared.Jittering;
@@ -10,7 +9,6 @@ using Content.Shared.Nutrition.Components;
using Content.Shared.Administration.Logs;
using Content.Shared.CCVar;
using Content.Shared.Database;
using Content.Server.MobState;
using Content.Server.Power.Components;
using Content.Server.Fluids.EntitySystems;
using Content.Server.Body.Components;
@@ -21,6 +19,8 @@ using Content.Server.Materials;
using Content.Server.Mind.Components;
using Content.Shared.Humanoid;
using Content.Shared.Interaction.Events;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Popups;
using Robust.Shared.Random;
using Robust.Shared.Configuration;

View File

@@ -4,13 +4,14 @@ using Content.Server.Body.Systems;
using Content.Server.DoAfter;
using Content.Server.Medical.Components;
using Content.Server.Stack;
using Content.Server.MobState;
using Content.Shared.Audio;
using Content.Shared.Damage;
using Content.Shared.Database;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Stacks;
using Robust.Shared.Random;
@@ -27,6 +28,7 @@ public sealed class HealingSystem : EntitySystem
[Dependency] private readonly StackSystem _stacks = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;
public override void Initialize()
{
@@ -175,10 +177,15 @@ public sealed class HealingSystem : EntitySystem
public float GetScaledHealingPenalty(EntityUid uid, HealingComponent component)
{
var output = component.Delay;
if (!TryComp<MobStateComponent>(uid, out var mobState) || !TryComp<DamageableComponent>(uid, out var damageable))
if (!TryComp<MobThresholdsComponent>(uid, out var mobThreshold) || !TryComp<DamageableComponent>(uid, out var damageable))
return output;
_mobStateSystem.TryGetEarliestCriticalState(mobState, 0, out var _, out var amount);
if (!_mobThresholdSystem.TryGetThresholdForState(uid, MobState.Critical, out var amount,
mobThreshold))
{
return 1;
}
var percentDamage = (float) (damageable.TotalDamage / amount);
//basically make it scale from 1 to the multiplier.
var modifier = percentDamage * (component.SelfHealPenaltyMultiplier - 1) + 1;

View File

@@ -6,7 +6,7 @@ using Content.Server.Popups;
using Content.Shared.Damage;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Audio;
using Robust.Server.GameObjects;
using Robust.Shared.Player;

View File

@@ -5,7 +5,6 @@ using Content.Server.Power.Components;
using Content.Shared.Destructible;
using Content.Shared.ActionBlocker;
using Content.Shared.DragDrop;
using Content.Shared.MobState.Components;
using Content.Shared.Movement.Events;
using Content.Shared.Verbs;
using Robust.Shared.Containers;
@@ -13,7 +12,8 @@ using Content.Server.MachineLinking.System;
using Content.Server.MachineLinking.Events;
using Content.Server.Cloning.Components;
using Content.Server.Construction;
using Content.Server.MobState;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Robust.Server.Containers;
using static Content.Shared.MedicalScanner.SharedMedicalScannerComponent; /// Hmm...

View File

@@ -7,11 +7,11 @@ using Content.Shared.Clothing.Components;
using Content.Shared.Damage;
using Content.Shared.FixedPoint;
using Content.Shared.Inventory.Events;
using Content.Shared.MobState.Components;
using Content.Shared.Verbs;
using Robust.Shared.Player;
using System.Threading;
using Content.Server.MobState;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
namespace Content.Server.Medical
{

View File

@@ -2,13 +2,13 @@ using Content.Server.Access.Systems;
using Content.Server.DeviceNetwork;
using Content.Server.DeviceNetwork.Components;
using Content.Server.DeviceNetwork.Systems;
using Content.Server.MobState;
using Content.Server.Popups;
using Content.Shared.Damage;
using Content.Shared.Examine;
using Content.Shared.Inventory.Events;
using Content.Shared.Medical.SuitSensor;
using Content.Shared.MobState.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Verbs;
using Robust.Shared.Containers;
using Robust.Shared.Map;