aaaaaaaaaaaaaaa

This commit is contained in:
Paul
2021-03-02 21:37:14 +01:00
parent 0b38f93434
commit 7cc489bea0
3 changed files with 9 additions and 9 deletions

View File

@@ -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>

View File

@@ -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 {}
}

View File

@@ -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)
{