Remove all usages of obsolete Dirty method, remove some obsoleted methods (#4500)

This commit is contained in:
DrSmugleaf
2023-10-21 14:19:07 -07:00
committed by GitHub
parent 7feede0d95
commit f754ddb96d
16 changed files with 33 additions and 81 deletions

View File

@@ -91,7 +91,7 @@ namespace Robust.Client.GameObjects
}
/// <inheritdoc />
public override void Dirty(Entity<IComponent> ent, MetaDataComponent? meta = null)
public override void Dirty<T>(Entity<T> ent, MetaDataComponent? meta = null)
{
// Client only dirties during prediction
if (_gameTiming.InPrediction)

View File

@@ -1,7 +1,5 @@
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
namespace Robust.Server.GameObjects
{
@@ -15,13 +13,5 @@ namespace Robust.Server.GameObjects
/// </summary>
[DataField("layer")]
public int Layer = 1;
[ViewVariables(VVAccess.ReadWrite)]
[Obsolete("Do not access directly, only exists for VV")]
public int LayerVV
{
get => Layer;
set => EntitySystem.Get<VisibilitySystem>().SetLayer(Owner, this, value);
}
}
}

View File

@@ -1,13 +1,14 @@
using System;
using Robust.Server.GameStates;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.ViewVariables;
namespace Robust.Server.GameObjects
{
public sealed class VisibilitySystem : EntitySystem
{
[Dependency] private readonly PvsSystem _pvs = default!;
[Dependency] private readonly IViewVariablesManager _vvManager = default!;
private EntityQuery<TransformComponent> _xformQuery;
private EntityQuery<MetaDataComponent> _metaQuery;
@@ -21,6 +22,15 @@ namespace Robust.Server.GameObjects
_visiblityQuery = GetEntityQuery<VisibilityComponent>();
SubscribeLocalEvent<EntParentChangedMessage>(OnParentChange);
EntityManager.EntityInitialized += OnEntityInit;
_vvManager.GetTypeHandler<VisibilityComponent>()
.AddPath(nameof(VisibilityComponent.Layer), (_, comp) => comp.Layer, (uid, value, comp) =>
{
if (!Resolve(uid, ref comp))
return;
SetLayer(uid, comp, value);
});
}
public override void Shutdown()
@@ -40,12 +50,6 @@ namespace Robust.Server.GameObjects
RefreshVisibility(uid, visibilityComponent: component);
}
[Obsolete("Use overload that takes an EntityUid instead")]
public void AddLayer(VisibilityComponent component, int layer, bool refresh = true)
{
AddLayer(component.Owner, component, layer, refresh);
}
public void RemoveLayer(EntityUid uid, VisibilityComponent component, int layer, bool refresh = true)
{
if ((layer & component.Layer) != layer)
@@ -57,12 +61,6 @@ namespace Robust.Server.GameObjects
RefreshVisibility(uid, visibilityComponent: component);
}
[Obsolete("Use overload that takes an EntityUid instead")]
public void RemoveLayer(VisibilityComponent component, int layer, bool refresh = true)
{
RemoveLayer(component.Owner, component, layer, refresh);
}
public void SetLayer(EntityUid uid, VisibilityComponent component, int layer, bool refresh = true)
{
if (component.Layer == layer)
@@ -74,12 +72,6 @@ namespace Robust.Server.GameObjects
RefreshVisibility(uid, visibilityComponent: component);
}
[Obsolete("Use overload that takes an EntityUid instead")]
public void SetLayer(VisibilityComponent component, int layer, bool refresh = true)
{
SetLayer(component.Owner, component, layer, refresh);
}
private void OnParentChange(ref EntParentChangedMessage ev)
{
RefreshVisibility(ev.Entity);
@@ -127,12 +119,6 @@ namespace Robust.Server.GameObjects
}
}
[Obsolete("Use overload that takes an EntityUid instead")]
public void RefreshVisibility(VisibilityComponent visibilityComponent)
{
RefreshVisibility(visibilityComponent.Owner, visibilityComponent);
}
private int GetParentVisibilityMask(EntityUid uid, VisibilityComponent? visibilityComponent = null)
{
int visMask = 1; // apparently some content expects everything to have the first bit/flag set to true.

View File

@@ -98,7 +98,7 @@ namespace Robust.Server.ViewVariables
// Auto-dirty component. Only works when modifying a field that is directly on a component,
// Does not work for nested objects.
if (Object is Component comp)
EntityManager.Dirty(comp);
EntityManager.Dirty(comp.Owner, comp);
}
public bool TryGetRelativeObject(object[] propertyIndex, out object? value)

View File

@@ -206,7 +206,7 @@ namespace Robust.Shared.Scripting
=> ent.DirtyEntity(uid);
public void Dirty(Component comp)
=> ent.Dirty(comp);
=> ent.Dirty(comp.Owner, comp);
public string Name(EntityUid uid)
=> ent.GetComponent<MetaDataComponent>(uid).EntityName;

View File

@@ -209,7 +209,7 @@ namespace Robust.Shared.Containers
DebugTools.Assert(transform.LocalRotation == Angle.Zero);
DebugTools.Assert(!physicsQuery.TryGetComponent(toinsert, out var phys) || (!phys.Awake && !phys.CanCollide));
entMan.Dirty(Manager);
entMan.Dirty(Owner, Manager);
return true;
}
@@ -355,7 +355,7 @@ namespace Robust.Shared.Containers
DebugTools.Assert(destination == null || xform.Coordinates.Equals(destination.Value));
entMan.Dirty(Manager);
entMan.Dirty(Owner, Manager);
return true;
}

View File

@@ -45,7 +45,7 @@ namespace Robust.Shared.Containers
var container = _dynFactory.CreateInstanceUnchecked<T>(typeof(T), inject: false);
container.Init(id, uid, this);
Containers[id] = container;
_entMan.Dirty(this);
_entMan.Dirty(uid, this);
return container;
}

View File

@@ -501,12 +501,6 @@ namespace Robust.Shared.Containers
}
}
[Obsolete("Use AttachParentToContainerOrGrid(EntityUid<TransformComponent>) instead")]
public void AttachParentToContainerOrGrid(TransformComponent transform)
{
AttachParentToContainerOrGrid(new Entity<TransformComponent>(transform.Owner, transform));
}
public void AttachParentToContainerOrGrid(Entity<TransformComponent> transform)
{
// TODO make this check upwards for any container, and parent to that.

View File

@@ -64,7 +64,7 @@ namespace Robust.Shared.GameObjects
public void Dirty(IEntityManager? entManager = null)
{
IoCManager.Resolve(ref entManager);
entManager.Dirty(this);
entManager.Dirty(Owner, this);
}
// these two methods clear the LastModifiedTick/CreationTick to mark it as "not different from prototype load".

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using Robust.Shared.GameStates;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
@@ -111,14 +110,6 @@ namespace Robust.Shared.GameObjects
return _entityPrototype != null ? _entityPrototype.Name : string.Empty;
return _entityName;
}
[Obsolete("Use MetaDataSystem.SetEntityName")]
set
{
if (value == EntityName)
return;
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<MetaDataSystem>().SetEntityName(Owner, value, this);
}
}
/// <summary>
@@ -133,14 +124,6 @@ namespace Robust.Shared.GameObjects
return _entityPrototype != null ? _entityPrototype.Description : string.Empty;
return _entityDescription;
}
[Obsolete("Use MetaDataSystem.SetEntityDescription")]
set
{
if (value == EntityDescription)
return;
IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<MetaDataSystem>().SetEntityDescription(Owner, value, this);
}
}
/// <summary>

View File

@@ -1,18 +1,16 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using Robust.Shared.Animations;
using Robust.Shared.GameStates;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using Robust.Shared.Map.Components;
namespace Robust.Shared.GameObjects
{
@@ -130,7 +128,7 @@ namespace Robust.Shared.GameObjects
LocalRotation = Angle.Zero;
_noLocalRotation = value;
_entMan.Dirty(this);
_entMan.Dirty(Owner, this);
}
}
@@ -152,7 +150,7 @@ namespace Robust.Shared.GameObjects
var oldRotation = _localRotation;
_localRotation = value;
_entMan.Dirty(this);
_entMan.Dirty(Owner, this);
MatricesDirty = true;
if (!Initialized)
@@ -335,7 +333,7 @@ namespace Robust.Shared.GameObjects
var oldGridPos = Coordinates;
_localPosition = value;
_entMan.Dirty(this);
_entMan.Dirty(Owner, this);
MatricesDirty = true;
if (!Initialized)

View File

@@ -398,7 +398,8 @@ namespace Robust.Shared.GameObjects
Dirty(new Entity<IComponent>(uid, component), meta);
}
public virtual void Dirty(Entity<IComponent> ent, MetaDataComponent? meta = null)
/// <inheritdoc />
public virtual void Dirty<T>(Entity<T> ent, MetaDataComponent? meta = null) where T : IComponent
{
if (ent.Comp.LifeStage >= ComponentLifeStage.Removing || !ent.Comp.NetSyncEnabled)
return;

View File

@@ -208,7 +208,7 @@ public partial class EntitySystem
[Obsolete("Use Dirty(EntityUid, Component, MetaDataComponent?")]
protected void Dirty(IComponent component, MetaDataComponent? meta = null)
{
EntityManager.Dirty(component, meta);
EntityManager.Dirty(component.Owner, component, meta);
}
/// <summary>

View File

@@ -83,11 +83,12 @@ namespace Robust.Shared.GameObjects
public void DirtyEntity(EntityUid uid, MetaDataComponent? metadata = null);
[Obsolete("use override with an EntityUid")]
public void Dirty(IComponent component, MetaDataComponent? metadata = null);
public void Dirty(EntityUid uid, IComponent component, MetaDataComponent? meta = null);
public void Dirty(Entity<IComponent> ent, MetaDataComponent? meta = null);
public void Dirty<T>(Entity<T> ent, MetaDataComponent? meta = null) where T : IComponent;
public void QueueDeleteEntity(EntityUid? uid);

View File

@@ -2,7 +2,6 @@ using System;
using System.Globalization;
using System.Linq;
using Robust.Shared.GameObjects;
using Robust.Shared.Log;
using Robust.Shared.Map.Components;
namespace Robust.Shared.Map
@@ -25,7 +24,7 @@ namespace Robust.Shared.Map
return;
mapComp.MapPaused = paused;
EntityManager.Dirty(mapComp);
EntityManager.Dirty(mapUid, mapComp);
var xformQuery = EntityManager.GetEntityQuery<TransformComponent>();
var metaQuery = EntityManager.GetEntityQuery<MetaDataComponent>();
@@ -65,7 +64,7 @@ namespace Robust.Shared.Map
mapComp.MapPreInit = false;
mapComp.MapPaused = false;
EntityManager.Dirty(mapComp);
EntityManager.Dirty(mapEnt, mapComp);
RecursiveDoMapInit(mapEnt, in xformQuery, in metaQuery, in metaSystem);
}

View File

@@ -149,7 +149,7 @@ internal sealed class ViewVariablesFieldOrPropertyPath : ViewVariablesPath
}
DebugTools.Assert(_object is not Component || ReferenceEquals(ParentComponent.Component, _object));
_entMan.Dirty(ParentComponent.Component);
_entMan.Dirty(ParentComponent.Owner, ParentComponent.Component);
}
public override object? Invoke(object?[]? parameters) => null;