结构大修改,改成朴实无华的结构,不过度架构。能跑就行

This commit is contained in:
2025-12-23 00:09:39 +08:00
parent 384f11f620
commit 3d14085920
2837 changed files with 149714 additions and 1100 deletions

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9720afaa3bc94081b63a7c0571e4c86a
timeCreated: 1757251153

View File

@@ -0,0 +1,20 @@
using Fantasy;
using Fantasy.Async;
using Fantasy.Network;
using Fantasy.Network.Interface;
using NBF.Fishing2;
using Log = NBC.Log;
namespace NBF.Fishing2
{
public class Map2C_ChangeMapHandler : Message<Map2C_ChangeMap>
{
protected override async FTask Run(Session session, Map2C_ChangeMap message)
{
Log.Info($"收到地图切换消息=={message.MapId}");
// await MapHelper.ChangeMap(message.MapId);
// await MapHelper.CreateRoomTest(message.MapId);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9aca13592484450582e818dd128a23c2
timeCreated: 1756301493

View File

@@ -0,0 +1,32 @@
using Fantasy;
using Fantasy.Async;
using Fantasy.Network;
using Fantasy.Network.Interface;
using NBC;
using Log = NBC.Log;
namespace NBF.Fishing2
{
public class Map2C_RoleEnterMapNotifyHandler : Message<Map2C_RoleEnterRoomNotify>
{
protected override async FTask Run(Session session, Map2C_RoleEnterRoomNotify message)
{
Log.Info($"收到进入房间推送 id={message.Info.Id} ");
var map = App.Main.GetComponent<Map>();
if (map == null || !map.IsRoomMap)
{
Log.Info("房间不是好友房间,不处理进入请求");
return;
}
var info = message.Info;
var unit = map.GetUnit(info.Id);
if (unit == null)
{
unit = map.CreateMapUnit(info);
}
await unit.CreateView();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b0934eeab5b8445b824f1337f774379e
timeCreated: 1757251141

View File

@@ -0,0 +1,27 @@
using Fantasy;
using Fantasy.Async;
using Fantasy.Network;
using Fantasy.Network.Interface;
using NBC;
using Log = NBC.Log;
namespace NBF.Fishing2
{
public class Map2C_RoleExitMapNotifyHandler : Message<Map2C_RoleExitRoomNotify>
{
protected override async FTask Run(Session session, Map2C_RoleExitRoomNotify message)
{
Log.Info($"收到离开房间推送 id={message.Id} ");
var map = App.Main.GetComponent<Map>();
if (map == null)
{
Log.Info("地图不存在,不处理退出请求");
return;
}
if (map.Units.Remove(message.Id, out var unit))
{
unit.Dispose();
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 18ae467167c44db1873fee88067d2f9a
timeCreated: 1757251193

View File

@@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using Fantasy;
using NBC;
using Fantasy.Entitas;
using Fantasy.Entitas.Interface;
namespace NBF.Fishing2
{
public class Map : Entity
{
public int MapId;
public string RoomCode;
/// <summary>
/// 自己的实体id
/// </summary>
public long SelfId;
/// <summary>
/// 好友房地图
/// </summary>
public bool IsRoomMap => !string.IsNullOrEmpty(RoomCode);
/// <summary>
/// 地图中的单位
/// </summary>
public Dictionary<long, MapUnit> Units = new Dictionary<long, MapUnit>();
/// <summary>
/// 自己的实体
/// </summary>
public MapUnit SelfMapUnit => GetUnit(SelfId);
#region System
public class MapDestroySystem : DestroySystem<Map>
{
protected override void Destroy(Map self)
{
self.MapId = 0;
self.SelfId = 0;
self.RoomCode = string.Empty;
self.Units.Clear();
}
}
#endregion
public MapUnit CreateMapUnit(MapUnitInfo unitInfo)
{
var mapUnit = Create<MapUnit>(Scene, unitInfo.Id, true, true);
mapUnit.SetUnitInfo(unitInfo);
Add(mapUnit);
return mapUnit;
}
/// <summary>
/// 获取一个单位
/// </summary>
/// <param name="self"></param>
/// <param name="id"></param>
/// <returns></returns>
public MapUnit GetUnit(long id)
{
return Units.GetValueOrDefault(id);
}
/// <summary>
/// 进入地图
/// </summary>
/// <param name="map"></param>
/// <param name="unit"></param>
/// <returns></returns>
public bool Add(MapUnit unit)
{
Units.Add(unit.Id, unit);
return true;
}
/// <summary>
/// 离开地图
/// </summary>
/// <param name="self"></param>
/// <param name="id"></param>
/// <returns></returns>
public bool Remove(long id)
{
return Units.Remove(id);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2acb8a2309ee4443a812939b0e02c18f
timeCreated: 1756049289

View File

@@ -0,0 +1,11 @@
using Fantasy.Entitas;
namespace NBF.Fishing2
{
/// <summary>
/// 地图管理组件
/// </summary>
public class MapManageComponent : Entity
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 226c840e80f840ae8a4ff54bc7c6645a
timeCreated: 1756304063