private async Task CallbackEntity(Nuid id, EntityEvent entity_event, NList args) { string entity_type = Global.NULL_STRING; Entity entity = EntityManager.Get(id); if (entity != null) { entity_type = entity.Type; } else { entity_type = await GetCacheType(id); } EntityPrefab entity_prefab = Prefabs.GetEntity(entity_type); if (entity_prefab == null) { return; } if (entity_prefab.ancestors != null && entity_prefab.ancestors.Count > 0) { for (int i = entity_prefab.ancestors.Count - 1; i >= 0; i--) { string parent_type = entity_prefab.ancestors[i]; await NModule.CallbackEntity(this, id, parent_type, entity_event, args); } } await NModule.CallbackEntity(this, id, entity_type, entity_event, args); }
private async Task OnRecv_Custom(NList msg) { int custom_msg = msg.Get <int>(0); NList args = msg.GetRange(1, msg.Count - 1); await NModule.CallbackCustom(_RoleNode, _RoleId, custom_msg, args); }
public async Task Custom(Nuid id, int custom, NList msg) { Entity entity = EntityManager.Get(id); if (entity != null) { await NModule.CallbackCustom(this, id, custom, msg); await SyncManager.Callback(SyncType.Custom, this, id, NList.New().Add(custom).Append(msg)); } else { if (id.Origin == Identity) { return; } INode node = GrainFactory.GetGrain <INode>(id.Origin); if (await node.IsActive()) { await node.Custom(id, custom, msg); } } }
private static void LoadModules() { var moduels = from t in Assembly.Load("Game.Modules").GetTypes() where Global.IsSubClassOf(t, typeof(NModule)) select t; foreach (Type type in moduels) { NModule.LoadModule(type); } }
private async Task CallbackTable(Nuid id, string table_name, TableEvent table_event, NList args) { string entity_type = Global.NULL_STRING; Entity entity = EntityManager.Get(id); if (entity != null) { entity_type = entity.Type; } else { entity_type = await GetCacheType(id); } EntityPrefab entity_prefab = Prefabs.GetEntity(entity_type); if (entity_prefab == null) { return; } if (entity_prefab.ancestors != null && entity_prefab.ancestors.Count > 0) { for (int i = entity_prefab.ancestors.Count - 1; i >= 0; i--) { string parent_type = entity_prefab.ancestors[i]; await NModule.CallbackTable(this, id, parent_type, table_name, table_event, args); } } await NModule.CallbackTable(this, id, entity_type, table_name, table_event, args); TablePrefab table_prefab = entity_prefab.tables[table_name]; if (table_prefab != null && table_prefab.sync) { NList msg = NList.New().Add(id).Add(table_name).Add((int)table_event).Append(args); await SyncTable(id, msg); } }
private async Task CallbackField(Nuid id, string field_name, FieldEvent field_event, NList args) { string entity_type = Global.NULL_STRING; Entity entity = EntityManager.Get(id); if (entity != null) { entity_type = entity.Type; } else { entity_type = await GetCacheType(id); } EntityPrefab entity_prefab = Prefabs.GetEntity(entity_type); if (entity_prefab == null) { return; } if (entity_prefab.ancestors != null && entity_prefab.ancestors.Count > 0) { for (int i = entity_prefab.ancestors.Count - 1; i >= 0; i--) { string parent_type = entity_prefab.ancestors[i]; await NModule.CallbackField(this, id, parent_type, field_name, field_event, args); } } await NModule.CallbackField(this, id, entity_type, field_name, field_event, args); FieldPrefab field_prefab = entity_prefab.fields[field_name]; if (field_prefab != null && field_prefab.sync) { NList msg = NList.New().Add(id).Add(field_name).Add((int)field_event).Append(args); await SyncManager.Callback(SyncType.Field, this, id, msg); } }
public async Task Command(Nuid id, int command, NList msg) { Entity entity = EntityManager.Get(id); if (entity != null) { await NModule.CallbackCommand(this, id, command, msg); } else { if (id.Origin == Identity) { await NModule.CallbackCommand(this, id, command, msg); } else { INode node = GrainFactory.GetGrain <INode>(id.Origin); await node.Command(id, command, msg); } } }