adds a source uid to most damage & mobstate events (#11559)
Co-authored-by: Flipp Syder <76629141+vulppine@users.noreply.github.com>
This commit is contained in:
@@ -178,7 +178,7 @@ namespace Content.Shared.MobState.EntitySystems
|
||||
|
||||
public void UpdateState(EntityUid _, MobStateComponent component, DamageChangedEvent args)
|
||||
{
|
||||
UpdateState(component, args.Damageable.TotalDamage);
|
||||
UpdateState(component, args.Damageable.TotalDamage, args.Origin);
|
||||
}
|
||||
|
||||
private void OnMoveAttempt(EntityUid uid, MobStateComponent component, UpdateCanMoveEvent args)
|
||||
@@ -275,20 +275,20 @@ namespace Content.Shared.MobState.EntitySystems
|
||||
/// <summary>
|
||||
/// Updates the mob state..
|
||||
/// </summary>
|
||||
public void UpdateState(MobStateComponent component, FixedPoint2 damage)
|
||||
public void UpdateState(MobStateComponent component, FixedPoint2 damage, EntityUid? origin = null)
|
||||
{
|
||||
if (!TryGetState(component, damage, out var newState, out var threshold))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SetMobState(component, component.CurrentState, (newState.Value, threshold));
|
||||
SetMobState(component, component.CurrentState, (newState.Value, threshold), origin);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the mob state and marks the component as dirty.
|
||||
/// </summary>
|
||||
private void SetMobState(MobStateComponent component, DamageState? old, (DamageState state, FixedPoint2 threshold)? current)
|
||||
private void SetMobState(MobStateComponent component, DamageState? old, (DamageState state, FixedPoint2 threshold)? current, EntityUid? origin = null)
|
||||
{
|
||||
if (!current.HasValue)
|
||||
{
|
||||
@@ -313,7 +313,7 @@ namespace Content.Shared.MobState.EntitySystems
|
||||
EnterState(component, state);
|
||||
UpdateState(component, state, threshold);
|
||||
|
||||
var message = new MobStateChangedEvent(component, old, state);
|
||||
var message = new MobStateChangedEvent(component, old, state, origin);
|
||||
RaiseLocalEvent(component.Owner, message, true);
|
||||
Dirty(component);
|
||||
}
|
||||
|
||||
@@ -7,11 +7,13 @@ namespace Content.Shared.MobState
|
||||
public MobStateChangedEvent(
|
||||
MobStateComponent component,
|
||||
DamageState? oldMobState,
|
||||
DamageState currentMobState)
|
||||
DamageState currentMobState,
|
||||
EntityUid? origin)
|
||||
{
|
||||
Component = component;
|
||||
OldMobState = oldMobState;
|
||||
CurrentMobState = currentMobState;
|
||||
Origin = origin;
|
||||
}
|
||||
|
||||
public EntityUid Entity => Component.Owner;
|
||||
@@ -21,6 +23,8 @@ namespace Content.Shared.MobState
|
||||
public DamageState? OldMobState { get; }
|
||||
|
||||
public DamageState CurrentMobState { get; }
|
||||
|
||||
public EntityUid? Origin { get; }
|
||||
}
|
||||
|
||||
public static class A
|
||||
|
||||
Reference in New Issue
Block a user