Revert "Virtualize all NetIDs to reduce network traffic" (#1119)

This reverts commit d776476542.
This commit is contained in:
Tyler Young
2020-06-08 18:34:37 -04:00
committed by GitHub
parent 7f406aa16c
commit 5c8545c396
14 changed files with 17 additions and 45 deletions

View File

@@ -205,7 +205,7 @@ namespace Robust.Shared.GameObjects
if (NetID == null)
throw new InvalidOperationException($"Cannot make state for component without Net ID: {GetType()}");
return new NetIdComponentState(NetID.Value);
return new ComponentState(NetID.Value);
}
/// <inheritdoc />

View File

@@ -3,30 +3,14 @@ using System;
namespace Robust.Shared.GameObjects
{
[Serializable, NetSerializable]
public abstract class ComponentState
public class ComponentState
{
public uint NetID { get; }
public abstract uint NetID { get; }
protected ComponentState()
public ComponentState(uint netID)
{
NetID = netID;
}
}
[Serializable, NetSerializable]
internal sealed class NetIdComponentState : ComponentState
{
public override uint NetID { get; }
public NetIdComponentState(uint netId)
{
NetID = netId;
}
}
}

View File

@@ -29,8 +29,7 @@ namespace Robust.Shared.GameObjects.Components.Appearance
{
public readonly Dictionary<object, object> Data;
public override uint NetID => NetIDs.APPEARANCE;
public AppearanceComponentState(Dictionary<object, object> data)
public AppearanceComponentState(Dictionary<object, object> data) : base(NetIDs.APPEARANCE)
{
Data = data;
}

View File

@@ -13,8 +13,7 @@ namespace Robust.Shared.GameObjects.Components
{
public Box2? LocalBounds { get; }
public override uint NetID => NetIDs.CLICKABLE;
public ClickableComponentState(Box2? localBounds)
public ClickableComponentState(Box2? localBounds) : base(NetIDs.CLICKABLE)
{
LocalBounds = localBounds;
}

View File

@@ -11,9 +11,9 @@ namespace Robust.Shared.GameObjects.Components
public readonly bool CanCollide;
public readonly BodyStatus Status;
public readonly List<IPhysShape> PhysShapes;
public override uint NetID => NetIDs.COLLIDABLE;
public CollidableComponentState(bool canCollide, BodyStatus status, List<IPhysShape> physShapes)
: base(NetIDs.COLLIDABLE)
{
CanCollide = canCollide;
Status = status;

View File

@@ -28,8 +28,7 @@ namespace Robust.Shared.GameObjects.Components.Containers
{
public Dictionary<string,(bool, List<EntityUid>)> Containers { get; }
public override uint NetID => NetIDs.CONTAINER_MANAGER;
public ContainerManagerComponentState(Dictionary<string, (bool, List<EntityUid>)> containers)
public ContainerManagerComponentState(Dictionary<string, (bool, List<EntityUid>)> containers) : base(NetIDs.CONTAINER_MANAGER)
{
Containers = containers;
}

View File

@@ -67,8 +67,7 @@ namespace Robust.Shared.GameObjects
public bool Enabled { get; }
public Box2 BoundingBox { get; }
public override uint NetID => NetIDs.OCCLUDER;
public OccluderComponentState(bool enabled, Box2 boundingBox)
public OccluderComponentState(bool enabled, Box2 boundingBox) : base(NetIDs.OCCLUDER)
{
Enabled = enabled;
BoundingBox = boundingBox;

View File

@@ -12,9 +12,9 @@ namespace Robust.Shared.GameObjects
public readonly float Radius;
public readonly Vector2 Offset;
public override uint NetID => NetIDs.POINT_LIGHT;
public PointLightComponentState(bool enabled, Color color, float radius, Vector2 offset)
: base(NetIDs.POINT_LIGHT)
{
Enabled = enabled;
Color = color;

View File

@@ -76,9 +76,9 @@ namespace Robust.Shared.GameObjects.Components.Map
internal class MapComponentState : ComponentState
{
public MapId MapId { get; }
public override uint NetID => NetIDs.MAP_MAP;
public MapComponentState(MapId mapId)
: base(NetIDs.MAP_MAP)
{
MapId = mapId;
}

View File

@@ -99,14 +99,12 @@ namespace Robust.Shared.GameObjects.Components.Map
/// </summary>
public GridId GridIndex { get; }
public override uint NetID => NetIDs.MAP_GRID;
/// <summary>
/// Constructs a new instance of <see cref="MapGridComponentState"/>.
/// </summary>
/// <param name="gridIndex">Index of the grid this component is linked to.</param>
public MapGridComponentState(GridId gridIndex)
: base(NetIDs.MAP_GRID)
{
GridIndex = gridIndex;
}

View File

@@ -26,9 +26,6 @@ namespace Robust.Shared.GameObjects
/// </summary>
public string? PrototypeId { get; }
public override uint NetID => NetIDs.META_DATA;
/// <summary>
/// Constructs a new instance of <see cref="MetaDataComponentState"/>.
/// </summary>
@@ -36,6 +33,7 @@ namespace Robust.Shared.GameObjects
/// <param name="description">The in-game description of this entity.</param>
/// <param name="prototypeId">The prototype this entity was created from, if any.</param>
public MetaDataComponentState(string? name, string? description, string? prototypeId)
: base(NetIDs.META_DATA)
{
Name = name;
Description = description;

View File

@@ -25,15 +25,13 @@ namespace Robust.Shared.GameObjects
/// </summary>
public readonly float AngularVelocity;
public override uint NetID => NetIDs.PHYSICS;
/// <summary>
/// Constructs a new state snapshot of a PhysicsComponent.
/// </summary>
/// <param name="mass">Current Mass of the entity.</param>
/// <param name="velocity">Current Velocity of the entity.</param>
public PhysicsComponentState(float mass, Vector2 linearVelocity, float angularVelocity)
: base(NetIDs.PHYSICS)
{
Mass = (int) Math.Round(mass *1000); // rounds kg to nearest gram
LinearVelocity = linearVelocity;

View File

@@ -30,7 +30,6 @@ namespace Robust.Shared.GameObjects.Components.Renderable
public readonly string BaseRsiPath;
public readonly List<PrototypeLayerData> Layers;
public readonly uint RenderOrder;
public override uint NetID => NetIDs.SPRITE;
public SpriteComponentState(
bool visible,
@@ -43,6 +42,7 @@ namespace Robust.Shared.GameObjects.Components.Renderable
string baseRsiPath,
List<PrototypeLayerData> layers,
uint renderOrder)
: base(NetIDs.SPRITE)
{
Visible = visible;
DrawDepth = drawDepth;

View File

@@ -772,9 +772,6 @@ namespace Robust.Shared.GameObjects.Components.Transform
/// </summary>
public readonly Angle Rotation;
public override uint NetID => NetIDs.TRANSFORM;
/// <summary>
/// Constructs a new state snapshot of a TransformComponent.
/// </summary>
@@ -782,6 +779,7 @@ namespace Robust.Shared.GameObjects.Components.Transform
/// <param name="rotation">Current direction offset of this entity.</param>
/// <param name="parentId">Current parent transform of this entity.</param>
public TransformComponentState(Vector2 localPosition, Angle rotation, EntityUid? parentId)
: base(NetIDs.TRANSFORM)
{
LocalPosition = localPosition;
Rotation = rotation;