mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Add MetadataComponent argument to Dirty() (#3302)
This commit is contained in:
@@ -48,19 +48,19 @@ namespace Robust.Client.GameObjects
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Dirty(EntityUid uid)
|
||||
public override void DirtyEntity(EntityUid uid, MetaDataComponent? meta = null)
|
||||
{
|
||||
// Client only dirties during prediction
|
||||
if (_gameTiming.InPrediction)
|
||||
base.Dirty(uid);
|
||||
base.DirtyEntity(uid, meta);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Dirty(Component component)
|
||||
public override void Dirty(Component component, MetaDataComponent? meta = null)
|
||||
{
|
||||
// Client only dirties during prediction
|
||||
if (_gameTiming.InPrediction)
|
||||
base.Dirty(component);
|
||||
base.Dirty(component, meta);
|
||||
}
|
||||
|
||||
public override EntityStringRepresentation ToPrettyString(EntityUid uid)
|
||||
|
||||
@@ -252,13 +252,19 @@ namespace Robust.Shared.GameObjects
|
||||
/// <remarks>
|
||||
/// Calling Dirty on a component will call this directly.
|
||||
/// </remarks>
|
||||
public virtual void Dirty(EntityUid uid)
|
||||
public virtual void DirtyEntity(EntityUid uid, MetaDataComponent? metadata = null)
|
||||
{
|
||||
// We want to retrieve MetaDataComponent even if its Deleted flag is set.
|
||||
if (!_entTraitArray[CompIdx.ArrayIndex<MetaDataComponent>()].TryGetValue(uid, out var component))
|
||||
throw new KeyNotFoundException($"Entity {uid} does not exist, cannot dirty it.");
|
||||
|
||||
var metadata = (MetaDataComponent)component;
|
||||
if (metadata == null)
|
||||
{
|
||||
if (!_entTraitArray[CompIdx.ArrayIndex<MetaDataComponent>()].TryGetValue(uid, out var component))
|
||||
throw new KeyNotFoundException($"Entity {uid} does not exist, cannot dirty it.");
|
||||
metadata = (MetaDataComponent)component;
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugTools.Assert(metadata.Owner == uid);
|
||||
}
|
||||
|
||||
if (metadata.EntityLastModifiedTick == _gameTiming.CurTick) return;
|
||||
|
||||
@@ -270,7 +276,7 @@ namespace Robust.Shared.GameObjects
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Dirty(Component component)
|
||||
public virtual void Dirty(Component component, MetaDataComponent? meta = null)
|
||||
{
|
||||
var owner = component.Owner;
|
||||
|
||||
@@ -282,7 +288,7 @@ namespace Robust.Shared.GameObjects
|
||||
if (!component.NetSyncEnabled)
|
||||
return;
|
||||
|
||||
Dirty(owner);
|
||||
DirtyEntity(owner, meta);
|
||||
component.LastModifiedTick = CurrentTick;
|
||||
}
|
||||
|
||||
@@ -441,7 +447,7 @@ namespace Robust.Shared.GameObjects
|
||||
var entity = AllocEntity(out metadata, uid);
|
||||
|
||||
metadata._entityPrototype = prototype;
|
||||
Dirty(metadata);
|
||||
Dirty(metadata, metadata);
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -173,18 +173,18 @@ public partial class EntitySystem
|
||||
/// Marks an entity as dirty.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected void Dirty(EntityUid uid)
|
||||
protected void Dirty(EntityUid uid, MetaDataComponent? meta = null)
|
||||
{
|
||||
EntityManager.Dirty(uid);
|
||||
EntityManager.DirtyEntity(uid, meta);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Marks a component as dirty.
|
||||
/// Marks a component as dirty. This also implicitly dirties the entity this component belongs to.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected void Dirty(Component component)
|
||||
protected void Dirty(Component component, MetaDataComponent? meta = null)
|
||||
{
|
||||
EntityManager.Dirty(component);
|
||||
EntityManager.Dirty(component, meta);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -86,9 +86,9 @@ namespace Robust.Shared.GameObjects
|
||||
/// <returns></returns>
|
||||
IEnumerable<EntityUid> GetEntities();
|
||||
|
||||
public void Dirty(EntityUid uid);
|
||||
public void DirtyEntity(EntityUid uid, MetaDataComponent? metadata = null);
|
||||
|
||||
public void Dirty(Component component);
|
||||
public void Dirty(Component component, MetaDataComponent? metadata = null);
|
||||
|
||||
public void QueueDeleteEntity(EntityUid uid);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user