mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
* fix up buttons * wah * ough * huhwuhuahsdhsfdj * loud incorrect buzzer * wawa * Allow XmlnsDefinition * wawa * Release notes. * Expose keybind loading. * address reviews and other things --------- Co-authored-by: moonheart08 <moonheart08@users.noreply.github.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
56 lines
1.8 KiB
C#
56 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Robust.Client.GameObjects;
|
|
|
|
public sealed partial class ClientEntityManager
|
|
{
|
|
protected override NetEntity GenerateNetEntity() => new(NextNetworkId++ | NetEntity.ClientEntity);
|
|
|
|
/// <summary>
|
|
/// If the client fails to resolve a NetEntity then during component state handling or the likes we
|
|
/// flag that comp state as requiring re-running if that NetEntity comes in.
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
internal readonly Dictionary<NetEntity, List<(Type type, EntityUid Owner)>> PendingNetEntityStates = new();
|
|
|
|
public override bool IsClientSide(EntityUid uid, MetaDataComponent? metadata = null)
|
|
{
|
|
// Can't log false because some content code relies on invalid UIDs.
|
|
if (!MetaQuery.Resolve(uid, ref metadata, false))
|
|
return false;
|
|
|
|
return metadata.NetEntity.IsClientSide();
|
|
}
|
|
|
|
public override EntityUid EnsureEntity<T>(NetEntity nEntity, EntityUid callerEntity)
|
|
{
|
|
if (!nEntity.Valid)
|
|
{
|
|
return EntityUid.Invalid;
|
|
}
|
|
|
|
if (NetEntityLookup.TryGetValue(nEntity, out var entity))
|
|
{
|
|
return entity.Item1;
|
|
}
|
|
|
|
// Flag the callerEntity to have their state potentially re-run later.
|
|
var pending = PendingNetEntityStates.GetOrNew(nEntity);
|
|
pending.Add((typeof(T), callerEntity));
|
|
|
|
|
|
|
|
return entity.Item1;
|
|
}
|
|
|
|
public override EntityCoordinates EnsureCoordinates<T>(NetCoordinates netCoordinates, EntityUid callerEntity)
|
|
{
|
|
var entity = EnsureEntity<T>(netCoordinates.NetEntity, callerEntity);
|
|
return new EntityCoordinates(entity, netCoordinates.Position);
|
|
}
|
|
}
|