Files
RobustToolbox/Robust.Shared/Map/MapId.cs
Leon Friedrich fbc706f37b Refactor map loading & saving (#5572)
* Refactor map loading & saving

* test fixes

* ISerializationManager tweaks

* Fix component composition

* Try fix entity deserialization component composition

* comments

* CL

* error preinit

* a

* cleanup

* error if version is too new

* Add AlwaysPushSerializationTest

* Add auto-inclusion test

* Better categorization

* Combine test components

* Save -> TrySave

Also better handling for saving multiple entities individually

* Create new partial class for map loading

* Add OrphanSerializationTest

* Include MapIds in BeforeSerializationEvent

* Addd LifetimeSerializationTest

* Add TestMixedLifetimeSerialization

* Add CategorizationTest

* explicitly serialize list of nullspace entities

* Add backwards compatibility test

* Version comments

also fixes wrong v4 format

* add MapMergeTest

* Add NetEntity support

* Optimize EntityDeserializer

Avoid unnecessary component deserialization

* fix assert & other bugs

* fucking containers strike again

* Fix deletion of pre-init entities

* fix release note merge conflict

* Update Robust.Shared/Map/MapManager.GridCollection.cs

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* VV

---------

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2025-02-16 21:25:07 +11:00

60 lines
1.3 KiB
C#

using System;
using Robust.Shared.Serialization;
namespace Robust.Shared.Map
{
[Serializable, NetSerializable]
public readonly struct MapId : IEquatable<MapId>
{
public static readonly MapId Nullspace = new(0);
internal readonly int Value;
public MapId(int value)
{
Value = value;
}
/// <inheritdoc />
public bool Equals(MapId other)
{
return Value == other.Value;
}
/// <inheritdoc />
public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
return obj is MapId id && Equals(id);
}
/// <inheritdoc />
public override int GetHashCode()
{
return Value;
}
public static bool operator ==(MapId a, MapId b)
{
return a.Value == b.Value;
}
public static bool operator !=(MapId a, MapId b)
{
return !(a == b);
}
public static explicit operator int(MapId self)
{
return self.Value;
}
public override string ToString()
{
return IsClientSide ? $"c{-Value}" : Value.ToString();
}
public bool IsClientSide => Value < 0;
}
}