123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using System.Collections.Generic;
- namespace ET.Server
- {
- [FriendOf(typeof(Room))]
- public static class RoomSystem
- {
- [ObjectSystem]
- public class RoomAwakeSystem : AwakeSystem<Room, Player>
- {
- protected override void Awake(Room self, Player owner)
- {
- Log.Info($"创建房间实体...");
- self.RoomId = RandomGenerator.RandRoomId();
- self.Type = 1;
- self.OwnerId = owner.Id;
- self.Players = new List<Player>();
- self.CreateTime = TimeHelper.ServerNow();
- // 添加房间玩家集合
- self.Players.Add(owner);
- // 添加麻将主逻辑组件
- switch (self.Type)
- {
- case 1:
- // 黄冈晃晃
- self.AddComponent<HGHHMainCheckerComponent>();
- break;
- case 2:
- break;
- }
-
- // 添加本地房间数据
- 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.RoomId);
- }
- }
- }
- }
- }
|