mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
aaaaaaaaaaaaaaa
This commit is contained in:
@@ -3,10 +3,12 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Robust.Shared.GameObjects
|
||||
{
|
||||
[CopyByRef]
|
||||
public interface IEntity
|
||||
{
|
||||
GameTick LastModifiedTick { get; }
|
||||
@@ -40,7 +42,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// True if the entity has been deleted.
|
||||
/// </summary>
|
||||
bool Deleted { get; }
|
||||
|
||||
|
||||
bool Paused { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -2,6 +2,6 @@ using System;
|
||||
|
||||
namespace Robust.Shared.Serialization.Manager.Attributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum, Inherited = false)]
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Interface, Inherited = false)]
|
||||
public class CopyByRefAttribute : Attribute {}
|
||||
}
|
||||
|
||||
@@ -539,30 +539,28 @@ namespace Robust.Shared.Serialization.Manager
|
||||
return copy == null ? default : (T?) copy;
|
||||
}
|
||||
|
||||
private object? CreateCopyInternal(object? source, ISerializationContext? context = null, bool skipHook = false)
|
||||
private object? CreateCopyInternal(Type type, object? source, ISerializationContext? context = null, bool skipHook = false)
|
||||
{
|
||||
if (source == null) return source;
|
||||
|
||||
var type = source.GetType();
|
||||
|
||||
if (type.IsPrimitive || type.IsEnum || source is string)
|
||||
if (type.IsPrimitive || type.IsEnum || source is string || _copyByRefRegistrations.Contains(type))
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
//todo paul checks here
|
||||
var target = Activator.CreateInstance(source.GetType())!;
|
||||
return Copy(source, target, context, skipHook);
|
||||
}
|
||||
|
||||
public object? CreateCopy(object? source, ISerializationContext? context = null, bool skipHook = false)
|
||||
{
|
||||
return CreateCopyInternal(source, context, skipHook);
|
||||
if (source == null) return null;
|
||||
return CreateCopyInternal(source.GetType(), source, context, skipHook);
|
||||
}
|
||||
|
||||
public T? CreateCopy<T>(T? source, ISerializationContext? context = null, bool skipHook = false)
|
||||
{
|
||||
var copy = CreateCopyInternal(source, context, skipHook);
|
||||
var copy = CreateCopyInternal(typeof(T), source, context, skipHook);
|
||||
|
||||
if (copy == null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user