Browse Source

增加房间销毁逻辑

johnclot69 1 year ago
parent
commit
e8befb6e4a

+ 0 - 8
DotNet/Hotfix/Scenes/Game/GameRoomComponentSystem.cs

@@ -25,12 +25,4 @@ public static class GameRoomComponentSystem
     {
         return self.idRooms.Values.ToArray();
     }
-    
-    /// <summary>
-    /// 加入房间
-    /// </summary>
-    public static void JoinRoom(this GameRoomComponent self)
-    {
-        
-    }
 }

+ 15 - 4
DotNet/Hotfix/Scenes/Game/Room/RoomSystem.cs

@@ -6,16 +6,27 @@ namespace ET.Server;
 public static class RoomSystem
 {
     [ObjectSystem]
-    public class RoomAwakeSystem : AwakeSystem<Room, long>
+    public class RoomAwakeSystem : AwakeSystem<Room>
     {
-        protected override void Awake(Room self, long id)
+        protected override void Awake(Room self)
         {
-            Log.Info($"创建房间...");
+            Log.Info($"创建房间实体...");
             self.Type = 2;
             self.Players = new List<Player>();
             self.CreateTime = TimeHelper.ServerNow();
-            // 添加房间玩家数据
+            // 添加本地房间数据
             self.DomainScene().GetComponent<GameRoomComponent>().Add(self);
         }
+        
+        [ObjectSystem]
+        public class RoomDestroySystem : DestroySystem<Room>
+        {
+            protected override void Destroy(Room self)
+            {
+                Log.Info($"销毁房间实体...");
+                // 移除本地房间数据
+                self.DomainScene().GetComponent<GameRoomComponent>()?.Remove(self.Id);
+            }
+        }
     }
 }

+ 1 - 1
DotNet/Model/Scenes/Game/Room/Room.cs

@@ -6,7 +6,7 @@ namespace ET.Server;
 /// 玩家房间
 /// </summary>
 [ChildOf(typeof(GameRoomComponent))]
-public class Room : Entity, IAwake<long>, IDestroy
+public class Room : Entity, IAwake, IDestroy
 {
     /** 房间玩法类型 1:麻将 2:斗地主 **/
     public int Type { get; set; }