public void Initialize() { for (int i = 0; i <= RegionsX; i++) { for (int j = 0; j <= RegionsY; j++) { _worldRegions[i, j] = new L2WorldRegion(i, j); } } for (int x = 0; x <= RegionsX; x++) { for (int y = 0; y <= RegionsY; y++) { for (int a = -1; a <= 1; a++) { for (int b = -1; b <= 1; b++) { if (ValidRegion(x + a, y + b)) { _worldRegions[x + a, y + b].AddSurroundingRegion(_worldRegions[x, y]); } } } } } Log.Info($"L2World: WorldRegion grid ({RegionsX} by {RegionsY}) is now setted up."); }
public virtual void SpawnMe(bool notifyOthers = true) { Region = L2World.Instance.GetRegion(new Location(X, Y, Z)); L2World.Instance.AddObject(this); OnSpawn(notifyOthers); }
public virtual void SpawnMe() { Region = L2World.Instance.GetRegion(new Location(X, Y, Z)); L2World.Instance.AddObject(this); OnSpawn(); }
public virtual void SetRegion(L2WorldRegion newRegion) { List <L2WorldRegion> oldAreas = new List <L2WorldRegion>(); if (Region != null) { Region.RemoveVisibleObject(this); oldAreas = Region.GetSurroundingRegions(); } List <L2WorldRegion> newAreas = new List <L2WorldRegion>(); if (newRegion != null) { newRegion.AddVisibleObject(this); newAreas = newRegion.GetSurroundingRegions(); } foreach (L2WorldRegion region in oldAreas.Where(region => !newAreas.Contains(region))) { foreach (L2Object obj in region.GetObjects().Where(obj => obj != this)) { obj.RemoveKnownObject(this); RemoveKnownObject(obj); } if (this is L2Player && region.IsEmptyNeighborhood()) { region.SetActive(false); } } foreach (L2WorldRegion region in newAreas.Where(region => !oldAreas.Contains(region))) { // Update all objects. foreach (L2Object obj in region.GetObjects().Where(obj => obj != this)) { obj.AddKnownObject(this); AddKnownObject(obj); } // Activate the new neighbor region. if (this is L2Player) { region.SetActive(true); } } Region = newRegion; }
public virtual List <L2Player> GetKnownPlayers() { L2WorldRegion region = Region; if (region == null) { return(new List <L2Player>()); } List <L2Player> result = new List <L2Player>(); region.GetSurroundingRegions().ForEach(reg => result.AddRange(L2World.Instance.GetPlayers().Where(obj => obj != this))); return(result); }
public override void SetRegion(L2WorldRegion newRegion) { // confirm revalidation of old region's zones if (Region != null) { if (newRegion != null) { Region.RevalidateZones(this); } else { Region.RemoveFromZones(this); } } base.SetRegion(newRegion); }
public virtual void DecayMe() { Region = null; L2World.Instance.RemoveObject(this); }
public void AddSurroundingRegion(L2WorldRegion region) { _surroundingRegions.Add(region); }