You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.3 KiB
31 lines
1.3 KiB
using System; |
|
|
|
namespace ET |
|
{ |
|
public class Other2UnitCache_AddOrUpdateUnitHandler : AMActorRpcHandler<Scene, Other2UnitCache_AddOrUpdateUnit, UnitCache2Other_AddOrUpdateUnit> |
|
{ |
|
protected override async ETTask Run(Scene scene, Other2UnitCache_AddOrUpdateUnit request, UnitCache2Other_AddOrUpdateUnit response, Action reply) |
|
{ |
|
UpdateUnitCacheAsync(scene, request, response).Coroutine(); |
|
reply(); |
|
|
|
await ETTask.CompletedTask; |
|
} |
|
|
|
private async ETTask UpdateUnitCacheAsync(Scene scene, Other2UnitCache_AddOrUpdateUnit request, UnitCache2Other_AddOrUpdateUnit response) |
|
{ |
|
UnitCacheComponent unitCacheComponent = scene.GetComponent<UnitCacheComponent>(); |
|
using (ListComponent<Entity> entityList = ListComponent<Entity>.Create()) |
|
{ |
|
for (int i = 0; i < request.EntityTypes.Count; i++) |
|
{ |
|
Type type = Game.EventSystem.GetType(request.EntityTypes[i]); |
|
Entity entity = (Entity) MongoHelper.FromBson(type, request.EntityBytes[i]); |
|
entityList.Add(entity); |
|
} |
|
|
|
await unitCacheComponent.AddOrUpdate(request.UnitId, entityList); |
|
} |
|
} |
|
} |
|
} |