public static MapEditor GetOrCreateEditor(Map map) { MapEditor editor; if (!EditorsByMap.TryGetValue(map, out editor)) { EditorsByMap.Add(map, editor = new MapEditor(map)); } return editor; }
public static MapEditor StartEditing(Map map, Character chr = null) { var editor = GetOrCreateEditor(map); if (chr != null) { editor.Join(chr); } return editor; }
public static ObjectReference GetOrCreate(Map rgn, EntityId id) { var caster = rgn.GetObject(id); if (caster != null) { return caster.SharedReference; } return new ObjectReference(id, 1); }
/// <summary> /// Creates a new GameObject with the given parameters /// </summary> public static GameObject Create(GOEntryId id, Map map, GOSpawnEntry spawnEntry = null, GOSpawnPoint spawnPoint = null) { var entry = GOMgr.GetEntry(id); if (entry != null) { return Create(entry, map, spawnEntry, spawnPoint); } return null; }
public Zone(Map rgn, ZoneTemplate template) { Map = rgn; Template = template; if (template.WorldStates != null) { WorldStates = new WorldStateCollection(this, template.WorldStates); } CreateChatChannels(); }
public Ticket(Character chr, string message, TicketType type) { m_owner = chr; m_ownerName = chr.Name; m_charId = chr.EntityId.Low; m_Message = message; m_Map = chr.Map; Position = chr.Position; Phase = chr.Phase; m_Timestamp = DateTime.Now; m_Type = type; }
public static IMessage GetRemoveObjectTask(WorldObject obj, Map rgn) { var moveTask = new Message2<WorldObject, Map>(); moveTask.Parameter1 = obj; moveTask.Parameter2 = rgn; moveTask.Callback = ((worldObj, objRgn) => { objRgn.RemoveObjectNow(worldObj); }); return moveTask; }
public static IMessage GetInitializeCharacterTask(Character chr, Map rgn) { var initTask = new Message2<Character, Map>(); initTask.Parameter1 = chr; initTask.Parameter2 = rgn; initTask.Callback = ((initChr, initRgn) => { initRgn.AddObjectNow(chr); //Map.s_log.Debug("Owner added to the map"); //Map.s_log.Debug("Owner initialized"); }); return initTask; }
public DynamicObject(Unit creator, SpellId spellId, float radius, Map map, Vector3 pos) { if (creator == null) throw new ArgumentNullException("creator", "creator must not be null"); Master = creator; EntityId = EntityId.GetDynamicObjectId(++lastId); Type |= ObjectTypes.DynamicObject; SetEntityId(DynamicObjectFields.CASTER, creator.EntityId); SpellId = spellId; Radius = radius; Bytes = 0x01EEEEEE; ScaleX = 1; m_position = pos; map.AddObjectLater(this); }
public TeleportNode(string defaultName, Map rgn, Vector3 pos) { DefaultName = defaultName; Map = rgn; Position = pos; }
public void TeleportTo(Map map, bool wait) { TeleportTo(map, ref m_position, 3f, wait); }
/// <summary> /// Sets the entry position of the character. /// </summary> public void SetCharacterEntry(Map map, ref Vector3 pos, float orientation) { m_EntryMap = map; _entryPosition = pos; _entryOrientation = orientation; }
public NPC SpawnAt(Map map, Vector3 pos, bool hugGround = false) { var npc = Create(map.DifficultyIndex); if (hugGround && InhabitType == InhabitType.Ground) { pos.Z = map.Terrain.GetGroundHeightUnderneath(pos); } map.AddObject(npc, pos); return npc; }
internal void OnOwnerLogout() { TicketMgr.Instance.lck.EnterWriteLock(); try { Position = m_owner.Position; m_Map = m_owner.Map; Phase = m_owner.Phase; m_owner = null; var handler = m_handler; if (handler != null) { handler.SendMessage("Owner of the Ticket you are handling went -{0}-.", ChatUtility.Colorize("offline", Color.Red)); } } finally { TicketMgr.Instance.lck.ExitWriteLock(); } }
/// <summary> /// Returns the character to their original location prior to entering the Battleground. /// </summary> public void TeleportBack() { if (m_EntryMap == null || m_EntryMap.IsDisposed || _entryPosition.X == 0) { _chr.TeleportToBindLocation(); } else { _chr.TeleportTo(m_EntryMap, ref _entryPosition, _entryOrientation); } m_EntryMap = null; }
/// <summary> /// Creates a new duel between the 2 parties. /// </summary> /// <param name="challenger"></param> /// <param name="rival"></param> /// <param name="startDelay"></param> /// <param name="cancelDelay"></param> internal Duel(Character challenger, Character rival, int startDelay, int cancelDelay) { m_challenger = challenger; m_rival = rival; m_Map = challenger.Map; m_startDelay = startDelay; m_cancelDelay = cancelDelay; m_challenger.Duel = this; m_challenger.DuelOpponent = rival; m_rival.Duel = this; m_rival.DuelOpponent = challenger; Initialize(); }
private void SetCaster(ObjectReference caster, Map map, uint phase, Vector3 sourceLoc) { CasterReference = caster; if (caster == null) { throw new ArgumentNullException("caster"); } CasterObject = caster.Object; CasterUnit = caster.UnitMaster; Map = map; Phase = phase; SourceLoc = sourceLoc; }
public static void LoadDefaultMaps() { foreach (var rgnInfo in s_MapTemplates) { if (rgnInfo != null && rgnInfo.Type == MapType.Normal) { var map = new Map(rgnInfo); if (map.Id == MapId.Outland) { map.XpCalculator = XpGenerator.CalcOutlandXp; } else if (map.Id == MapId.Northrend) { map.XpCalculator = XpGenerator.CalcNorthrendXp; } else { map.XpCalculator = XpGenerator.CalcDefaultXp; } map.InitMap(); AddMap(map); } } }
public static SpellCast ObtainPooledCast(ObjectReference caster, Map map, uint phase, ref Vector3 sourceLoc) { var cast = SpellCastPool.Obtain(); cast.SetCaster(caster, map, phase, sourceLoc); return cast; }
/// <summary> /// Returns the GOTemplate of this entry that is closest to the given location /// </summary> public GOSpawnEntry GetClosestTemplate(Map rgn, Vector3 pos) { return SpawnEntries.GetClosestEntry(new WorldLocationStruct(rgn, pos)); }
public void TeleportTo(Map map, ref Vector3 pos, float? orientation, bool wait) { if (!HasNode) { m_Map = null; } Assert.IsNotNull(map); if (Map == map) { Assert.IsTrue(Map.MoveObject(this, ref pos)); if (orientation.HasValue) { Orientation = orientation.Value; } } else { map.TransferObject(this, pos, wait); if (orientation != null) { Orientation = orientation.Value; } LastPosition = pos; } }
/// <summary> /// Teleports the owner to the given position in the given map. /// </summary> /// <param name="map">the target <see cref="Map" /></param> /// <param name="pos">the target <see cref="Vector3">position</see></param> /// <param name="orientation">the target orientation</param> public void TeleportTo(Map map, ref Vector3 pos, float? orientation) { var ownerMap = m_Map; if (map.IsDisposed) return; // must not be moving or logging out when being teleported CancelMovement(); CancelAllActions(); if (this is Character) { ((Character)this).CancelLogout(); } if (ownerMap == map) { if (Map.MoveObject(this, ref pos)) { if (orientation.HasValue) Orientation = orientation.Value; if (this is Character) { var chr = ((Character)this); chr.LastPosition = pos; MovementHandler.SendMoved(chr); } } } else { if (ownerMap != null && !ownerMap.IsInContext) { var position = pos; ownerMap.AddMessage(new Message(() => TeleportTo(map, ref position, orientation))); } else if (map.TransferObjectLater(this, pos)) { if (orientation.HasValue) { Orientation = orientation.Value; } if (this is Character) { var chr = ((Character)this); chr.LastPosition = pos; MovementHandler.SendNewWorld(chr.Client, map.Id, ref pos, Orientation); } } else { // apparently, the target map has a colliding entity ID. this should NEVER // happen for any kind of Unit log.Error("ERROR: Tried to teleport object, but failed to add player to the new map - " + this); } } }
/// <summary> /// Teleports the owner to the given position in the given map. /// </summary> /// <param name="map">the target <see cref="Map" /></param> /// <param name="pos">the target <see cref="Vector3">position</see></param> /// <param name="orientation">the target orientation</param> public void TeleportTo(Map map, Vector3 pos, float? orientation) { TeleportTo(map, ref pos, orientation); }
/// <summary> /// Teleports the owner to the given position in the given map. /// </summary> /// <param name="map">the target <see cref="Map" /></param> /// <param name="pos">the target <see cref="Vector3">position</see></param> public void TeleportTo(Map map, Vector3 pos) { TeleportTo(map, ref pos, null); }
/// <summary> /// Spawns and returns a new GameObject from this template into the given map /// </summary> /// <param name="owner">Can be null, if the GO is not owned by anyone</param> /// <returns>The newly spawned GameObject or null, if the Template has no Entry associated with it.</returns> public GameObject Spawn(Map map, Vector3 pos, Unit owner = null) { if (map == null) throw new ArgumentNullException("map"); return Spawn(new WorldLocation(map, pos), owner); }
public static GameObject Create(GOEntry entry, Map map, GOSpawnEntry spawnEntry = null, GOSpawnPoint spawnPoint = null) { return Create(entry, new WorldLocation(map, Vector3.Zero), spawnEntry, spawnPoint); }
/// <summary> /// Adds the map, associated with its unique Id /// </summary> /// <param name="map">the map to add</param> private static void AddMap(Map map) { MapCount++; if (s_Maps[(uint)map.Id] != null) { throw new InvalidOperationException("Tried to a second non-instanced map of the same type to World: " + map); } ArrayUtil.Set(ref s_Maps, (uint)map.Id, map); }
public MapEditor(Map map) { Map = map; Menu = new MapEditorMenu(this); m_IsVisible = false; }
public NavFigurine(Map map, Vector3 location) : this() { map.AddObject(this, ref location); }
/// <summary> /// Spawns and returns a new Corpse at the given location /// </summary> /// <param name="bones"></param> /// <param name="lootable"></param> /// <returns></returns> public Corpse SpawnCorpse(bool bones, bool lootable, Map map, Vector3 pos, float o) { var corpse = new Corpse(this, pos, o, DisplayId, Facial, Skin, HairStyle, HairColor, FacialHair, GuildId, Gender, Race, bones ? CorpseFlags.Bones : CorpseFlags.None, lootable ? CorpseDynamicFlags.PlayerLootable : CorpseDynamicFlags.None); for (var i = EquipmentSlot.Head; i <= EquipmentSlot.Tabard; i++) { var item = m_inventory[(int)i]; if (item != null) { corpse.SetItem(i, item.Template); } } corpse.Position = pos; map.AddObjectLater(corpse); return corpse; }