diff --git a/Api/Factory/UserFactory.cs b/Api/Factory/UserFactory.cs
index 54cabe4..ca5732c 100644
--- a/Api/Factory/UserFactory.cs
+++ b/Api/Factory/UserFactory.cs
@@ -15,7 +15,22 @@ namespace Milimoe.FunGame.Core.Api.Factory
public static User Create(long Id = 0, string Username = "", DateTime? RegTime = null, DateTime? LastTime = null, string Email = "", string NickName = "", bool IsAdmin = false, bool IsOperator = false, bool IsEnable = true, decimal Credits = 0, decimal Materials = 0, decimal GameTime = 0, string AutoKey = "")
{
- return new User(Id, Username, RegTime, LastTime, Email, NickName, IsAdmin, IsOperator, IsEnable, Credits, Materials, GameTime, AutoKey);
+ return new(Id, Username, RegTime, LastTime, Email, NickName, IsAdmin, IsOperator, IsEnable, Credits, Materials, GameTime, AutoKey);
+ }
+
+ public static User Create(UserType type)
+ {
+ return new(type);
+ }
+
+ public static User CreateGuest()
+ {
+ return General.GuestUserInstance;
+ }
+
+ public static User CreateLocalUser()
+ {
+ return General.LocalUserInstance;
}
}
}
diff --git a/Docs/FunGame.Core.xml b/Docs/FunGame.Core.xml
index 0533bb1..57f602c 100644
--- a/Docs/FunGame.Core.xml
+++ b/Docs/FunGame.Core.xml
@@ -2140,6 +2140,16 @@
默认的未知用户
+
+
+ 游客用户
+
+
+
+
+ 本地用户
+
+
大厅(空房间)实例
diff --git a/Entity/User/User.cs b/Entity/User/User.cs
index 3e78533..27fe96f 100644
--- a/Entity/User/User.cs
+++ b/Entity/User/User.cs
@@ -46,6 +46,26 @@ namespace Milimoe.FunGame.Core.Entity
Inventory = new(this);
}
+ internal User(UserType usertype)
+ {
+ switch (usertype)
+ {
+ case UserType.General:
+ case UserType.Empty:
+ break;
+ case UserType.Guest:
+ Id = UserSet.GuestUserId;
+ Username = UserSet.GuestUserName;
+ break;
+ case UserType.LocalUser:
+ Id = UserSet.LocalUserId;
+ Username = UserSet.LocalUserName;
+ break;
+ }
+ Statistics = new(this);
+ Inventory = new(this);
+ }
+
public override bool Equals(IBaseEntity? other)
{
return other is User u && u.Id == Id;
diff --git a/Library/Constant/ConstantSet.cs b/Library/Constant/ConstantSet.cs
index cc46acc..c5a85ac 100644
--- a/Library/Constant/ConstantSet.cs
+++ b/Library/Constant/ConstantSet.cs
@@ -274,4 +274,15 @@ namespace Milimoe.FunGame.Core.Library.Constant
};
}
}
+
+ public class UserSet
+ {
+ public const long UnknownUserId = 0;
+ public const long GuestUserId = -5;
+ public const long LocalUserId = -6;
+
+ public const string UnknownUserName = "未知用户";
+ public const string GuestUserName = "游客用户";
+ public const string LocalUserName = "本地用户";
+ }
}
diff --git a/Library/Constant/General.cs b/Library/Constant/General.cs
index e124ad4..ba456d0 100644
--- a/Library/Constant/General.cs
+++ b/Library/Constant/General.cs
@@ -19,6 +19,16 @@ namespace Milimoe.FunGame.Core.Library.Constant
/// 默认的未知用户
///
public static User UnknownUserInstance => new();
+
+ ///
+ /// 游客用户
+ ///
+ public static User GuestUserInstance => new(UserType.Guest);
+
+ ///
+ /// 本地用户
+ ///
+ public static User LocalUserInstance => new(UserType.LocalUser);
///
/// 大厅(空房间)实例
diff --git a/Library/Constant/TypeEnum.cs b/Library/Constant/TypeEnum.cs
index a997e83..9269513 100644
--- a/Library/Constant/TypeEnum.cs
+++ b/Library/Constant/TypeEnum.cs
@@ -205,6 +205,14 @@ namespace Milimoe.FunGame.Core.Library.Constant
CharacterStatistics
}
+ public enum UserType
+ {
+ General,
+ Empty,
+ Guest,
+ LocalUser
+ }
+
public enum ShowMessageType
{
None,