Compare commits

...

9 Commits

Author SHA1 Message Date
Pieter-Jan Briers
17164ead34 Fix release compile. 2021-11-09 15:35:37 +01:00
Vera Aguilera Puerto
079e099a3b Makes many things use OwnerUid instead of Owner.Uid 2021-11-09 15:11:02 +01:00
Javier Guardia Fernández
1c8ed1c5b2 Update to .NET 6 and C# 10 (#2211)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
2021-11-09 14:59:19 +01:00
Vera Aguilera Puerto
d4cdb7ff3b Tumbler command uses EntityUid 2021-11-09 13:02:01 +01:00
Vera Aguilera Puerto
31d301b91f ActorSystem and PlayerSession partially use EntityUid
Non-breaking changes
2021-11-09 12:54:18 +01:00
Vera Aguilera Puerto
07c65474cb LocalPlayer EntityUid 2021-11-09 12:38:25 +01:00
Vera Aguilera Puerto
8c3c8fceea ViewSubscriberSystem uses EntityUid for everything 2021-11-09 11:37:31 +01:00
Vera Aguilera Puerto
ee894d8a8e Move the last responsabilities from Entity to EntityManager. 2021-11-08 16:09:12 +01:00
Vera Aguilera Puerto
ce169ed15e Move LastModifiedTick out of Entity and into MetaDataComponent. (#2209) 2021-11-08 15:56:49 +01:00
36 changed files with 253 additions and 215 deletions

View File

@@ -22,7 +22,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.100
dotnet-version: 6.0.100
- name: Install dependencies
run: dotnet restore
- name: Build

View File

@@ -42,7 +42,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.100
dotnet-version: 6.0.100
- name: Build
run: dotnet build

View File

@@ -23,7 +23,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.100
dotnet-version: 6.0.100
- name: Package client
run: Tools/package_client_build.py -p windows mac linux

View File

@@ -21,7 +21,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.100
dotnet-version: 6.0.100
- name: Disable submodule autoupdate
run: touch BuildChecker/DISABLE_SUBMODULE_AUTOUPDATE
@@ -38,4 +38,4 @@ jobs:
- name: Content.Tests
run: dotnet test --no-build Content.Tests/Content.Tests.csproj -v n
- name: Content.IntegrationTests
run: COMPlus_gcServer=1 dotnet test --no-build Content.IntegrationTests/Content.IntegrationTests.csproj -v n
run: COMPlus_gcServer=1 dotnet test --no-build Content.IntegrationTests/Content.IntegrationTests.csproj -v n

View File

@@ -1,8 +1,8 @@
<Project>
<!-- Engine-specific properties. Content should not use this file. -->
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>9</LangVersion>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>10</LangVersion>
<Nullable>enable</Nullable>
<WarningsAsErrors>nullable</WarningsAsErrors>
</PropertyGroup>

View File

@@ -26,7 +26,7 @@
<TargetOS Condition="'$(TargetOS)' == ''">$(ActualOS)</TargetOS>
<Python>python3</Python>
<Python Condition="'$(ActualOS)' == 'Windows'">py -3</Python>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<EnableClientScripting>True</EnableClientScripting>
<!-- Client scripting is disabled on full release builds for security and size reasons. -->
<EnableClientScripting Condition="'$(FullRelease)' == 'True'">False</EnableClientScripting>

View File

@@ -47,7 +47,7 @@ namespace Robust.Client.GameObjects
if (_visible == value) return;
_visible = value;
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new SpriteUpdateEvent());
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, new SpriteUpdateEvent());
}
}
@@ -302,7 +302,7 @@ namespace Robust.Client.GameObjects
{
if (_containerOccluded == value) return;
_containerOccluded = value;
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new SpriteUpdateEvent());
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, new SpriteUpdateEvent());
}
}
@@ -1653,7 +1653,7 @@ namespace Robust.Client.GameObjects
internal void UpdateBounds()
{
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new SpriteUpdateEvent());
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, new SpriteUpdateEvent());
}
/// <summary>

View File

@@ -24,11 +24,13 @@ namespace Robust.Client.Player
public event Action<EntityDetachedEventArgs>? EntityDetached;
/// <summary>
/// Game entity that the local player is controlling. If this is null, the player
/// is in free/spectator cam.
/// Game entity that the local player is controlling. If this is null, the player is not attached to any
/// entity at all.
/// </summary>
[ViewVariables] public IEntity? ControlledEntity { get; private set; }
[ViewVariables] public EntityUid? ControlledEntityUid => ControlledEntity?.Uid;
[ViewVariables] public NetUserId UserId { get; set; }

View File

@@ -17,7 +17,7 @@
<PackageReference Include="nfluidsynth" Version="0.3.1" />
<PackageReference Include="NVorbis" Version="0.10.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.3" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.4" />
<PackageReference Include="OpenToolkit.Graphics" Version="4.0.0-pre9.1" />
<PackageReference Include="OpenToolkit.OpenAL" Version="4.0.0-pre9.1" />
<PackageReference Include="SpaceWizards.SharpFont" Version="1.0.1" />

View File

@@ -299,11 +299,11 @@ namespace Robust.Server.Console.Commands
var broadphaseSystem = EntitySystem.Get<SharedBroadphaseSystem>();
var entityManager = IoCManager.Resolve<IEntityManager>();
var groundEnt = entityManager.SpawnEntity(null, new MapCoordinates(0f, 0f, mapId));
var ground = entityManager.AddComponent<PhysicsComponent>(groundEnt);
var groundUid = entityManager.SpawnEntity(null, new MapCoordinates(0f, 0f, mapId)).Uid;
var ground = entityManager.AddComponent<PhysicsComponent>(groundUid);
var bodyEnt = entityManager.SpawnEntity(null, new MapCoordinates(0f, 10f, mapId));
var body = entityManager.AddComponent<PhysicsComponent>(bodyEnt);
var bodyUid = entityManager.SpawnEntity(null, new MapCoordinates(0f, 10f, mapId)).Uid;
var body = entityManager.AddComponent<PhysicsComponent>(bodyUid);
body.BodyType = BodyType.Dynamic;
body.SleepingAllowed = false;
@@ -331,7 +331,7 @@ namespace Robust.Server.Console.Commands
fixture.CollisionLayer = 2;
}
var revolute = EntitySystem.Get<SharedJointSystem>().CreateRevoluteJoint(ground.Owner.Uid, body.Owner.Uid);
var revolute = EntitySystem.Get<SharedJointSystem>().CreateRevoluteJoint(groundUid, bodyUid);
revolute.LocalAnchorA = new Vector2(0f, 10f);
revolute.LocalAnchorB = new Vector2(0f, 0f);
revolute.ReferenceAngle = 0f;
@@ -350,7 +350,7 @@ namespace Robust.Server.Console.Commands
Timer.Spawn(i * 20, () =>
{
if (!mapManager.MapExists(mapId)) return;
var ent = entityManager.SpawnEntity(null, new MapCoordinates(0f, 10f, mapId));
var ent = entityManager.SpawnEntity(null, new MapCoordinates(0f, 10f, mapId)).Uid;
var box = entityManager.AddComponent<PhysicsComponent>(ent);
box.BodyType = BodyType.Dynamic;
box.FixedRotation = false;

View File

@@ -21,43 +21,41 @@ namespace Robust.Server.GameObjects
private void OnActorPlayerAttach(AttachPlayerEvent args)
{
args.Result = Attach(args.Entity, args.Player, args.Force, out var forceKicked);
args.Result = Attach(args.Uid, args.Player, args.Force, out var forceKicked);
args.ForceKicked = forceKicked;
}
/// <summary>
/// Attaches a player session to an entity, optionally kicking any sessions already attached to it.
/// </summary>
/// <param name="entity">The entity to attach the player to</param>
/// <param name="uid">The entity to attach the player to</param>
/// <param name="player">The player to attach to the entity</param>
/// <param name="force">Whether to kick any existing players from the entity</param>
/// <returns>Whether the attach succeeded, or not.</returns>
public bool Attach(IEntity entity, IPlayerSession player, bool force = false)
public bool Attach(EntityUid uid, IPlayerSession player, bool force = false)
{
return Attach(entity, player, false, out _);
return Attach(uid, player, false, out _);
}
/// <summary>
/// Attaches a player session to an entity, optionally kicking any sessions already attached to it.
/// </summary>
/// <param name="entity">The entity to attach the player to</param>
/// <param name="uid">The entity to attach the player to</param>
/// <param name="player">The player to attach to the entity</param>
/// <param name="force">Whether to kick any existing players from the entity</param>
/// <param name="forceKicked">The player that was forcefully kicked, or null.</param>
/// <returns>Whether the attach succeeded, or not.</returns>
public bool Attach(IEntity entity, IPlayerSession player, bool force, out IPlayerSession? forceKicked)
public bool Attach(EntityUid uid, IPlayerSession player, bool force, out IPlayerSession? forceKicked)
{
// Null by default.
forceKicked = null;
// Cannot attach to a deleted entity.
if (entity.Deleted)
// Cannot attach to a deleted/nonexisting entity.
if (!EntityManager.EntityExists(uid))
{
return false;
}
var uid = entity.Uid;
// Check if there was a player attached to the entity already...
if (EntityManager.TryGetComponent(uid, out ActorComponent actor))
{
@@ -76,12 +74,12 @@ namespace Robust.Server.GameObjects
}
// We add the actor component.
actor = EntityManager.AddComponent<ActorComponent>(entity);
actor = EntityManager.AddComponent<ActorComponent>(uid);
actor.PlayerSession = player;
player.SetAttachedEntity(entity);
player.SetAttachedEntity(actor.Owner);
// The player is fully attached now, raise an event!
RaiseLocalEvent(uid, new PlayerAttachedEvent(entity, player, forceKicked));
RaiseLocalEvent(uid, new PlayerAttachedEvent(actor.Owner, player, forceKicked));
return true;
}
@@ -98,13 +96,13 @@ namespace Robust.Server.GameObjects
/// </summary>
/// <param name="entity">The entity player sessions will be detached from.</param>
/// <returns>Whether any player session was detached.</returns>
public bool Detach(IEntity entity)
public bool Detach(EntityUid entity)
{
if (!entity.HasComponent<ActorComponent>())
if (!EntityManager.HasComponent<ActorComponent>(entity))
return false;
// Removing the component will call shutdown, and our subscription will handle the rest of the detach logic.
entity.RemoveComponent<ActorComponent>();
EntityManager.RemoveComponent<ActorComponent>(entity);
return true;
}
@@ -116,8 +114,8 @@ namespace Robust.Server.GameObjects
/// This returns true if the player wasn't attached to any entity.</returns>
public bool Detach(IPlayerSession player)
{
var entity = player.AttachedEntity;
return entity == null || Detach(entity);
var uid = player.AttachedEntityUid;
return uid == null || Detach(uid.Value);
}
private void OnActorShutdown(EntityUid uid, ActorComponent component, ComponentShutdown args)
@@ -146,7 +144,7 @@ namespace Robust.Server.GameObjects
/// Entity to attach the player to.
/// Input parameter.
/// </summary>
public IEntity Entity { get; }
public EntityUid Uid { get; }
/// <summary>
/// Whether to force-attach the player,
@@ -168,9 +166,9 @@ namespace Robust.Server.GameObjects
/// </summary>
public bool Result { get; set; } = false;
public AttachPlayerEvent(IEntity entity, IPlayerSession player, bool force = false)
public AttachPlayerEvent(EntityUid uid, IPlayerSession player, bool force = false)
{
Entity = entity;
Uid = uid;
Player = player;
Force = force;
}
@@ -195,6 +193,7 @@ namespace Robust.Server.GameObjects
public sealed class PlayerAttachedEvent : EntityEventArgs
{
public IEntity Entity { get; }
public EntityUid EntityUid { get; }
public IPlayerSession Player { get; }
/// <summary>
@@ -205,6 +204,7 @@ namespace Robust.Server.GameObjects
public PlayerAttachedEvent(IEntity entity, IPlayerSession player, IPlayerSession? kicked = null)
{
Entity = entity;
EntityUid = entity.Uid;
Player = player;
Kicked = kicked;
}
@@ -216,11 +216,13 @@ namespace Robust.Server.GameObjects
public sealed class PlayerDetachedEvent : EntityEventArgs
{
public IEntity Entity { get; }
public EntityUid EntityUid { get; }
public IPlayerSession Player { get; }
public PlayerDetachedEvent(IEntity entity, IPlayerSession player)
{
Entity = entity;
EntityUid = entity.Uid;
Player = player;
}
}

View File

@@ -20,11 +20,8 @@ namespace Robust.Server.GameObjects
/// </summary>
public void AddViewSubscriber(EntityUid uid, IPlayerSession session)
{
// This will throw if you pass in an invalid uid.
var entity = EntityManager.GetEntity(uid);
// If the entity doesn't have the component, it will be added.
var viewSubscriber = entity.EnsureComponent<ViewSubscriberComponent>();
var viewSubscriber = EntityManager.EnsureComponent<ViewSubscriberComponent>(uid);
if (viewSubscriber.SubscribedSessions.Contains(session))
return; // Already subscribed, do nothing else.
@@ -32,7 +29,7 @@ namespace Robust.Server.GameObjects
viewSubscriber.SubscribedSessions.Add(session);
session.AddViewSubscription(uid);
RaiseLocalEvent(uid, new ViewSubscriberAddedEvent(entity, session));
RaiseLocalEvent(uid, new ViewSubscriberAddedEvent(uid, session));
}
/// <summary>
@@ -47,7 +44,7 @@ namespace Robust.Server.GameObjects
return; // Session wasn't subscribed, do nothing.
session.RemoveViewSubscription(uid);
RaiseLocalEvent(uid, new ViewSubscriberRemovedEvent(EntityManager.GetEntity(uid), session));
RaiseLocalEvent(uid, new ViewSubscriberRemovedEvent(uid, session));
}
private void OnViewSubscriberShutdown(EntityUid uid, ViewSubscriberComponent component, ComponentShutdown _)
@@ -64,10 +61,10 @@ namespace Robust.Server.GameObjects
/// </summary>
public class ViewSubscriberAddedEvent : EntityEventArgs
{
public IEntity View { get; }
public EntityUid View { get; }
public IPlayerSession Subscriber { get; }
public ViewSubscriberAddedEvent(IEntity view, IPlayerSession subscriber)
public ViewSubscriberAddedEvent(EntityUid view, IPlayerSession subscriber)
{
View = view;
Subscriber = subscriber;
@@ -80,10 +77,10 @@ namespace Robust.Server.GameObjects
/// </summary>
public class ViewSubscriberRemovedEvent : EntityEventArgs
{
public IEntity View { get; }
public EntityUid View { get; }
public IPlayerSession Subscriber { get; }
public ViewSubscriberRemovedEvent(IEntity view, IPlayerSession subscriber)
public ViewSubscriberRemovedEvent(EntityUid view, IPlayerSession subscriber)
{
View = view;
Subscriber = subscriber;

View File

@@ -350,9 +350,9 @@ namespace Robust.Server.GameStates
chunk.FastGetAllAnchoredEnts(uid =>
{
var ent = _entMan.GetEntity(uid);
var ent = _entMan.GetComponent<MetaDataComponent>(uid);
if (ent.LastModifiedTick < lastSeenChunk)
if (ent.EntityLastModifiedTick < lastSeenChunk)
return;
var newState = ServerGameStateManager.GetEntityState(_entMan, session, uid, lastSeenChunk);
@@ -508,7 +508,7 @@ namespace Robust.Server.GameStates
//Still Visible
// Nothing new to send
if (EntityManager.GetEntity(entityUid).LastModifiedTick < fromTick)
if (EntityManager.GetComponent<MetaDataComponent>(entityUid).EntityLastModifiedTick < fromTick)
continue;
// only send new changes

View File

@@ -749,7 +749,7 @@ namespace Robust.Server.Maps
}
else
{
EntityUidMap.Add(mapIdComp.Owner.Uid, uid);
EntityUidMap.Add(mapIdComp.OwnerUid, uid);
takenIds.Add(uid);
}
}

View File

@@ -25,6 +25,14 @@ namespace Robust.Server.Player
/// <param name="entity">The entity to attach to.</param>
void AttachToEntity(IEntity? entity);
/// <summary>
/// Attaches this player to an entity.
/// NOTE: The content pack almost certainly has an alternative for this.
/// Do not call this directly for most content code.
/// </summary>
/// <param name="uid">The entity to attach to.</param>
void AttachToEntity(EntityUid uid);
/// <summary>
/// Detaches this player from an entity.
/// NOTE: The content pack almost certainly has an alternative for this.

View File

@@ -122,20 +122,28 @@ namespace Robust.Server.Player
if (entity == null)
return;
if (!EntitySystem.Get<ActorSystem>().Attach(entity, this))
AttachToEntity(entity.Uid);
}
/// <inheritdoc />
public void AttachToEntity(EntityUid uid)
{
DetachFromEntity();
if (!EntitySystem.Get<ActorSystem>().Attach(uid, this))
{
Logger.Warning($"Couldn't attach player \"{this}\" to entity \"{entity}\"! Did it have a player already attached to it?");
Logger.Warning($"Couldn't attach player \"{this}\" to entity \"{uid}\"! Did it have a player already attached to it?");
}
}
/// <inheritdoc />
public void DetachFromEntity()
{
if (AttachedEntity == null)
if (AttachedEntityUid == null)
return;
#if EXCEPTION_TOLERANCE
if (AttachedEntity.Deleted)
if (AttachedEntity!.Deleted)
{
Logger.Warning($"Player \"{this}\" was attached to an entity that was deleted. THIS SHOULD NEVER HAPPEN, BUT DOES.");
// We can't contact ActorSystem because trying to fire an entity event would crash.
@@ -146,7 +154,7 @@ namespace Robust.Server.Player
}
#endif
if (!EntitySystem.Get<ActorSystem>().Detach(AttachedEntity))
if (!EntitySystem.Get<ActorSystem>().Detach(AttachedEntityUid.Value))
{
Logger.Warning($"Couldn't detach player \"{this}\" from entity \"{AttachedEntity}\"! Is it missing an ActorComponent?");
}
@@ -195,6 +203,7 @@ namespace Robust.Server.Player
/// <inheritdoc />
void IPlayerSession.SetAttachedEntity(IEntity? entity)
{
// TODO: Use EntityUid for this.
AttachedEntity = entity;
UpdatePlayerState();
}

View File

@@ -159,7 +159,7 @@ namespace Robust.Server.ServerStatus
}
var buildInfo = File.ReadAllText(path);
var info = JsonConvert.DeserializeObject<BuildInfo>(buildInfo);
var info = JsonConvert.DeserializeObject<BuildInfo>(buildInfo)!;
// Don't replace cvars with contents of build.json if overriden by --cvar or such.
SetCVarIfUnmodified(CVars.BuildEngineVersion, info.EngineVersion);

View File

@@ -455,6 +455,7 @@ Types:
AsyncVoidMethodBuilder: { All: True }
CompilationRelaxationsAttribute: { All: True }
CompilerGeneratedAttribute: { All: True }
DefaultInterpolatedStringHandler: { All: True }
ExtensionAttribute: { All: True }
IAsyncStateMachine: { All: True }
InternalsVisibleToAttribute: { All: True }
@@ -612,6 +613,7 @@ Types:
- "System.Text.StringBuilder Append(System.Decimal)"
- "System.Text.StringBuilder Append(System.ReadOnlyMemory`2<char>)"
- "System.Text.StringBuilder Append(System.ReadOnlySpan`2<char>)"
- "System.Text.StringBuilder Append(ref System.Text.StringBuilder/AppendInterpolatedStringHandler)"
- "System.Text.StringBuilder Append(System.Text.StringBuilder)"
- "System.Text.StringBuilder Append(System.Text.StringBuilder, int, int)"
- "System.Text.StringBuilder Append(uint)"
@@ -668,6 +670,7 @@ Types:
- "void CopyTo(int, System.Span`1<char>, int)"
NestedTypes:
ChunkEnumerator: { All: True }
AppendInterpolatedStringHandler: { All: True }
StringRuneEnumerator: { All: True }
System.Threading.Tasks:
Task: { All: True }

View File

@@ -233,11 +233,11 @@ namespace Robust.Shared.GameObjects
{
// Deserialization will cause this to be true.
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
if(Owner is null)
if(Owner is null || LifeStage >= ComponentLifeStage.Removing)
return;
var entManager = Owner.EntityManager;
entManager.DirtyEntity(Owner.Uid);
entManager.DirtyEntity(OwnerUid);
LastModifiedTick = entManager.CurrentTick;
}

View File

@@ -176,7 +176,7 @@ namespace Robust.Shared.GameObjects
EntitySystem.Get<SharedBroadphaseSystem>().RegenerateContacts(this);
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new PhysicsBodyTypeChangedEvent(_bodyType, oldType), false);
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, new PhysicsBodyTypeChangedEvent(_bodyType, oldType), false);
}
}
@@ -219,11 +219,11 @@ namespace Robust.Shared.GameObjects
if (value)
{
_sleepTime = 0.0f;
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new PhysicsWakeMessage(this));
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, new PhysicsWakeMessage(this));
}
else
{
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new PhysicsSleepMessage(this));
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, new PhysicsSleepMessage(this));
ResetDynamics();
_sleepTime = 0.0f;
}
@@ -494,7 +494,7 @@ namespace Robust.Shared.GameObjects
return;
_canCollide = value;
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new CollisionChangeMessage(this, Owner.Uid, _canCollide));
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new CollisionChangeMessage(this, OwnerUid, _canCollide));
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new PhysicsUpdateMessage(this));
Dirty();
}
@@ -1089,8 +1089,8 @@ namespace Robust.Shared.GameObjects
else
{
// TODO: Probably a bad idea but ehh future sloth's problem; namely that we have to duplicate code between here and CanCollide.
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new CollisionChangeMessage(this, Owner.Uid, _canCollide));
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new PhysicsUpdateMessage(this));
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, new CollisionChangeMessage(this, Owner.Uid, _canCollide));
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, new PhysicsUpdateMessage(this));
}
}
else

View File

@@ -72,7 +72,7 @@ namespace Robust.Shared.GameObjects
{
var xform = (TransformComponent) transform;
var tileIndices = Grid.TileIndicesFor(transform.Coordinates);
var result = Grid.AddToSnapGridCell(tileIndices, transform.Owner.Uid);
var result = Grid.AddToSnapGridCell(tileIndices, transform.OwnerUid);
if (result)
{
@@ -102,7 +102,7 @@ namespace Robust.Shared.GameObjects
var xform = (TransformComponent)transform;
var tileIndices = Grid.TileIndicesFor(transform.Coordinates);
Grid.RemoveFromSnapGridCell(tileIndices, transform.Owner.Uid);
Grid.RemoveFromSnapGridCell(tileIndices, transform.OwnerUid);
xform.SetAnchored(false);
if (xform.Owner.TryGetComponent<PhysicsComponent>(out var physicsComponent))
{

View File

@@ -5,6 +5,7 @@ using Robust.Shared.Players;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Timing;
using Robust.Shared.ViewVariables;
namespace Robust.Shared.GameObjects
@@ -59,6 +60,10 @@ namespace Robust.Shared.GameObjects
/// <inheritdoc />
public override string Name => "MetaData";
// Every entity starts at tick 1, because they are conceptually created in the time between 0->1
[ViewVariables]
public GameTick EntityLastModifiedTick { get; internal set; } = new(1);
/// <summary>
/// The in-game name of this entity.
/// </summary>

View File

@@ -139,7 +139,7 @@ namespace Robust.Shared.GameObjects
{
RebuildMatrices();
var rotateEvent = new RotateEvent(Owner, oldRotation, _localRotation);
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ref rotateEvent);
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, ref rotateEvent);
}
else
{
@@ -180,7 +180,7 @@ namespace Robust.Shared.GameObjects
get => !_parent.IsValid() ? null : Owner.EntityManager.GetEntity(_parent).Transform;
internal set
{
if (_anchored && value?.Owner.Uid != _parent)
if (_anchored && value?.OwnerUid != _parent)
{
Anchored = false;
}
@@ -292,7 +292,7 @@ namespace Robust.Shared.GameObjects
get
{
var valid = _parent.IsValid();
return new EntityCoordinates(valid ? _parent : Owner.Uid, valid ? LocalPosition : Vector2.Zero);
return new EntityCoordinates(valid ? _parent : OwnerUid, valid ? LocalPosition : Vector2.Zero);
}
// NOTE: This setter must be callable from before initialize (inheriting from AttachParent's note)
set
@@ -327,7 +327,7 @@ namespace Robust.Shared.GameObjects
var oldParent = Parent;
var oldConcrete = (TransformComponent?) oldParent;
var uid = Owner.Uid;
var uid = OwnerUid;
oldConcrete?._children.Remove(uid);
var newConcrete = (TransformComponent) newParent;
newConcrete._children.Add(uid);
@@ -340,7 +340,7 @@ namespace Robust.Shared.GameObjects
GridID = GetGridIndex();
var entParentChangedMessage = new EntParentChangedMessage(Owner, oldParent?.Owner);
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ref entParentChangedMessage);
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, ref entParentChangedMessage);
}
// These conditions roughly emulate the effects of the code before I changed things,
@@ -358,7 +358,7 @@ namespace Robust.Shared.GameObjects
if(!oldPosition.Position.Equals(Coordinates.Position))
{
var moveEvent = new MoveEvent(Owner, oldPosition, Coordinates);
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ref moveEvent);
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, ref moveEvent);
}
}
}
@@ -404,7 +404,7 @@ namespace Robust.Shared.GameObjects
{
RebuildMatrices();
var moveEvent = new MoveEvent(Owner, oldGridPos, Coordinates);
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ref moveEvent);
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, ref moveEvent);
}
else
{
@@ -540,7 +540,7 @@ namespace Robust.Shared.GameObjects
{
// Note that _children is a SortedSet<EntityUid>,
// so duplicate additions (which will happen) don't matter.
((TransformComponent) Parent!)._children.Add(Owner.Uid);
((TransformComponent) Parent!)._children.Add(OwnerUid);
}
GridID = GetGridIndex();
@@ -596,14 +596,14 @@ namespace Robust.Shared.GameObjects
if (_oldCoords != null)
{
var moveEvent = new MoveEvent(Owner, _oldCoords.Value, Coordinates, worldAABB);
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ref moveEvent);
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, ref moveEvent);
_oldCoords = null;
}
if (_oldLocalRotation != null)
{
var rotateEvent = new RotateEvent(Owner, _oldLocalRotation.Value, _localRotation, worldAABB);
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ref rotateEvent);
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, ref rotateEvent);
_oldLocalRotation = null;
}
}
@@ -665,12 +665,12 @@ namespace Robust.Shared.GameObjects
Anchored = false;
var oldConcrete = (TransformComponent) oldParent;
var uid = Owner.Uid;
var uid = OwnerUid;
oldConcrete._children.Remove(uid);
_parent = EntityUid.Invalid;
var entParentChangedMessage = new EntParentChangedMessage(Owner, oldParent?.Owner);
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ref entParentChangedMessage);
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, ref entParentChangedMessage);
var oldMapId = MapID;
MapID = MapId.Nullspace;
@@ -689,14 +689,14 @@ namespace Robust.Shared.GameObjects
//NOTE: This function must be callable from before initialize
// don't attach to something we're already attached to
if (ParentUid == newParent.Owner.Uid)
if (ParentUid == newParent.OwnerUid)
return;
DebugTools.Assert(newParent != this,
$"Can't parent a {nameof(TransformComponent)} to itself.");
// offset position from world to parent, and set
Coordinates = new EntityCoordinates(newParent.Owner.Uid, newParent.InvWorldMatrix.Transform(WorldPosition));
Coordinates = new EntityCoordinates(newParent.OwnerUid, newParent.InvWorldMatrix.Transform(WorldPosition));
}
internal void ChangeMapId(MapId newMapId)
@@ -730,7 +730,7 @@ namespace Robust.Shared.GameObjects
private void MapIdChanged(MapId oldId)
{
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new EntMapIdChangedMessage(Owner, oldId));
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, new EntMapIdChangedMessage(Owner, oldId));
}
public void AttachParent(IEntity parent)
@@ -788,7 +788,7 @@ namespace Robust.Shared.GameObjects
var newParentId = newState.ParentID;
var rebuildMatrices = false;
if (Parent?.Owner.Uid != newParentId)
if (Parent?.OwnerUid != newParentId)
{
if (newParentId != _parent)
{
@@ -917,7 +917,7 @@ namespace Robust.Shared.GameObjects
}
ActivelyLerping = true;
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, new TransformStartLerpMessage(this));
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, new TransformStartLerpMessage(this));
}
/// <summary>
@@ -974,7 +974,7 @@ namespace Robust.Shared.GameObjects
Dirty();
var anchorStateChangedEvent = new AnchorStateChangedEvent(Owner, value);
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, ref anchorStateChangedEvent);
Owner.EntityManager.EventBus.RaiseLocalEvent(OwnerUid, ref anchorStateChangedEvent);
}
}

View File

@@ -28,6 +28,10 @@ namespace Robust.Shared.GameObjects
public EntityLifeStage LifeStage { get => MetaData.EntityLifeStage; internal set => MetaData.EntityLifeStage = value; }
[ViewVariables]
GameTick IEntity.LastModifiedTick { get => MetaData.EntityLastModifiedTick; set => MetaData.EntityLastModifiedTick = value; }
/// <inheritdoc />
[ViewVariables]
public EntityPrototype? Prototype
@@ -44,11 +48,6 @@ namespace Robust.Shared.GameObjects
set => MetaData.EntityDescription = value;
}
/// <inheritdoc />
[ViewVariables]
// Every entity starts at tick 1, because they are conceptually created in the time between 0->1
GameTick IEntity.LastModifiedTick { get; set; } = new(1);
/// <inheritdoc />
[ViewVariables(VVAccess.ReadWrite)]
public string Name
@@ -101,76 +100,6 @@ namespace Robust.Shared.GameObjects
return EntityManager.EntityExists(Uid);
}
/// <summary>
/// Calls Initialize() on all registered components.
/// </summary>
public void InitializeComponents()
{
// TODO: Move this to EntityManager.
DebugTools.Assert(LifeStage == EntityLifeStage.PreInit);
LifeStage = EntityLifeStage.Initializing;
// Initialize() can modify the collection of components.
var components = EntityManager.GetComponents(Uid)
.OrderBy(x => x switch
{
TransformComponent _ => 0,
IPhysBody _ => 1,
_ => int.MaxValue
});
foreach (var component in components)
{
var comp = (Component) component;
if (comp.Initialized)
continue;
comp.LifeInitialize();
}
#if DEBUG
// Second integrity check in case of.
foreach (var t in EntityManager.GetComponents(Uid))
{
if (!t.Initialized)
{
DebugTools.Assert($"Component {t.Name} was not initialized at the end of {nameof(InitializeComponents)}.");
}
}
#endif
DebugTools.Assert(LifeStage == EntityLifeStage.Initializing);
LifeStage = EntityLifeStage.Initialized;
EntityManager.EventBus.RaiseEvent(EventSource.Local, new EntityInitializedMessage(this));
}
/// <summary>
/// Calls Startup() on all registered components.
/// </summary>
public void StartAllComponents()
{
// TODO: Move this to EntityManager.
// Startup() can modify _components
// This code can only handle additions to the list. Is there a better way? Probably not.
var comps = EntityManager.GetComponents(Uid)
.OrderBy(x => x switch
{
TransformComponent _ => 0,
IPhysBody _ => 1,
_ => int.MaxValue
});
foreach (var component in comps)
{
var comp = (Component) component;
if (comp.LifeStage == ComponentLifeStage.Initialized)
{
comp.LifeStartup();
}
}
}
#endregion Initialization
#region Component Messaging

View File

@@ -101,7 +101,7 @@ namespace Robust.Shared.GameObjects
{
ref var unitRef = ref Unsafe.As<TEvent, Unit>(ref args);
_eventTables.DispatchComponent<TEvent>(component.Owner.Uid, component, ref unitRef, false);
_eventTables.DispatchComponent<TEvent>(component.OwnerUid, component, ref unitRef, false);
}
/// <inheritdoc />
@@ -109,7 +109,7 @@ namespace Robust.Shared.GameObjects
{
ref var unitRef = ref Unsafe.As<TEvent, Unit>(ref args);
_eventTables.DispatchComponent<TEvent>(component.Owner.Uid, component, ref unitRef, true);
_eventTables.DispatchComponent<TEvent>(component.OwnerUid, component, ref unitRef, true);
}
/// <inheritdoc />

View File

@@ -88,6 +88,69 @@ namespace Robust.Shared.GameObjects
#region Component Management
public void InitializeComponents(EntityUid uid)
{
var metadata = GetComponent<MetaDataComponent>(uid);
DebugTools.Assert(metadata.EntityLifeStage == EntityLifeStage.PreInit);
metadata.EntityLifeStage = EntityLifeStage.Initializing;
// Initialize() can modify the collection of components.
var components = GetComponents(uid)
.OrderBy(x => x switch
{
TransformComponent _ => 0,
IPhysBody _ => 1,
_ => int.MaxValue
});
foreach (var component in components)
{
var comp = (Component) component;
if (comp.Initialized)
continue;
comp.LifeInitialize();
}
#if DEBUG
// Second integrity check in case of.
foreach (var t in GetComponents(uid))
{
if (!t.Initialized)
{
DebugTools.Assert($"Component {t.Name} was not initialized at the end of {nameof(InitializeComponents)}.");
}
}
#endif
DebugTools.Assert(metadata.EntityLifeStage == EntityLifeStage.Initializing);
metadata.EntityLifeStage = EntityLifeStage.Initialized;
EventBus.RaiseEvent(EventSource.Local, new EntityInitializedMessage(GetEntity(uid)));
}
public void StartComponents(EntityUid uid)
{
// TODO: Move this to EntityManager.
// Startup() can modify _components
// This code can only handle additions to the list. Is there a better way? Probably not.
var comps = GetComponents(uid)
.OrderBy(x => x switch
{
TransformComponent _ => 0,
IPhysBody _ => 1,
_ => int.MaxValue
});
foreach (var component in comps)
{
var comp = (Component) component;
if (comp.LifeStage == ComponentLifeStage.Initialized)
{
comp.LifeStartup();
}
}
}
public T AddComponent<T>(IEntity entity) where T : Component, new()
{
if (entity == null) throw new ArgumentNullException(nameof(entity));
@@ -120,7 +183,7 @@ namespace Robust.Shared.GameObjects
if (component == null) throw new ArgumentNullException(nameof(component));
if (component.Owner.Uid != uid) throw new InvalidOperationException("Component is not owned by entity.");
if (component.OwnerUid != uid) throw new InvalidOperationException("Component is not owned by entity.");
AddComponentInternal(uid, component, overwrite);
}
@@ -216,7 +279,7 @@ namespace Robust.Shared.GameObjects
{
if (component == null) throw new ArgumentNullException(nameof(component));
if (component.Owner == null || component.Owner.Uid != uid)
if (component.Owner == null || component.OwnerUid != uid)
throw new InvalidOperationException("Component is not owned by entity.");
RemoveComponentImmediate((Component)component, uid, false);
@@ -353,12 +416,7 @@ namespace Robust.Shared.GameObjects
{
var reg = _componentFactory.GetRegistration(component.GetType());
var entityUid = component.Owner.Uid;
foreach (var refType in reg.References)
{
_entTraitDict[refType].Remove(entityUid);
}
var entityUid = component.OwnerUid;
// ReSharper disable once InvertIf
if (reg.NetID != null)
@@ -372,6 +430,11 @@ namespace Robust.Shared.GameObjects
DirtyEntity(entityUid);
}
foreach (var refType in reg.References)
{
_entTraitDict[refType].Remove(entityUid);
}
_entCompIndex.Remove(entityUid, component);
ComponentDeleted?.Invoke(this, new DeletedComponentEventArgs(component, entityUid));
}

View File

@@ -6,7 +6,6 @@ using Prometheus;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
namespace Robust.Shared.GameObjects
{
@@ -235,11 +234,16 @@ namespace Robust.Shared.GameObjects
public void DirtyEntity(EntityUid uid)
{
var currentTick = CurrentTick;
var entity = GetEntity(uid);
if (entity.LastModifiedTick == currentTick) return;
// We want to retrieve MetaDataComponent even if its Deleted flag is set.
if (!_entTraitDict[typeof(MetaDataComponent)].TryGetValue(uid, out var component))
throw new KeyNotFoundException($"Entity {uid} does not exist, cannot dirty it.");
entity.LastModifiedTick = currentTick;
var metadata = (MetaDataComponent)component;
if (metadata.EntityLastModifiedTick == currentTick) return;
metadata.EntityLastModifiedTick = currentTick;
var dirtyEvent = new EntityDirtyEvent {Uid = uid};
EventBus.RaiseLocalEvent(uid, ref dirtyEvent);
@@ -441,13 +445,13 @@ namespace Robust.Shared.GameObjects
protected void InitializeEntity(Entity entity)
{
entity.InitializeComponents();
InitializeComponents(entity.Uid);
EntityInitialized?.Invoke(this, entity.Uid);
}
protected void StartEntity(Entity entity)
{
entity.StartAllComponents();
StartComponents(entity.Uid);
EntityStarted?.Invoke(this, entity.Uid);
}

View File

@@ -24,6 +24,16 @@ namespace Robust.Shared.GameObjects
/// </summary>
event EventHandler<ComponentEventArgs>? ComponentDeleted;
/// <summary>
/// Calls Initialize() on all registered components of the entity.
/// </summary>
void InitializeComponents(EntityUid uid);
/// <summary>
/// Calls Startup() on all registered components of the entity.
/// </summary>
void StartComponents(EntityUid uid);
/// <summary>
/// Adds a Component type to an entity. If the entity is already Initialized, the component will
/// automatically be Initialized and Started.

View File

@@ -108,7 +108,7 @@ namespace Robust.Shared.Map
if (GridExists(gridIndex))
{
Logger.DebugS("map",
$"Entity {comp.Owner.Uid} removed grid component, removing bound grid {gridIndex}");
$"Entity {comp.OwnerUid} removed grid component, removing bound grid {gridIndex}");
DeleteGrid(gridIndex);
}
}
@@ -267,8 +267,8 @@ namespace Robust.Shared.Map
if (result != null)
{
_mapEntities.Add(actualID, result.Owner.Uid);
Logger.DebugS("map", $"Rebinding map {actualID} to entity {result.Owner.Uid}");
_mapEntities.Add(actualID, result.OwnerUid);
Logger.DebugS("map", $"Rebinding map {actualID} to entity {result.OwnerUid}");
}
else
{
@@ -277,8 +277,8 @@ namespace Robust.Shared.Map
var mapComp = newEnt.AddComponent<MapComponent>();
mapComp.WorldMap = actualID;
newEnt.InitializeComponents();
newEnt.StartAllComponents();
_entityManager.InitializeComponents(newEnt.Uid);
_entityManager.StartComponents(newEnt.Uid);
Logger.DebugS("map", $"Binding map {actualID} to entity {newEnt.Uid}");
}
}
@@ -303,8 +303,8 @@ namespace Robust.Shared.Map
var newEntity = (Entity) _entityManager.CreateEntityUninitialized(null);
SetMapEntity(mapId, newEntity);
newEntity.InitializeComponents();
newEntity.StartAllComponents();
_entityManager.InitializeComponents(newEntity.Uid);
_entityManager.StartComponents(newEntity.Uid);
return newEntity;
}
@@ -459,7 +459,7 @@ namespace Robust.Shared.Map
if (result != null)
{
grid.GridEntityId = result.Owner.Uid;
grid.GridEntityId = result.OwnerUid;
Logger.DebugS("map", $"Rebinding grid {actualID} to entity {grid.GridEntityId}");
}
else
@@ -479,8 +479,8 @@ namespace Robust.Shared.Map
//use in transform states anytime before the state parent is properly set.
gridEnt.Transform.AttachParent(GetMapEntity(currentMapID));
gridEnt.InitializeComponents();
gridEnt.StartAllComponents();
_entityManager.InitializeComponents(gridEnt.Uid);
_entityManager.StartComponents(gridEnt.Uid);
}
}
else

View File

@@ -6,10 +6,10 @@ using System.Security.Cryptography;
using System.Threading.Tasks;
using Lidgren.Network;
using Newtonsoft.Json;
using Robust.Shared.AuthLib;
using Robust.Shared.Log;
using Robust.Shared.Network.Messages.Handshake;
using Robust.Shared.Utility;
using UsernameHelpers = Robust.Shared.AuthLib.UsernameHelpers;
namespace Robust.Shared.Network
{
@@ -128,7 +128,7 @@ namespace Robust.Shared.Network
var resp = await joinedResp.Content.ReadAsStringAsync();
var joinedRespJson = JsonConvert.DeserializeObject<HasJoinedResponse>(resp);
if (!joinedRespJson.IsValid)
if (joinedRespJson is not {IsValid: true})
{
connection.Disconnect("Failed to validate login");
return;

View File

@@ -108,7 +108,7 @@ namespace Robust.Shared.Physics
AddBody(update.Component);
}
_handledThisTick.Add(update.Component.Owner.Uid);
_handledThisTick.Add(update.Component.OwnerUid);
}
// Body update may not necessarily handle this (unless the thing's deleted) so we'll still do this work regardless.
@@ -119,7 +119,7 @@ namespace Robust.Shared.Physics
!body.CanCollide) continue;
UpdateBroadphase(body);
_handledThisTick.Add(body.Owner.Uid);
_handledThisTick.Add(body.OwnerUid);
}
while (_queuedMoves.TryDequeue(out var move))
@@ -167,7 +167,7 @@ namespace Robust.Shared.Physics
private void UpdateBroadphaseCache(BroadphaseComponent broadphase)
{
var uid = broadphase.Owner.Uid;
var uid = broadphase.OwnerUid;
var transform = _physicsManager.UpdateTransform(uid);
_broadphases.Add(uid);
@@ -196,7 +196,7 @@ namespace Robust.Shared.Physics
foreach (var (proxy, worldAABB) in moveBuffer)
{
var fixture = proxy.Fixture;
var uid = fixture.Body.Owner.Uid;
var uid = fixture.Body.OwnerUid;
// || prediction && !fixture.Body.Predict
if (!_broadphases.Contains(uid)) continue;
@@ -259,11 +259,11 @@ namespace Robust.Shared.Physics
foreach (var (broadphase, broadphaseXForm) in _broadphaseTransforms)
{
// Broadphase can't intersect with entities on itself so skip.
if (proxyBody.Owner.Uid == broadphase.Owner.Uid ||
if (proxyBody.OwnerUid == broadphase.OwnerUid ||
broadphase.Owner.Transform.MapID != proxyBody.Owner.Transform.MapID) continue;
// If we're a map / our BB intersects then we'll do the work
if (_broadphaseBounding.TryGetValue(broadphase.Owner.Uid, out var broadphaseAABB) &&
if (_broadphaseBounding.TryGetValue(broadphase.OwnerUid, out var broadphaseAABB) &&
!broadphaseAABB.Intersects(worldAABB)) continue;
// Logger.DebugS("physics", $"Checking proxy for {proxy.Fixture.Body.Owner} on {broadphase.Owner}");
@@ -604,7 +604,7 @@ namespace Robust.Shared.Physics
}
// Ensure cache remains up to date if the broadphase is moving.
var uid = body.Owner.Uid;
var uid = body.OwnerUid;
if (EntityManager.TryGetComponent(uid, out BroadphaseComponent? broadphase))
{
@@ -622,7 +622,7 @@ namespace Robust.Shared.Physics
var proxyCount = fixture.ProxyCount;
var broadphaseMapId = broadphase.Owner.Transform.MapID;
var broadphaseInvMatrix = _broadphaseInvMatrices[broadphase.Owner.Uid];
var broadphaseInvMatrix = _broadphaseInvMatrices[broadphase.OwnerUid];
var broadphaseXform = _broadphaseTransforms[broadphase];
var relativePos1 = new Transform(
@@ -688,7 +688,7 @@ namespace Robust.Shared.Physics
}
// Ensure cache remains up to date if the broadphase is moving.
var uid = body.Owner.Uid;
var uid = body.OwnerUid;
if (EntityManager.TryGetComponent(uid, out BroadphaseComponent? broadphaseComp))
{
@@ -732,7 +732,7 @@ namespace Robust.Shared.Physics
if (useCache)
{
broadphaseInvMatrix = _broadphaseInvMatrices[broadphase.Owner.Uid];
broadphaseInvMatrix = _broadphaseInvMatrices[broadphase.OwnerUid];
broadphaseTransform = _broadphaseTransforms[broadphase];
}
else

View File

@@ -97,13 +97,10 @@ namespace Robust.Shared.Serialization
{
Primitives.ReadPrimitive(hasherStream, out uint lu);
var l = (int) lu;
var y = hasherStream.Read(buf, 0, l);
if (y != l)
{
throw new InvalidDataException($"Could not read the full length of string #{i}.");
}
var span = buf.AsSpan(0, l);
hasherStream.ReadExact(span);
var str = Encoding.UTF8.GetString(buf, 0, l);
var str = Encoding.UTF8.GetString(span);
list.Add(str);
}

View File

@@ -48,8 +48,7 @@ namespace Robust.Shared.Utility
/// </exception>
public static void ReadExact(this Stream stream, Span<byte> buffer)
{
var read = 0;
while (read < buffer.Length)
while (buffer.Length > 0)
{
var cRead = stream.Read(buffer);
if (cRead == 0)
@@ -57,7 +56,17 @@ namespace Robust.Shared.Utility
throw new EndOfStreamException();
}
read += cRead;
// read += cRead;
buffer = buffer[cRead..];
if (buffer.Length > 0)
{
}
else
{
}
}
}

View File

@@ -1,7 +1,7 @@
using NUnit.Framework;
using Robust.Client.UserInterface;
using Robust.Shared.IoC;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.IoC;
namespace Robust.UnitTesting.Client.UserInterface
{
@@ -116,7 +116,7 @@ namespace Robust.UnitTesting.Client.UserInterface
baseControl.ForceRunStyleUpdate();
Assert.That(baseControl.TryGetStyleProperty("foo", out object _), Is.False);
Assert.That(baseControl.TryGetStyleProperty("foo", out object? _), Is.False);
uiMgr.RootControl.Stylesheet = sheetA;
childA.Stylesheet = sheetB;

View File

@@ -322,7 +322,7 @@ namespace Robust.UnitTesting.Server.GameObjects.Components
public override bool CanInsert(IEntity toinsert)
{
return toinsert.TryGetComponent(out IContainerManager _);
return toinsert.TryGetComponent(out IContainerManager? _);
}
}
}

View File

@@ -88,7 +88,7 @@ namespace Robust.UnitTesting.Shared.Map
mapMan.CreateNewMapEntity(MapId.Nullspace);
var oldEntity = (Entity)entMan.CreateEntityUninitialized(null, MapCoordinates.Nullspace);
oldEntity.InitializeComponents();
entMan.InitializeComponents(oldEntity.Uid);
mapMan.Restart();