internal int SummonNpc(NpcToSummon summonParameters) { NpcMonster npcMonster = ServerManager.GetNpc(summonParameters.VNum); if (npcMonster != null) { MapNpc mapNpc = new MapNpc { NpcVNum = npcMonster.NpcMonsterVNum, MapY = summonParameters.SpawnCell.X, MapX = summonParameters.SpawnCell.Y, MapId = Map.MapId, IsHostile = false, IsMoving = summonParameters.Move, MapNpcId = GetNextNpcId(), Target = summonParameters.Target, OnDeathEvents = summonParameters.DeathEvents, IsMate = summonParameters.IsMate, IsProtected = summonParameters.IsProtected }; mapNpc.Initialize(this); AddNPC(mapNpc); Broadcast(mapNpc.GenerateIn()); return(mapNpc.MapNpcId); } return(default);
public void LoadNpcs() { foreach (MapNpcDTO npc in DAOFactory.MapNpcDAO.LoadFromMap(Map.MapId).ToList()) { MapNpc np = npc as MapNpc; np.Initialize(this); _npcs[np.MapNpcId] = np; _mapNpcIds.Add(np.MapNpcId); } }
public void LoadNpcs() { Parallel.ForEach(DAOFactory.MapNpcDAO.LoadFromMap(Map.MapId).ToList(), npc => { MapNpc mapNpc = new MapNpc(npc); mapNpc.Initialize(this); int mapNpcId = mapNpc.MapNpcId; _npcs[mapNpcId] = mapNpc; _mapNpcIds[mapNpcId] = mapNpcId; }); }
public void LoadNpcs() { var partitioner = Partitioner.Create(DAOFactory.MapNpcDAO.LoadFromMap(Map.MapId), EnumerablePartitionerOptions.None); Parallel.ForEach(partitioner, npc => { MapNpc mapNpc = npc as MapNpc; mapNpc.Initialize(this); int mapNpcId = mapNpc.MapNpcId; _npcs[mapNpcId] = mapNpc; _mapNpcIds.Add(mapNpcId); }); }
internal List <int> SummonNpcs(List <NpcToSummon> summonParameters) { List <int> ids = new List <int>(); foreach (NpcToSummon mon in summonParameters) { NpcMonster npcmonster = ServerManager.Instance.GetNpc(mon.VNum); if (npcmonster != null) { MapNpc npc = new MapNpc { NpcVNum = npcmonster.NpcMonsterVNum, MapY = mon.SpawnCell.X, MapX = mon.SpawnCell.Y, MapId = Map.MapId, IsHostile = true, IsMoving = true, MapNpcId = GetNextNpcId(), Target = mon.Target, OnDeathEvents = mon.DeathEvents, IsMate = mon.IsMate, IsProtected = mon.IsProtected }; npc.Initialize(this); AddNPC(npc); Broadcast(npc.GenerateIn()); ids.Add(npc.MapNpcId); } } return(ids); }