Remove or fix broken Dirty() calls. (#18933)

This commit is contained in:
Leon Friedrich
2023-08-10 16:17:43 +12:00
committed by GitHub
parent 705a5e94db
commit 9da4679220
5 changed files with 29 additions and 15 deletions

View File

@@ -58,7 +58,7 @@ public sealed class BodySystem : SharedBodySystem
if (TryComp(slot.Child, out BodyPartComponent? child)) if (TryComp(slot.Child, out BodyPartComponent? child))
{ {
child.ParentSlot = slot; child.ParentSlot = slot;
Dirty(slot.Child.Value); Dirty(slot.Child.Value, child);
continue; continue;
} }
@@ -75,7 +75,7 @@ public sealed class BodySystem : SharedBodySystem
if (TryComp(slot.Child, out OrganComponent? child)) if (TryComp(slot.Child, out OrganComponent? child))
{ {
child.ParentSlot = slot; child.ParentSlot = slot;
Dirty(slot.Child.Value); Dirty(slot.Child.Value, child);
continue; continue;
} }
@@ -101,7 +101,7 @@ public sealed class BodySystem : SharedBodySystem
} }
child.ParentSlot = slot; child.ParentSlot = slot;
Dirty(slot.Child.Value); Dirty(slot.Child.Value, child);
} }
private void OnRelayMoveInput(EntityUid uid, BodyComponent component, ref MoveInputEvent args) private void OnRelayMoveInput(EntityUid uid, BodyComponent component, ref MoveInputEvent args)

View File

@@ -34,8 +34,6 @@ namespace Content.Server.Polymorph.Systems
var newmap = _mapManager.CreateMap(); var newmap = _mapManager.CreateMap();
_mapManager.SetMapPaused(newmap, true); _mapManager.SetMapPaused(newmap, true);
PausedMap = _mapManager.GetMapEntityId(newmap); PausedMap = _mapManager.GetMapEntityId(newmap);
Dirty(PausedMap.Value);
} }
} }
} }

View File

@@ -70,8 +70,8 @@ public partial class SharedBodySystem
organ.ParentSlot = slot; organ.ParentSlot = slot;
organ.Body = CompOrNull<BodyPartComponent>(slot.Parent)?.Body; organ.Body = CompOrNull<BodyPartComponent>(slot.Parent)?.Body;
Dirty(slot.Parent); DirtyAllComponents(slot.Parent);
Dirty(organId.Value); Dirty(organId.Value, organ);
if (organ.Body == null) if (organ.Body == null)
{ {
@@ -85,6 +85,20 @@ public partial class SharedBodySystem
return true; return true;
} }
public void DirtyAllComponents(EntityUid uid)
{
// TODO just use containers. Please
if (TryComp(uid, out BodyPartComponent? part))
Dirty(uid, part);
if (TryComp(uid, out OrganComponent? organ))
Dirty(uid, organ);
if (TryComp(uid, out BodyComponent? body))
Dirty(uid, body);
}
public bool AddOrganToFirstValidSlot( public bool AddOrganToFirstValidSlot(
EntityUid? childId, EntityUid? childId,
EntityUid? parentId, EntityUid? parentId,

View File

@@ -55,7 +55,7 @@ public partial class SharedBodySystem
if (part.ParentSlot is { } slot) if (part.ParentSlot is { } slot)
{ {
slot.Child = null; slot.Child = null;
Dirty(slot.Parent); DirtyAllComponents(slot.Parent);
} }
foreach (var childSlot in part.Children.Values.ToArray()) foreach (var childSlot in part.Children.Values.ToArray())
@@ -207,8 +207,8 @@ public partial class SharedBodySystem
part.Body = null; part.Body = null;
} }
Dirty(slot.Parent); DirtyAllComponents(slot.Parent);
Dirty(partId.Value); DirtyAllComponents(partId.Value);
if (part.Body is { } newBody) if (part.Body is { } newBody)
{ {
@@ -226,7 +226,7 @@ public partial class SharedBodySystem
RaiseLocalEvent(organ.Id, new AddedToBodyEvent(newBody), true); RaiseLocalEvent(organ.Id, new AddedToBodyEvent(newBody), true);
} }
Dirty(newBody); DirtyAllComponents(newBody);
} }
return true; return true;
@@ -281,8 +281,8 @@ public partial class SharedBodySystem
} }
} }
Dirty(slot.Parent); DirtyAllComponents(slot.Parent);
Dirty(partId.Value); DirtyAllComponents(partId.Value);
return true; return true;
} }

View File

@@ -322,10 +322,12 @@ public sealed class MobThresholdSystem : EntitySystem
} }
if (mobState.CurrentState != MobState.Dead || thresholds.AllowRevives) if (mobState.CurrentState != MobState.Dead || thresholds.AllowRevives)
{
thresholds.CurrentThresholdState = newState; thresholds.CurrentThresholdState = newState;
_mobStateSystem.UpdateMobState(target, mobState); Dirty(target, thresholds);
}
Dirty(target); _mobStateSystem.UpdateMobState(target, mobState);
} }
private void UpdateAlerts(EntityUid target, MobState currentMobState, MobThresholdsComponent? threshold = null, private void UpdateAlerts(EntityUid target, MobState currentMobState, MobThresholdsComponent? threshold = null,