private void UpdateMobSpawners( RequestCache requestCache) { foreach (MobSpawner spawner in m_chosenMobSpawners) { MobQueries.UpdateMobSpawner(requestCache.DatabaseContext, spawner); } }
public override void WriteDirtyObjectToDatabase(AsyncRPGDataContext db_context) { if (IsDirty) { MobQueries.UpdateMob(db_context, this); IsDirty = false; } }
public void Initialize(AsyncRPGDataContext db_context) { m_mobTypesById = MobQueries.LoadMobTypes(db_context); // Build the name -> type table foreach (MobType mob_type in m_mobTypesById.Values) { m_mobTypesByName.Add(mob_type.Name, mob_type); } }
public void Initialize( AsyncRPGDataContext db_context, MobTypeSet mobTypeSet) { m_mobSpawnTablesById = MobQueries.LoadMobSpawnTables(db_context, mobTypeSet); foreach (MobSpawnTable mobSpawnTable in m_mobSpawnTablesById.Values) { m_mobSpawnTablesByName.Add(mobSpawnTable.Name, mobSpawnTable); } }
public Mob GetMob(AsyncRPGDataContext db_context, MobTypeSet mobTypeSet, int mobID) { Mob mob = null; if (!m_mobs.TryGetValue(mobID, out mob)) { mob = MobQueries.GetMob(db_context, mobTypeSet, mobID); m_mobs.Add(mobID, mob); } return(mob); }
public IEnumerable <Mob> GetMobs(AsyncRPGDataContext db_context, MobTypeSet mobTypeSet) { if (!m_allMobsCached) { foreach (Mob mob in MobQueries.GetMobs(db_context, mobTypeSet, m_roomKey)) { if (!m_mobs.ContainsKey(mob.ID)) { m_mobs.Add(mob.ID, mob); } } } return(m_mobs.Values); }
public bool Initialize(string connectionString, out string result) { bool success = MobQueries.LoadMobTypes(connectionString, out m_mobTypesById, out result); if (success) { // Build the name -> type table foreach (MobType mob_type in m_mobTypesById.Values) { m_mobTypesByName.Add(mob_type.Name, mob_type); } } return(success); }
private void SpawnMobs( RequestCache requestCache) { foreach (MobSpawner spawner in m_chosenMobSpawners) { Mob newMob = spawner.SpawnRandomMob(); // Locally keep track of all the mobs we created for the next steps m_newMobs.Add(newMob); } // Save the mobs into the DB MobQueries.InsertMobs(requestCache.DatabaseContext, m_room.room_key, m_newMobs); // Add the mob to the cached room data now that is has a valid mob id foreach (Mob newMob in m_newMobs) { requestCache.AddMob(newMob); } }
public bool Initialize( string connection_string, MobTypeSet mobTypeSet, out string result) { bool success = MobQueries.LoadMobSpawnTables( connection_string, mobTypeSet, out m_mobSpawnTablesById, out result); if (success) { foreach (MobSpawnTable mobSpawnTable in m_mobSpawnTablesById.Values) { m_mobSpawnTablesByName.Add(mobSpawnTable.Name, mobSpawnTable); } } return(success); }
//TODO: LoadRoom - Convert this over to a request processor public static bool LoadRoom( AsyncRPGDataContext context, World world, RoomKey room_key, out Room room, out string result) { bool success; string json_static_data = WorldQueries.GetRoomStaticData(context, room_key); room = null; success = false; // Load static room data for this room if (json_static_data.Length > 0) { StaticRoomData static_room_data = null; try { if (json_static_data.Length == 0) { throw new ArgumentException(); } static_room_data = JsonMapper.ToObject <StaticRoomData>(json_static_data); } catch (System.Exception) { static_room_data = null; } if (static_room_data != null) { room = new Room(room_key); room.static_room_data = static_room_data; success = true; result = SuccessMessages.GENERAL_SUCCESS; } else { result = ErrorMessages.DB_ERROR + "(Failed to parse room static data)"; } } else { result = ErrorMessages.DB_ERROR + "(Failed to get room static data)"; } // If the static room data parsed, load everything else if (success) { RoomTemplate roomTemplate = world.RoomTemplates.GetTemplateByName(room.static_room_data.room_template_name); // Load the random seed for the room room.random_seed = WorldQueries.GetRoomRandomSeed(context, room_key); // Setup the runtime nav mesh room.runtime_nav_mesh = new NavMesh(room.room_key, roomTemplate.NavMeshTemplate); // Load all of the portals for this room room.portals = WorldQueries.GetRoomPortals(context, room_key); // Flag all of the room sides that have portals foreach (Portal p in room.portals) { room.portalRoomSideBitmask.Set(p.room_side, true); } // Load mob spawners for this room room.mobSpawners = MobQueries.GetMobSpawners(context, world.MobSpawnTables, room_key); } return(success); }