mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
* ComponentNames are not sent over the network when components are created. * Removed ComponentStates array from EntityState, now the state is stored directly inside the CompChange struct. * Remove the unnecessary NetID property from ComponentState. * Remove Component.NetworkSynchronizeExistence. * Change GetNetComponents to return both the component and the component NetId. * Remove public usages of the Component.NetID property. * Adds the NetIDAttribute that can be applied to components. * Removed Component.NetID. * Revert changes to GetComponentState and how prediction works. * Adds component netID automatic generation. * Modifies ClientConsoleHost so that commands can be called before Initialize(). * Completely remove static NetIds. * Renamed NetIDAttribute to NetworkedComponentAttribute. * Fixing unit tests.
80 lines
2.1 KiB
C#
80 lines
2.1 KiB
C#
using System;
|
|
using Robust.Shared.GameStates;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Players;
|
|
using Robust.Shared.Serialization;
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
namespace Robust.Shared.GameObjects
|
|
{
|
|
/// <summary>
|
|
/// Represents a world map inside the ECS system.
|
|
/// </summary>
|
|
public interface IMapComponent : IComponent
|
|
{
|
|
MapId WorldMap { get; }
|
|
void ClearMapId();
|
|
}
|
|
|
|
/// <inheritdoc cref="IMapComponent"/>
|
|
[ComponentReference(typeof(IMapComponent))]
|
|
[NetworkedComponent()]
|
|
public class MapComponent : Component, IMapComponent
|
|
{
|
|
[ViewVariables(VVAccess.ReadOnly)]
|
|
[DataField("index")]
|
|
private MapId _mapIndex = MapId.Nullspace;
|
|
|
|
/// <inheritdoc />
|
|
public override string Name => "Map";
|
|
|
|
/// <inheritdoc />
|
|
public MapId WorldMap
|
|
{
|
|
get => _mapIndex;
|
|
internal set => _mapIndex = value;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public void ClearMapId()
|
|
{
|
|
_mapIndex = MapId.Nullspace;
|
|
}
|
|
|
|
/// <param name="player"></param>
|
|
/// <inheritdoc />
|
|
public override ComponentState GetComponentState(ICommonSession player)
|
|
{
|
|
return new MapComponentState(_mapIndex);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
|
{
|
|
base.HandleComponentState(curState, nextState);
|
|
|
|
if (!(curState is MapComponentState state))
|
|
return;
|
|
|
|
_mapIndex = state.MapId;
|
|
|
|
((TransformComponent) Owner.Transform).ChangeMapId(_mapIndex);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Serialized state of a <see cref="MapGridComponentState"/>.
|
|
/// </summary>
|
|
[Serializable, NetSerializable]
|
|
internal class MapComponentState : ComponentState
|
|
{
|
|
public MapId MapId { get; }
|
|
|
|
public MapComponentState(MapId mapId)
|
|
{
|
|
MapId = mapId;
|
|
}
|
|
}
|
|
}
|