mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-15 14:52:35 +02:00
* Adds barbones culling. * Visibility culling and recursive parent ent additions. DebugEntityNetView improvements. Visibility moved from session to eyecomponent. * Multiple viewport support. * Perf improvements. * Removed old netbubble system from ServerEntityManager. Supports old NaN system for entities leaving view. Supports old SendFullMap optimization for anchored, non-updating Entities. * Fixes size of netView box. * Remove empty EntityManager.Update method. Switching ViewCulling back to PLINQ.
68 lines
2.0 KiB
C#
68 lines
2.0 KiB
C#
using Robust.Shared.Serialization;
|
|
using System;
|
|
|
|
namespace Robust.Shared.GameObjects
|
|
{
|
|
[Serializable, NetSerializable]
|
|
public sealed class EntityState
|
|
{
|
|
public EntityUid Uid { get; }
|
|
public ComponentChanged[]? ComponentChanges { get; }
|
|
public ComponentState[]? ComponentStates { get; }
|
|
|
|
public bool Empty => ComponentChanges is null && ComponentStates is null;
|
|
|
|
public EntityState(EntityUid uid, ComponentChanged[]? changedComponents, ComponentState[]? componentStates)
|
|
{
|
|
Uid = uid;
|
|
|
|
// empty lists are 5 bytes each
|
|
ComponentChanges = changedComponents == null || changedComponents.Length == 0 ? null : changedComponents;
|
|
ComponentStates = componentStates == null || componentStates.Length == 0 ? null : componentStates;
|
|
}
|
|
}
|
|
|
|
[Serializable, NetSerializable]
|
|
public readonly struct ComponentChanged
|
|
{
|
|
// 15ish bytes to create a component (strings are big), 5 bytes to remove one
|
|
|
|
/// <summary>
|
|
/// Was the component added or removed from the entity.
|
|
/// </summary>
|
|
public readonly bool Deleted;
|
|
|
|
/// <summary>
|
|
/// The Network ID of the component to remove.
|
|
/// </summary>
|
|
public readonly uint NetID;
|
|
|
|
/// <summary>
|
|
/// The prototype name of the component to add.
|
|
/// </summary>
|
|
public readonly string? ComponentName;
|
|
|
|
public ComponentChanged(bool deleted, uint netId, string? componentName)
|
|
{
|
|
Deleted = deleted;
|
|
NetID = netId;
|
|
ComponentName = componentName;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"{(Deleted ? "D" : "C")} {NetID} {ComponentName}";
|
|
}
|
|
|
|
public static ComponentChanged Added(uint netId, string componentName)
|
|
{
|
|
return new(false, netId, componentName);
|
|
}
|
|
|
|
public static ComponentChanged Removed(uint netId)
|
|
{
|
|
return new(true, netId, null);
|
|
}
|
|
}
|
|
}
|