提交进入地图和创建房间相关逻辑和协议
This commit is contained in:
61
Hotfix/Map/System/MapManageComponentSystem.cs
Normal file
61
Hotfix/Map/System/MapManageComponentSystem.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using Fantasy.Entitas;
|
||||
using Fantasy.Entitas.Interface;
|
||||
|
||||
namespace NB.Map;
|
||||
|
||||
public class MapManageComponentDestroySystem : DestroySystem<MapManageComponent>
|
||||
{
|
||||
protected override void Destroy(MapManageComponent self)
|
||||
{
|
||||
foreach (var (_, map) in self.Maps)
|
||||
{
|
||||
map.Dispose();
|
||||
}
|
||||
|
||||
self.Maps.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public class MapManageComponentAwakeSystem : AwakeSystem<MapManageComponent>
|
||||
{
|
||||
protected override void Awake(MapManageComponent self)
|
||||
{
|
||||
//初始化所有地图
|
||||
for (int i = 1; i < 100; i++)
|
||||
{
|
||||
//初始化100个地图
|
||||
var map = MapFactory.Create(self.Scene, i);
|
||||
if (map != null)
|
||||
{
|
||||
self.Add(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class MapManageComponentSystem
|
||||
{
|
||||
#region 增删
|
||||
|
||||
public static void Add(this MapManageComponent self, Map map)
|
||||
{
|
||||
self.Maps[map.MapId] = map;
|
||||
}
|
||||
|
||||
public static bool Remove(this MapManageComponent self, int mapId)
|
||||
{
|
||||
if (self.Maps.TryGetValue(mapId, out var map))
|
||||
{
|
||||
map.Dispose();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Map? Get(this MapManageComponent self, int mapId)
|
||||
{
|
||||
return self.Maps.GetValueOrDefault(mapId);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using Fantasy.Entitas.Interface;
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Entitas.Interface;
|
||||
|
||||
namespace NB.Map;
|
||||
|
||||
@@ -16,4 +18,9 @@ public class MapRoomDestroySystem : DestroySystem<MapRoom>
|
||||
|
||||
public static class MapRoomSystem
|
||||
{
|
||||
public static async FTask<uint> Enter(this MapRoom self, long unitId)
|
||||
{
|
||||
await FTask.CompletedTask;
|
||||
return ErrorCode.Successful;
|
||||
}
|
||||
}
|
||||
16
Hotfix/Map/System/MapSystem.cs
Normal file
16
Hotfix/Map/System/MapSystem.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Fantasy.Entitas.Interface;
|
||||
|
||||
namespace NB.Map;
|
||||
|
||||
public class MapDestroySystem : DestroySystem<Map>
|
||||
{
|
||||
protected override void Destroy(Map self)
|
||||
{
|
||||
self.MapId = 0;
|
||||
self.Units.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public static class MapSystem
|
||||
{
|
||||
}
|
||||
38
Hotfix/Map/System/MapUnitSystem.cs
Normal file
38
Hotfix/Map/System/MapUnitSystem.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Fantasy;
|
||||
using Fantasy.Async;
|
||||
using Fantasy.Entitas.Interface;
|
||||
using Unity.Mathematics;
|
||||
|
||||
namespace NB.Map;
|
||||
|
||||
public class MapUnitSystemDestroySystem : DestroySystem<MapUnit>
|
||||
{
|
||||
protected override void Destroy(MapUnit self)
|
||||
{
|
||||
self.MapId = 0;
|
||||
self.Position = float3.zero;
|
||||
self.Rotation = float4.zero;
|
||||
self.GateRouteId = 0L;
|
||||
}
|
||||
}
|
||||
|
||||
public static class MapUnitSystem
|
||||
{
|
||||
public static async FTask<uint> EnterMap(this MapUnit self, int mapId)
|
||||
{
|
||||
var mapManageComponent = self.Scene.GetComponent<MapManageComponent>();
|
||||
|
||||
var map = mapManageComponent.Get(mapId);
|
||||
if (map == null)
|
||||
{
|
||||
return ErrorCode.MapIdError;
|
||||
}
|
||||
|
||||
// map.en
|
||||
|
||||
await FTask.CompletedTask;
|
||||
|
||||
|
||||
return ErrorCode.Successful;
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,10 @@ public static class RoomManageComponentSystem
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static MapRoom? Get(this RoomManageComponent self, int roomId)
|
||||
{
|
||||
return self.Rooms.GetValueOrDefault(roomId);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 房间Id
|
||||
@@ -79,15 +82,5 @@ public static class RoomManageComponentSystem
|
||||
|
||||
#endregion
|
||||
|
||||
#region 进入退出
|
||||
|
||||
public static void Enter(this RoomManageComponent self, MapUnit unit, long roomId)
|
||||
{
|
||||
}
|
||||
|
||||
public static void Exit(this RoomManageComponent self, MapUnit unit)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user