mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
* 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>
86 lines
1.9 KiB
C#
86 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Map.Components;
|
|
|
|
namespace Robust.Shared.Map;
|
|
|
|
/// <summary>
|
|
/// Arguments for when a map is created or deleted locally ore remotely.
|
|
/// </summary>
|
|
public sealed class MapEventArgs : EventArgs
|
|
{
|
|
/// <summary>
|
|
/// Creates a new instance of this class.
|
|
/// </summary>
|
|
public MapEventArgs(MapId map)
|
|
{
|
|
Map = map;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Map that is being modified.
|
|
/// </summary>
|
|
public MapId Map { get; }
|
|
}
|
|
|
|
internal partial class MapManager
|
|
{
|
|
/// <inheritdoc />
|
|
public virtual void DeleteMap(MapId mapId)
|
|
{
|
|
_mapSystem.DeleteMap(mapId);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public MapId CreateMap(MapId? mapId = null)
|
|
{
|
|
if (mapId != null)
|
|
{
|
|
_mapSystem.CreateMap(mapId.Value);
|
|
return mapId.Value;
|
|
}
|
|
|
|
_mapSystem.CreateMap(out var map);
|
|
return map;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public bool MapExists([NotNullWhen(true)] MapId? mapId)
|
|
{
|
|
return _mapSystem.MapExists(mapId);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public EntityUid GetMapEntityId(MapId mapId)
|
|
{
|
|
return _mapSystem.GetMapOrInvalid(mapId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Replaces GetMapEntity()'s throw-on-failure semantics.
|
|
/// </summary>
|
|
public EntityUid GetMapEntityIdOrThrow(MapId mapId)
|
|
{
|
|
return _mapSystem.GetMap(mapId);
|
|
}
|
|
|
|
public bool TryGetMap([NotNullWhen(true)] MapId? mapId, [NotNullWhen(true)] out EntityUid? uid)
|
|
{
|
|
return _mapSystem.TryGetMap(mapId, out uid);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public IEnumerable<MapId> GetAllMapIds()
|
|
{
|
|
return _mapSystem.GetAllMapIds();
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public bool IsMap(EntityUid uid)
|
|
{
|
|
return EntityManager.HasComponent<MapComponent>(uid);
|
|
}
|
|
}
|