This commit is contained in:
Putoo
2026-07-09 22:46:28 +08:00
parent 010ca90575
commit cfe6612a7a
33 changed files with 1355 additions and 39 deletions

View File

@@ -119,6 +119,40 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
return data;
}
public async Task<List<GameNpcModel>> GetMapNpcModel(string userId, string mapId, int areaId)
{
var taskService = App.GetService<IGameTaskService>();
List<GameNpcModel> result = new List<GameNpcModel>();
var data = await GetMapNpc(mapId);
foreach (var item in data)
{
if (GameTool.AreaVerify(areaId, item.areaId) == false)
{
continue;
}
GameNpcModel temp = new GameNpcModel()
{
npcId = item.npcId,
name = item.npcName,
tips = item.tips,
state = 0
};
if (item.code == nameof(MapEnum.NpcCode.Task))
{
var task = await taskService.GetTaskDataByNpc(userId,item.npcId);
if (task.Count > 0)
{
temp.state = task.Any(it => it.state == 0) ? 1 : 2;
}
}
result.Add(temp);
}
return result;
}
public async Task<game_city_npc> GetNpcInfo(int npcId)
{
string key = string.Format(BaseCache.BaseCacheKeys, "CityData", "NpcInfo");
@@ -183,6 +217,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
isOnline = isOnline
};
}
public async Task UpdateUserOnMap(string userId)
{
unit_user_online onLine = await GetUserOnMap(userId);
@@ -194,6 +229,7 @@ public class GameMapService(ISqlSugarClient DbClient, IRedisCache redis) : IGame
await db.Updateable<unit_user_online>(onLine).ExecuteCommandAsync();
}
}
public async Task UpdateUserOnMap(string userId, string ip, string mapId)
{
unit_user_online onLine = new unit_user_online();