Files
hjha-server/ServerCore/Core/ObjectRef.cs
xiaoou e9616125ce feat: initial commit - HJHA game server full source
6 major server modules (PdkFriendServer/GlobalSever/ServerCore/GameModule/GameNetModule) +
game logic (GameFix/GameDAL/ServerData) +
network layer (NetWorkMessage) +
data layer (ObjectModel) +
utilities (MrWu/Core/Config/CloudAPI/dll) +
adapters (zyxAdapter/base)

.NET 8.0 C# solution, 16 projects, 958 source files
2026-07-07 12:02:15 +08:00

50 lines
1.1 KiB
C#

namespace Server.Core
{
public struct ObjectRef<T> where T : class,IReference
{
private readonly long ReferenceId;
private T self;
private ObjectRef(T t)
{
if (t == null)
{
this.ReferenceId = 0;
this.self = null;
return;
}
this.ReferenceId = t.ReferenceId;
this.self = t;
}
private T UnWarp
{
get
{
if (this.self == null)
{
return null;
}
if (this.self.ReferenceId != this.ReferenceId)
{
this.self = null;
}
return this.self;
}
}
public static implicit operator ObjectRef<T>(T t)
{
return new ObjectRef<T>(t);
}
public static implicit operator T(ObjectRef<T> t)
{
return t.UnWarp;
}
}
}