public static ExtractedWMO Process(string basePath, MapId mapId, string path)
        {
            basePath = Path.Combine(basePath, mapId.ToString());
            var filePath = Path.Combine(basePath, path);
            filePath = Path.ChangeExtension(filePath, ".wmo");

            if (!File.Exists(filePath))
            {
                throw new FileNotFoundException("Extracted M2 file not found: {0}", filePath);
            }

            var wmo = new ExtractedWMO();

            using (var file = File.OpenRead(filePath))
            using (var br = new BinaryReader(file))
            {
                var type = br.ReadString();
                if (type != fileType)
                {
                    br.Close();
                    throw new InvalidDataException(string.Format("WMO file in invalid format: {0}", filePath));
                }

                wmo.Extents = br.ReadBoundingBox();
                wmo.WMOId = br.ReadUInt32();

                ReadWMODoodadDefs(br, wmo);

                ReadWMOGroups(br, wmo);
            }
            return wmo;
        }
Exemple #2
0
        /// <summary>
        /// Gets the nearest valid (i.e., not over a hole, outside map boundaries, etc) position to the given position.
        /// </summary>
        /// <param name="mapId">The <see cref="WCell.Constants.World.MapId"/> that corresponds to the desired map.</param>
        /// <param name="pos">The position to check against.</param>
        /// <param name="validPos">The nearest valid position to the given position.</param>
        /// <returns>True if the check was successful.</returns>
        public bool GetNearestValidPosition(MapId mapId, Vector3 pos, out Vector3 validPos)
        {
            validPos = Vector3.Zero;

            Map map;
            return ((!TryGetMap(mapId, out map)) || (map.GetNearestValidPosition(pos, out validPos)));
        }
Exemple #3
0
        /// <summary>
        /// Get the height of the floor underneath the given position on the map with the given MapId.
        /// </summary>
        /// <param name="mapId">The <see cref="WCell.Constants.World.MapId"/> that corresponds to the desired map.</param>
        /// <param name="pos">The position on the map to get the height at.</param>
        /// <param name="height">The height of the floor at the given position on the map.</param>
        /// <returns>True if the height retrieval was successful.</returns>
        public bool GetHeightAtPosition(MapId mapId, Vector3 pos, out float height)
        {
            height = float.MinValue;

            Map map;
            return ((!TryGetMap(mapId, out map)) || (map.GetHeightAtPosition(pos, out height)));
        }
Exemple #4
0
		public static bool HasLOS(MapId mapId, Vector3 startPos, Vector3 endPos)
		{
			float tMax;
			var ray = CollisionHelper.CreateRay(startPos, endPos, out tMax);
			var intTMax = (int)(tMax + 0.5f);

			for (var t = 0; t < intTMax; t++)
			{
				var currentPos = ray.Position + ray.Direction * t;

				TileCoord currentTileCoord;
				ChunkCoord currentChunkCoord;
				PointX2D currentPointX2D;
				var currentHeightMapFraction = LocationHelper.GetFullInfoForPos(currentPos,
																				out currentTileCoord,
																				out currentChunkCoord,
																				out currentPointX2D);

				var currentTile = GetTile(mapId, currentTileCoord);
				if (currentTile == null)
				{
					// Can't check non-existant tiles.
					return false;
				}

				var terrainHeight = currentTile.GetInterpolatedHeight(currentChunkCoord, currentPointX2D, currentHeightMapFraction);

				if (terrainHeight < currentPos.Z) continue;
				return false;
			}

			return true;
		}
Exemple #5
0
        /// <summary>
        /// Gets the nearest walkable (i.e., not water, model, air, etc) position to the given position.
        /// </summary>
        /// <param name="mapId">The <see cref="WCell.Constants.World.MapId"/> that corresponds to the desired map.</param>
        /// <param name="pos">The position to check against.</param>
        /// <param name="walkablePos">The nearest walkable position to the given position.</param>
        /// <returns>True if the check was successful.</returns>
        public bool GetNearestWalkablePositon(MapId mapId, Vector3 pos, out Vector3 walkablePos)
        {
            walkablePos = Vector3.Zero;

            Map map;
            return ((!TryGetMap(mapId, out map)) || (map.GetNearestWalkablePosition(pos, out walkablePos)));
        }
        public static ExtractedM2 Process(string basePath, MapId mapId, string path)
        {
            basePath = Path.Combine(basePath, mapId.ToString());
            var filePath = Path.Combine(basePath, path);
            filePath = Path.ChangeExtension(filePath, ".m2x");

            if (!File.Exists(filePath))
            {
                throw new FileNotFoundException("Extracted M2 file not found: {0}", filePath);
            }

            var m2 = new ExtractedM2();

            using(var file = File.OpenRead(filePath))
            using(var br = new BinaryReader(file))
            {
                var type = br.ReadString();
                if (type != fileType)
                {
                    br.Close();
                    throw new InvalidDataException(string.Format("M2x file in invalid format: {0}", filePath));
                }

                m2.Extents = br.ReadBoundingBox();
                m2.BoundingVertices = br.ReadVector3List();
                m2.BoundingTriangles = br.ReadIndex3List();

                br.Close();
            }

            return m2;
        }
		public void FinalizeDataHolder()
		{
			RegionId = BattlegroundMgr.BattlemasterListReader.Entries[(int)Id].MapId;

			RegionInfo = World.GetRegionInfo(RegionId);
			if (RegionInfo == null)
			{
				ContentHandler.OnInvalidDBData("BattlegroundTemplate had invalid RegionId: {0} (#{1})",
					RegionId, (int)RegionId);
				return;
			}

			if (BattlegroundMgr.Templates.Length <= (int)Id)
			{
				ContentHandler.OnInvalidDBData("BattlegroundTemplate had invalid BG-Id: {0} (#{1})",
					Id, (int)Id);
				return;
			}

			RegionInfo.MinLevel = Math.Max(1, MinLevel);
			RegionInfo.MaxLevel = Math.Max(MinLevel, MaxLevel);

			BattlegroundMgr.Templates[(int)Id] = this;

			CreateQueues();
            SetStartPos();
		}
Exemple #8
0
		public InstanceBinding(uint id, MapId mapId, uint difficultyIndex)
		{
			BindTime = DateTime.Now;
			DifficultyIndex = difficultyIndex;
			InstanceId = id;
			MapId = mapId;
		}
		public void FinalizeDataHolder()
		{
			MapId = BattlegroundMgr.BattlemasterListReader.Entries[(int)Id].MapId;

			MapTemplate = World.GetMapTemplate(MapId);
			if (MapTemplate == null)
			{
				ContentMgr.OnInvalidDBData("BattlegroundTemplate had invalid MapId: {0} (#{1})",
					MapId, (int)MapId);
				return;
			}

			if (BattlegroundMgr.Templates.Length <= (int)Id)
			{
				ContentMgr.OnInvalidDBData("BattlegroundTemplate had invalid BG-Id: {0} (#{1})",
					Id, (int)Id);
				return;
			}
			MapTemplate.BattlegroundTemplate = this;

			Difficulties = new PvPDifficultyEntry[BattlegroundMgr.PVPDifficultyReader.Entries.Values.Count(entry => (entry.mapId == MapId))];

			foreach (var entry in BattlegroundMgr.PVPDifficultyReader.Entries.Values.Where(entry => (entry.mapId == MapId)))
			{
				Difficulties[entry.bracketId] = entry;
			}

			MinLevel = MapTemplate.MinLevel = Difficulties.First().minLevel;
			MaxLevel = MapTemplate.MaxLevel = Difficulties.Last().maxLevel;
			BattlegroundMgr.Templates[(int)Id] = this;

			CreateQueues();
			SetStartPos();
		}
Exemple #10
0
		public WorldState(MapId mapId, ZoneId zoneId, uint key, int value)
		{
			MapId = mapId;
			ZoneId = zoneId;
			Key = (WorldStateId)key;
			DefaultValue = value;
		}
 public ExtractedADTManager(ExtractedTerrainManager terrainManager, string basePath, MapId mapId)
 {
     _mapId = mapId;
     _terrainManager = terrainManager;
     _basePath = basePath;
     MapTiles = new List<ADTBase>();
 }
Exemple #12
0
        internal static bool TryLoad(MapId mapId, out Map map)
        {
            map = null;
            var basePath = TerrainDisplayConfig.MapDir;
            var mapPath = Path.Combine(basePath, mapId.ToString());
            var fileName = string.Format("{0}{1}", mapId, Extension);
            var filePath = Path.Combine(mapPath, fileName);

            if (!Directory.Exists(mapPath))
            {
                log.Warn("Unable to find requested .map dir: {0}", mapPath);
                return false;
            }
            if (!File.Exists(filePath))
            {
                log.Warn("Unable to find requested .map file: {0}", filePath);
                return false;
            }

            using(var file = File.OpenRead(filePath))
            {
                map = ReadWDTInfo(file);
                file.Close();

                if (map == null)
                {
                    log.Warn("Unable to load the requested .map file: {0}", filePath);
                    return false;
                }
            }

            map.MapId = mapId;
            return true;
        }
Exemple #13
0
		public void FinalizeDataHolder()
		{
			RegionId = BattlegroundMgr.BattlemasterListReader.Entries[(int)Id].MapId;

			RegionTemplate = World.GetRegionTemplate(RegionId);
			if (RegionTemplate == null)
			{
				ContentMgr.OnInvalidDBData("BattlegroundTemplate had invalid RegionId: {0} (#{1})",
					RegionId, (int)RegionId);
				return;
			}

			if (BattlegroundMgr.Templates.Length <= (int)Id)
			{
				ContentMgr.OnInvalidDBData("BattlegroundTemplate had invalid BG-Id: {0} (#{1})",
					Id, (int)Id);
				return;
			}

            Difficulties = new PvPDifficultyEntry[BattlegroundMgr.PVPDifficultyReader.Entries.Values.Count(entry => (entry.mapId == RegionId))];

            foreach (var entry in BattlegroundMgr.PVPDifficultyReader.Entries.Values)
            {
                if (entry.mapId == RegionId)
                    Difficulties[entry.bracketId] = entry;
            }

            RegionTemplate.MinLevel = Math.Max(1, MinLevel);
            RegionTemplate.MaxLevel = Math.Max(MinLevel, MaxLevel);

			BattlegroundMgr.Templates[(int)Id] = this;

			CreateQueues();
            SetStartPos();
		}
 public ExtractedWMOManager(string _baseDirectory, MapId _mapId)
 {
     this._baseDirectory = _baseDirectory;
     this._mapId = _mapId;
     _WMOs = new List<ExtractedWMO>();
     _WMOM2s = new List<ExtractedM2>();
 }
Exemple #15
0
 /// <summary>
 /// An instance has been reset
 /// </summary>
 public static void SendInstanceReset(IPacketReceiver client, MapId mapId)
 {
     using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_UPDATE_LAST_INSTANCE, 4))
     {
         packet.Write((int)mapId);
         client.Send(packet);
     }
 }
Exemple #16
0
 /// <summary>
 /// Creates a dummy Terrain and loads the given tile into it
 /// </summary>
 public static TerrainTile LoadTile(MapId map, int x, int y)
 {
     var terrain = new SimpleTerrain(map);
     terrain.TileProfile[x, y] = true;
     var tile = terrain.LoadTile(x, y);
     terrain.Tiles[x, y] = tile;
     return tile;
 }
Exemple #17
0
        public ITerrain CreateTerrain(MapId id)
        {
            if (!WorldMap.TerrainDataExists(id))
            {
                return new EmptyTerrain();
            }

            return new FullTerrain(id);
        }
Exemple #18
0
		public WorldLocation(MapId region, Vector3 pos)
		{
			Position = pos;
			Region = World.GetRegion(region);
			if (Region == null)
			{
				throw new Exception("Invalid Region in WorldLocation: " + region);
			}
		}
Exemple #19
0
		public WorldLocation(MapId map, Vector3 pos, uint phase = WorldObject.DefaultPhase)
		{
			Position = pos;
			Map = World.GetNonInstancedMap(map);
			if (Map == null)
			{
				throw new ArgumentException("map", "Invalid Map in WorldLocation: " + map);
			}
			Phase = phase;
		}
Exemple #20
0
        public static WDT ReadWDT(MapId mapId)
        {
            var map = MapInfo.GetMapInfo(mapId);
            if (map == null)
            {
                return null;
            }

            return ReadWDT(map);
        }
Exemple #21
0
		public WorldLocationStruct(MapId map, Vector3 pos, uint phase = WorldObject.DefaultPhase)
		{
			m_Position = pos;
			m_Map = World.GetNonInstancedMap(map);
			if (m_Map == null)
			{
				throw new Exception("Invalid Map in WorldLocationStruct: " + map);
			}
			m_Phase = phase;
		}
Exemple #22
0
		public TeleportNode(string defaultName, MapId id, Vector3 pos)
		{
			DefaultName = defaultName;
			Map = World.GetNonInstancedMap(id);
			if (Map == null)
			{
				throw new ArgumentException("Map is not a continent: " + id);
			}
			Position = pos;
		}
Exemple #23
0
        public static string GetFilename(MapId map, int x, int y)
        {
            var name = TileIdentifier.GetName(map);

            if (name == null)
            {
                throw new ArgumentException("Map does not exist: " + map);
            }
            var fileName = string.Format("{0}\\{0}_{1}_{2}{3}", name, y, x, Extension);
            return Path.Combine(baseDir, fileName);
        }
 public static Vector3[] GenerateWaypoints(MapId map, Vector3 lastPos)
 {
     var terrain = TerrainMgr.GetTerrain(map);
     if (terrain != null)
     {
         var gen = new RandomWaypointGenerator();
         var wps = gen.GenerateWaypoints(terrain, lastPos);
         return wps;
     }
     return new Vector3[0];
 }
Exemple #25
0
		public static void CreateTeleportNPC(NPCId id, Vector3 location, MapId mapId, uint phase = WorldObject.DefaultPhase)
		{
			var spawn = new NPCSpawnEntry(id, mapId, location);
			spawn.FinalizeDataHolder();

			spawn.Spawned += npc =>
			{
				npc.Invulnerable++;
				npc.GossipMenu = WorldLocationMgr.CreateTeleMenu();
			};
		}
Exemple #26
0
 public SimpleWDTTerrain GetOrLoadSimpleWDTTerrain(MapId map)
 {
     Terrain terrain;
     if (!WorldTerrain.TryGetValue(map, out terrain))
     {
         terrain = new SimpleWDTTerrain(map, false);
         terrain.FillTileProfile();
         WorldTerrain.Add(map, terrain);
     }
     return (SimpleWDTTerrain)terrain;
 }
        public ExtractedTerrainManager(string dataPath, TileIdentifier tileId)
        {
            _mapId = tileId.MapId;
            _baseDirectory = dataPath;

            _adtManager = new ExtractedADTManager(this, _baseDirectory, _mapId);
            _m2Manager = new ExtractedM2Manager(_baseDirectory, _mapId);
            _wmoManager = new ExtractedWMOManager(_baseDirectory, _mapId);
            _meshManager = new NavMeshManager();
            _selectedTriangleManager = new SelectedTriangleManager(_adtManager);
        }
Exemple #28
0
		public static Portal Create(MapId targetRgn, Vector3 targetPos)
		{
			var entry = GOMgr.GetEntry(GOPortalEntry.PortalId);
			if (entry == null)
			{
				return null;
			}
			var portal = (Portal)Create(entry, entry.FirstTemplate);
			portal.Target = new WorldLocation(targetRgn, targetPos);
			return portal;
		}
Exemple #29
0
        private static bool CheckIfCollides(MapId map, Vector3 startPos, Vector3 endPos)
        {
            var models = GetPotentialColliders(map, ref startPos, ref endPos);

            // No models intersect this footprint
            if (models.Count == 0) return false;

            float tMax;
            var ray = CollisionHelper.CreateRay(startPos, endPos, out tMax);

            return CollidesWithRay(models, tMax, ray);
        }
Exemple #30
0
        internal static float? GetCollisionDistance(MapId map, Vector3 startPos, Vector3 endPos)
        {
            var models = GetPotentialColliders(map, ref startPos, ref endPos);

            // No models intersect this footprint
            if (models.Count == 0) return null;

            float tMax;
            var ray = CollisionHelper.CreateRay(startPos, endPos, out tMax);

            return ShortestDistanceTo(models, tMax, ray);
        }
Exemple #31
0
        internal static List <NPCSpawnPoolTemplate> GetOrCreateSpawnPoolTemplatesByMap(MapId map)
        {
            var list = SpawnPoolsByMap[(int)map];

            if (list == null)
            {
                SpawnPoolsByMap[(int)map] = list = new List <NPCSpawnPoolTemplate>();
            }
            return(list);
        }
Exemple #32
0
 /// <inheritdoc />
 public bool AnyEntitiesIntersecting(MapId mapId, Box2 box, bool approximate = false) =>
 _entityTreesPerMap[mapId].Query(box, approximate).Any(ent => !ent.Deleted);
Exemple #33
0
 /// <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(MapId map, Vector3 pos)
 {
     return(Spawn(map, pos, null));
 }
Exemple #34
0
 public LoadMapEvent(MapId mapId)
 {
     MapId = mapId;
 }
Exemple #35
0
        /// <inheritdoc />
        public IEnumerable <IEntity> GetEntitiesInRange(MapId mapId, Vector2 point, float range, bool approximate = false)
        {
            var aabb = new Box2(point, point).Enlarged(range);

            return(GetEntitiesIntersecting(mapId, aabb, approximate));
        }
        public void Execute(IConsoleShell shell, string argStr, string[] args)
        {
            if (args.Length != 2)
            {
                shell.WriteLine("Require 2 args for testbed!");
                return;
            }

            var mapManager = IoCManager.Resolve <IMapManager>();

            if (!int.TryParse(args[0], out var mapInt))
            {
                shell.WriteLine($"Unable to parse map {args[0]}");
                return;
            }

            var mapId = new MapId(mapInt);

            if (!mapManager.MapExists(mapId))
            {
                shell.WriteLine("Unable to find map {mapId}");
                return;
            }

            if (shell.Player == null)
            {
                shell.WriteLine("No player found");
                return;
            }

            var player = (IPlayerSession)shell.Player;

            switch (args[1])
            {
            case "boxstack":
                SetupPlayer(mapId, shell, player, mapManager);
                CreateBoxStack(mapId);
                break;

            case "circlestack":
                SetupPlayer(mapId, shell, player, mapManager);
                CreateCircleStack(mapId);
                break;

            case "pyramid":
                SetupPlayer(mapId, shell, player, mapManager);
                CreatePyramid(mapId);
                break;

            case "tumbler":
                SetupPlayer(mapId, shell, player, mapManager);
                CreateTumbler(mapId);
                break;

            default:
                shell.WriteLine($"testbed {args[0]} not found!");
                return;
            }

            shell.WriteLine($"Testbed on map {mapId}");
        }
        public async Task BuckledDyingDropItemsTest()
        {
            var server = StartServer();

            IEntity         human;
            IEntity         chair;
            BuckleComponent buckle = null;
            HandsComponent  hands  = null;
            IBody           body   = null;

            await server.WaitAssertion(() =>
            {
                var mapManager = IoCManager.Resolve <IMapManager>();

                var mapId = new MapId(1);
                mapManager.CreateNewMapEntity(mapId);

                var entityManager = IoCManager.Resolve <IEntityManager>();
                var gridId        = new GridId(1);
                var grid          = mapManager.CreateGrid(mapId, gridId);
                var coordinates   = grid.GridEntityId.ToCoordinates();
                var tileManager   = IoCManager.Resolve <ITileDefinitionManager>();
                var tileId        = tileManager["underplating"].TileId;
                var tile          = new Tile(tileId);

                grid.SetTile(coordinates, tile);

                human = entityManager.SpawnEntity("HumanMob_Content", coordinates);
                chair = entityManager.SpawnEntity("ChairWood", coordinates);

                // Component sanity check
                Assert.True(human.TryGetComponent(out buckle));
                Assert.True(chair.HasComponent <StrapComponent>());
                Assert.True(human.TryGetComponent(out hands));
                Assert.True(human.TryGetComponent(out body));

                // Buckle
                Assert.True(buckle.TryBuckle(human, chair));
                Assert.NotNull(buckle.BuckledTo);
                Assert.True(buckle.Buckled);

                // Put an item into every hand
                for (var i = 0; i < hands.Count; i++)
                {
                    var akms = entityManager.SpawnEntity("RifleAk", coordinates);

                    // Equip items
                    Assert.True(akms.TryGetComponent(out ItemComponent item));
                    Assert.True(hands.PutInHand(item));
                }
            });

            await server.WaitRunTicks(10);

            await server.WaitAssertion(() =>
            {
                // Still buckled
                Assert.True(buckle.Buckled);

                // With items in all hands
                foreach (var slot in hands.Hands)
                {
                    Assert.NotNull(hands.GetItem(slot));
                }

                var legs = body.GetPartsOfType(BodyPartType.Leg);

                // Break our guy's kneecaps
                foreach (var leg in legs)
                {
                    body.RemovePart(leg);
                }
            });

            await server.WaitRunTicks(10);

            await server.WaitAssertion(() =>
            {
                // Still buckled
                Assert.True(buckle.Buckled);

                // Now with no item in any hand
                foreach (var slot in hands.Hands)
                {
                    Assert.Null(hands.GetItem(slot));
                }
            });
        }
Exemple #38
0
        public async Task EventsTest()
        {
            var options = new ServerContentIntegrationOption {
                ExtraPrototypes = Prototypes
            };
            var server = StartServerDummyTicker(options);

            await server.WaitAssertion(() =>
            {
                var mapManager = IoCManager.Resolve <IMapManager>();

                var mapId = new MapId(0);
                mapManager.CreateNewMapEntity(mapId);

                var entityManager = IoCManager.Resolve <IEntityManager>();
                var human         = entityManager.SpawnEntity("HumanBodyDummy", MapCoordinates.Nullspace);

                Assert.That(human.TryGetComponent(out IBody? body));
                Assert.NotNull(body);

                var centerPart = body !.CenterPart;
                Assert.NotNull(centerPart);

                Assert.That(body.TryGetSlot(centerPart !, out var centerSlot));
                Assert.NotNull(centerSlot);

                var mechanism = centerPart !.Mechanisms.First();
                Assert.NotNull(mechanism);

                mechanism.EnsureBehavior <TestMechanismBehavior>(out var behavior);
                Assert.False(behavior.WasAddedToBody);
                Assert.False(behavior.WasAddedToPart);
                Assert.That(behavior.WasAddedToPartInBody);
                Assert.That(behavior.NoRemoved);

                behavior.ResetAll();

                Assert.That(behavior.NoAdded);
                Assert.That(behavior.NoRemoved);

                centerPart.RemoveMechanism(mechanism);

                Assert.That(behavior.NoAdded);
                Assert.False(behavior.WasRemovedFromBody);
                Assert.False(behavior.WasRemovedFromPart);
                Assert.That(behavior.WasRemovedFromPartInBody);

                behavior.ResetAll();

                centerPart.TryAddMechanism(mechanism, true);

                Assert.False(behavior.WasAddedToBody);
                Assert.False(behavior.WasAddedToPart);
                Assert.That(behavior.WasAddedToPartInBody);
                Assert.That(behavior.NoRemoved());

                behavior.ResetAll();

                body.RemovePart(centerPart);

                Assert.That(behavior.NoAdded);
                Assert.That(behavior.WasRemovedFromBody);
                Assert.False(behavior.WasRemovedFromPart);
                Assert.False(behavior.WasRemovedFromPartInBody);

                behavior.ResetAll();

                centerPart.RemoveMechanism(mechanism);

                Assert.That(behavior.NoAdded);
                Assert.False(behavior.WasRemovedFromBody);
                Assert.That(behavior.WasRemovedFromPart);
                Assert.False(behavior.WasRemovedFromPartInBody);

                behavior.ResetAll();

                centerPart.TryAddMechanism(mechanism, true);

                Assert.False(behavior.WasAddedToBody);
                Assert.That(behavior.WasAddedToPart);
                Assert.False(behavior.WasAddedToPartInBody);
                Assert.That(behavior.NoRemoved);

                behavior.ResetAll();

                body.SetPart(centerSlot !.Id, centerPart);

                Assert.That(behavior.WasAddedToBody);
                Assert.False(behavior.WasAddedToPart);
                Assert.False(behavior.WasAddedToPartInBody);
                Assert.That(behavior.NoRemoved);
            });
        }
 public MapComponentState(MapId mapId, bool lightingEnabled)
 {
     MapId           = mapId;
     LightingEnabled = lightingEnabled;
 }
        public async Task LoadSaveTicksSaveSaltern()
        {
            await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });

            var server     = pairTracker.Pair.Server;
            var mapLoader  = server.ResolveDependency <IMapLoader>();
            var mapManager = server.ResolveDependency <IMapManager>();

            MapId mapId = default;

            // Load saltern.yml as uninitialized map, and save it to ensure it's up to date.
            server.Post(() =>
            {
                mapId = mapManager.CreateMap();
                mapManager.AddUninitializedMap(mapId);
                mapManager.SetMapPaused(mapId, true);
                mapLoader.LoadMap(mapId, "Maps/saltern.yml");
                mapLoader.SaveMap(mapId, "load save ticks save 1.yml");
            });

            // Run 5 ticks.
            server.RunTicks(5);

            await server.WaitPost(() =>
            {
                mapLoader.SaveMap(mapId, "/load save ticks save 2.yml");
            });

            await server.WaitIdleAsync();

            var userData = server.ResolveDependency <IResourceManager>().UserData;

            string one;
            string two;

            using (var stream = userData.Open(new ResourcePath("/load save ticks save 1.yml"), FileMode.Open))
                using (var reader = new StreamReader(stream))
                {
                    one = reader.ReadToEnd();
                }

            using (var stream = userData.Open(new ResourcePath("/load save ticks save 2.yml"), FileMode.Open))
                using (var reader = new StreamReader(stream))
                {
                    two = reader.ReadToEnd();
                }

            Assert.Multiple(() => {
                Assert.That(two, Is.EqualTo(one));
                var failed = TestContext.CurrentContext.Result.Assertions.FirstOrDefault();
                if (failed != null)
                {
                    var oneTmp = Path.GetTempFileName();
                    var twoTmp = Path.GetTempFileName();

                    File.WriteAllText(oneTmp, one);
                    File.WriteAllText(twoTmp, two);

                    TestContext.AddTestAttachment(oneTmp, "First save file");
                    TestContext.AddTestAttachment(twoTmp, "Second save file");
                    TestContext.Error.WriteLine("Complete output:");
                    TestContext.Error.WriteLine(oneTmp);
                    TestContext.Error.WriteLine(twoTmp);
                }
            });
            await pairTracker.CleanReturnAsync();
        }
        public async Task Test()
        {
            var server = StartServerDummyTicker(new ServerContentIntegrationOption
            {
                ExtraPrototypes = Prototypes
            });

            await server.WaitIdleAsync();

            var sEntityManager       = server.ResolveDependency <IEntityManager>();
            var sMapManager          = server.ResolveDependency <IMapManager>();
            var sEntitySystemManager = server.ResolveDependency <IEntitySystemManager>();

            IEntity                        sDestructibleEntity          = null;
            DamageableComponent            sDamageableComponent         = null;
            TestDestructibleListenerSystem sTestThresholdListenerSystem = null;
            DamageableSystem               sDamageableSystem            = null;

            await server.WaitPost(() =>
            {
                var mapId       = new MapId(1);
                var coordinates = new MapCoordinates(0, 0, mapId);
                sMapManager.CreateMap(mapId);

                sDestructibleEntity          = sEntityManager.SpawnEntity(DestructibleDamageTypeEntityId, coordinates);
                sDamageableComponent         = sDestructibleEntity.GetComponent <DamageableComponent>();
                sTestThresholdListenerSystem = sEntitySystemManager.GetEntitySystem <TestDestructibleListenerSystem>();
                sDamageableSystem            = sEntitySystemManager.GetEntitySystem <DamageableSystem>();
            });

            await server.WaitRunTicks(5);

            await server.WaitAssertion(() =>
            {
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
            });

            await server.WaitAssertion(() =>
            {
                var bluntDamageType = IoCManager.Resolve <IPrototypeManager>().Index <DamageTypePrototype>("TestBlunt");
                var slashDamageType = IoCManager.Resolve <IPrototypeManager>().Index <DamageTypePrototype>("TestSlash");

                var bluntDamage = new DamageSpecifier(bluntDamageType, 5);
                var slashDamage = new DamageSpecifier(slashDamageType, 5);

                // Raise blunt damage to 5
                sDamageableSystem.TryChangeDamage(sDestructibleEntity.Uid, bluntDamage, true);

                // No thresholds reached yet, the earliest one is at 10 damage
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);

                // Raise blunt damage to 10
                sDamageableSystem.TryChangeDamage(sDestructibleEntity.Uid, bluntDamage, true);

                // No threshold reached, slash needs to be 10 as well
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);

                // Raise slash damage to 10
                sDamageableSystem.TryChangeDamage(sDestructibleEntity.Uid, slashDamage * 2, true);

                // One threshold reached, blunt 10 + slash 10
                Assert.That(sTestThresholdListenerSystem.ThresholdsReached.Count, Is.EqualTo(1));

                // Threshold blunt 10 + slash 10
                var msg       = sTestThresholdListenerSystem.ThresholdsReached[0];
                var threshold = msg.Threshold;

                // Check that it matches the YAML prototype
                Assert.That(threshold.Behaviors, Is.Empty);
                Assert.NotNull(threshold.Trigger);
                Assert.That(threshold.Triggered, Is.True);
                Assert.IsInstanceOf <AndTrigger>(threshold.Trigger);

                var trigger = (AndTrigger)threshold.Trigger;

                Assert.IsInstanceOf <DamageTypeTrigger>(trigger.Triggers[0]);
                Assert.IsInstanceOf <DamageTypeTrigger>(trigger.Triggers[1]);

                sTestThresholdListenerSystem.ThresholdsReached.Clear();

                // Raise blunt damage to 20
                sDamageableSystem.TryChangeDamage(sDestructibleEntity.Uid, bluntDamage * 2, true);

                // No new thresholds reached
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);

                // Raise slash damage to 20
                sDamageableSystem.TryChangeDamage(sDestructibleEntity.Uid, slashDamage * 2, true);

                // No new thresholds reached
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);

                // Lower blunt damage to 0
                sDamageableSystem.TryChangeDamage(sDestructibleEntity.Uid, bluntDamage * -4, true);

                // No new thresholds reached, healing should not trigger it
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);

                // Raise blunt damage back up to 10
                sDamageableSystem.TryChangeDamage(sDestructibleEntity.Uid, bluntDamage * 2, true);

                // 10 blunt + 10 slash threshold reached, blunt was healed and brought back to its threshold amount and slash stayed the same
                Assert.That(sTestThresholdListenerSystem.ThresholdsReached.Count, Is.EqualTo(1));

                sTestThresholdListenerSystem.ThresholdsReached.Clear();

                // Heal both types of damage to 0
                sDamageableSystem.TryChangeDamage(sDestructibleEntity.Uid, bluntDamage * -2, true);
                sDamageableSystem.TryChangeDamage(sDestructibleEntity.Uid, slashDamage * -4, true);

                // No new thresholds reached, healing should not trigger it
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);

                // Raise blunt damage to 10
                sDamageableSystem.TryChangeDamage(sDestructibleEntity.Uid, bluntDamage * 2, true);

                // No new thresholds reached
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);

                // Raise slash damage to 10
                sDamageableSystem.TryChangeDamage(sDestructibleEntity.Uid, slashDamage * 2, true);

                // Both types of damage were healed and then raised again, the threshold should have been reached as triggers once is default false
                Assert.That(sTestThresholdListenerSystem.ThresholdsReached.Count, Is.EqualTo(1));

                // Threshold blunt 10 + slash 10
                msg       = sTestThresholdListenerSystem.ThresholdsReached[0];
                threshold = msg.Threshold;

                // Check that it matches the YAML prototype
                Assert.That(threshold.Behaviors, Is.Empty);
                Assert.NotNull(threshold.Trigger);
                Assert.That(threshold.Triggered, Is.True);
                Assert.IsInstanceOf <AndTrigger>(threshold.Trigger);

                trigger = (AndTrigger)threshold.Trigger;

                Assert.IsInstanceOf <DamageTypeTrigger>(trigger.Triggers[0]);
                Assert.IsInstanceOf <DamageTypeTrigger>(trigger.Triggers[1]);

                sTestThresholdListenerSystem.ThresholdsReached.Clear();

                // Change triggers once to true
                threshold.TriggersOnce = true;

                // Heal blunt and slash back to 0
                sDamageableSystem.TryChangeDamage(sDestructibleEntity.Uid, bluntDamage * -2, true);
                sDamageableSystem.TryChangeDamage(sDestructibleEntity.Uid, slashDamage * -2, true);

                // No new thresholds reached from healing
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);

                // Raise blunt damage to 10
                sDamageableSystem.TryChangeDamage(sDestructibleEntity.Uid, bluntDamage * 2, true);

                // No new thresholds reached
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);

                // Raise slash damage to 10
                sDamageableSystem.TryChangeDamage(sDestructibleEntity.Uid, slashDamage * 2, true);

                // No new thresholds reached as triggers once is set to true and it already triggered before
                Assert.IsEmpty(sTestThresholdListenerSystem.ThresholdsReached);
            });
        }
Exemple #42
0
 /// <summary>
 /// Creates a new Loot object and returns it or null, if there is nothing to be looted.
 /// </summary>
 /// <typeparam name="T"><see cref="T:WCell.RealmServer.Looting.ObjectLoot" /> or <see cref="T:WCell.RealmServer.Looting.NPCLoot" /></typeparam>
 /// <param name="lootable"></param>
 /// <param name="initialLooter"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public static T CreateLoot <T>(ILootable lootable, Character initialLooter, LootEntryType type, bool heroic,
                                MapId mapid) where T : Loot, new()
 {
     return(default(T));
 }
Exemple #43
0
 public override bool TrySpawnEntityAt(string entityType, Vector2 position, MapId argMap, out IEntity entity)
 {
     // TODO: check collisions here?
     entity = ForceSpawnEntityAt(entityType, position, argMap);
     return(true);
 }
Exemple #44
0
        public override IEntity ForceSpawnEntityAt(string entityType, Vector2 position, MapId argMap)
        {
            if (!_mapManager.TryGetMap(argMap, out var map))
            {
                map = _mapManager.DefaultMap;
            }

            return(ForceSpawnEntityAt(entityType, new GridLocalCoordinates(position, map.FindGridAt(position))));
        }
        private void CreateCircleStack(MapId mapId)
        {
            var entityManager = IoCManager.Resolve <IEntityManager>();

            var ground = entityManager.SpawnEntity(null, new MapCoordinates(0, 0, mapId)).AddComponent <PhysicsComponent>();

            var horizontal        = new EdgeShape(new Vector2(-20, 0), new Vector2(20, 0));
            var horizontalFixture = new Fixture(ground, horizontal)
            {
                CollisionLayer = (int)CollisionGroup.Impassable,
                CollisionMask  = (int)CollisionGroup.Impassable,
                Hard           = true
            };

            var broadphase = EntitySystem.Get <SharedBroadphaseSystem>();

            broadphase.CreateFixture(ground, horizontalFixture);

            var vertical        = new EdgeShape(new Vector2(10, 0), new Vector2(10, 10));
            var verticalFixture = new Fixture(ground, vertical)
            {
                CollisionLayer = (int)CollisionGroup.Impassable,
                CollisionMask  = (int)CollisionGroup.Impassable,
                Hard           = true
            };

            broadphase.CreateFixture(ground, verticalFixture);

            var xs = new[]
            {
                0.0f, -10.0f, -5.0f, 5.0f, 10.0f
            };

            var             columnCount = 1;
            var             rowCount    = 15;
            PhysShapeCircle shape;

            for (var j = 0; j < columnCount; j++)
            {
                for (var i = 0; i < rowCount; i++)
                {
                    var x = 0.0f;

                    var box = entityManager.SpawnEntity(null,
                                                        new MapCoordinates(new Vector2(xs[j] + x, 0.55f + 2.1f * i), mapId)).AddComponent <PhysicsComponent>();

                    box.BodyType = BodyType.Dynamic;
                    shape        = new PhysShapeCircle {
                        Radius = 0.5f
                    };
                    box.FixedRotation = false;
                    // TODO: Need to detect shape and work out if we need to use fixedrotation

                    var fixture = new Fixture(box, shape)
                    {
                        CollisionMask  = (int)CollisionGroup.Impassable,
                        CollisionLayer = (int)CollisionGroup.Impassable,
                        Hard           = true,
                    };

                    broadphase.CreateFixture(box, fixture);
                }
            }
        }
Exemple #46
0
 public EntMapIdChangedMessage(EntityUid entity, MapId oldMapId)
 {
     Entity   = entity;
     OldMapId = oldMapId;
 }
        private void CreateTumbler(MapId mapId)
        {
            var broadphaseSystem = EntitySystem.Get <SharedBroadphaseSystem>();
            var compManager      = IoCManager.Resolve <IComponentManager>();
            var entityManager    = IoCManager.Resolve <IEntityManager>();

            var groundEnt = entityManager.SpawnEntity(null, new MapCoordinates(0f, 0f, mapId));
            var ground    = compManager.AddComponent <PhysicsComponent>(groundEnt);

            var bodyEnt = entityManager.SpawnEntity(null, new MapCoordinates(0f, 10f, mapId));
            var body    = compManager.AddComponent <PhysicsComponent>(bodyEnt);

            body.BodyType        = BodyType.Dynamic;
            body.SleepingAllowed = false;
            body.FixedRotation   = false;

            // TODO: Box2D just derefs, bleh shape structs someday
            var shape1 = new PolygonShape();

            shape1.SetAsBox(0.5f, 10.0f, new Vector2(10.0f, 0.0f), 0.0f);
            broadphaseSystem.CreateFixture(body, shape1, 20.0f);

            var shape2 = new PolygonShape();

            shape2.SetAsBox(0.5f, 10.0f, new Vector2(-10.0f, 0.0f), 0f);
            broadphaseSystem.CreateFixture(body, shape2, 20.0f);

            var shape3 = new PolygonShape();

            shape3.SetAsBox(10.0f, 0.5f, new Vector2(0.0f, 10.0f), 0f);
            broadphaseSystem.CreateFixture(body, shape3, 20.0f);

            var shape4 = new PolygonShape();

            shape4.SetAsBox(10.0f, 0.5f, new Vector2(0.0f, -10.0f), 0f);
            broadphaseSystem.CreateFixture(body, shape4, 20.0f);

            foreach (var fixture in body.Fixtures)
            {
                fixture.CollisionLayer = (int)CollisionGroup.Impassable;
            }

            // TODO: Should Joints be their own entities? Box2D just adds them directly to the world.
            // HMMM
            // At the least it should be its own damn component
            var revolute = new RevoluteJoint(ground, body)
            {
                LocalAnchorA   = new Vector2(0f, 10f),
                LocalAnchorB   = new Vector2(0f, 0f),
                ReferenceAngle = 0f,
                MotorSpeed     = 0.05f * MathF.PI,
                MaxMotorTorque = 100000000f,
                EnableMotor    = true
            };

            body.AddJoint(revolute);

            // Box2D has this as 800 which is jesus christo.
            // Wouldn't recommend higher than 100 in debug and higher than 300 on release unless
            // you really want a profile.
            var count      = 200;
            var mapManager = IoCManager.Resolve <IMapManager>();

            for (var i = 0; i < count; i++)
            {
                Timer.Spawn(i * 20, () =>
                {
                    if (!mapManager.MapExists(mapId))
                    {
                        return;
                    }
                    var ent            = entityManager.SpawnEntity(null, new MapCoordinates(0f, 10f, mapId));
                    var body           = compManager.AddComponent <PhysicsComponent>(ent);
                    body.BodyType      = BodyType.Dynamic;
                    body.FixedRotation = false;
                    var shape          = new PolygonShape();
                    shape.SetAsBox(0.125f, 0.125f);
                    broadphaseSystem.CreateFixture(body, shape, 0.0625f);
                    body.Fixtures[0].CollisionMask  = (int)CollisionGroup.Impassable;
                    body.Fixtures[0].CollisionLayer = (int)CollisionGroup.Impassable;
                });
            }
        }
 public WorldZoneLocation(MapId map, Vector3 pos, ZoneTemplate zone)
     : base(map, pos, 1U)
 {
     this.ZoneTemplate = zone;
 }
Exemple #49
0
        public async Task PuddlePauseTest()
        {
            var server = StartServer();

            await server.WaitIdleAsync();

            var sMapManager            = server.ResolveDependency <IMapManager>();
            var sTileDefinitionManager = server.ResolveDependency <ITileDefinitionManager>();
            var sGameTiming            = server.ResolveDependency <IGameTiming>();
            var entityManager          = server.ResolveDependency <IEntityManager>();

            MapId             sMapId = default;
            IMapGrid          sGrid;
            GridId            sGridId      = default;
            EntityUid         sGridEntity  = default;
            EntityCoordinates sCoordinates = default;

            // Spawn a paused map with one tile to spawn puddles on
            await server.WaitPost(() =>
            {
                sMapId = sMapManager.CreateMap();
                sMapManager.SetMapPaused(sMapId, true);
                sGrid       = sMapManager.CreateGrid(sMapId);
                sGridId     = sGrid.Index;
                sGridEntity = sGrid.GridEntityId;
                entityManager.GetComponent <MetaDataComponent>(sGridEntity).EntityPaused = true; // See https://github.com/space-wizards/RobustToolbox/issues/1444

                var tileDefinition = sTileDefinitionManager["underplating"];
                var tile           = new Tile(tileDefinition.TileId);
                sCoordinates       = sGrid.ToCoordinates();

                sGrid.SetTile(sCoordinates, tile);
            });

            // Check that the map and grid are paused
            await server.WaitAssertion(() =>
            {
                Assert.True(sMapManager.IsGridPaused(sGridId));
                Assert.True(sMapManager.IsMapPaused(sMapId));
            });

            float                evaporateTime = default;
            PuddleComponent      puddle        = null;
            MetaDataComponent    meta          = null;
            EvaporationComponent evaporation;

            var amount = 2;

            var entitySystemManager = server.ResolveDependency <IEntitySystemManager>();
            var spillSystem         = entitySystemManager.GetEntitySystem <SpillableSystem>();

            // Spawn a puddle
            await server.WaitAssertion(() =>
            {
                var solution = new Solution("Water", FixedPoint2.New(amount));
                puddle       = spillSystem.SpillAt(solution, sCoordinates, "PuddleSmear");
                meta         = entityManager.GetComponent <MetaDataComponent>(puddle.Owner);

                // Check that the puddle was created
                Assert.NotNull(puddle);

                evaporation = entityManager.GetComponent <EvaporationComponent>(puddle.Owner);

                meta.EntityPaused = true; // See https://github.com/space-wizards/RobustToolbox/issues/1445

                Assert.True(meta.EntityPaused);

                // Check that the puddle is going to evaporate
                Assert.Positive(evaporation.EvaporateTime);

                // Should have a timer component added to it for evaporation
                Assert.That(evaporation.Accumulator, Is.EqualTo(0f));

                evaporateTime = evaporation.EvaporateTime;
            });

            // Wait enough time for it to evaporate if it was unpaused
            var sTimeToWait = (5 + (int)Math.Ceiling(amount * evaporateTime * sGameTiming.TickRate));
            await server.WaitRunTicks(sTimeToWait);

            // No evaporation due to being paused
            await server.WaitAssertion(() =>
            {
                Assert.True(meta.EntityPaused);

                // Check that the puddle still exists
                Assert.False(meta.EntityDeleted);
            });

            // Unpause the map
            await server.WaitPost(() => { sMapManager.SetMapPaused(sMapId, false); });

            // Check that the map, grid and puddle are unpaused
            await server.WaitAssertion(() =>
            {
                Assert.False(sMapManager.IsMapPaused(sMapId));
                Assert.False(sMapManager.IsGridPaused(sGridId));
                Assert.False(meta.EntityPaused);

                // Check that the puddle still exists
                Assert.False(meta.EntityDeleted);
            });

            // Wait enough time for it to evaporate
            await server.WaitRunTicks(sTimeToWait);

            // Puddle evaporation should have ticked
            await server.WaitAssertion(() =>
            {
                // Check that puddle has been deleted
                Assert.True(puddle.Deleted);
            });
        }
Exemple #50
0
 public NPCSpawnEntry(NPCId entryId, MapId map, Vector3 pos)
 {
     EntryId  = entryId;
     MapId    = map;
     Position = pos;
 }
        public async Task ForceUnbuckleBuckleTest()
        {
            var server = StartServer();

            IEntity         human  = null;
            IEntity         chair  = null;
            BuckleComponent buckle = null;

            await server.WaitAssertion(() =>
            {
                var mapManager = IoCManager.Resolve <IMapManager>();

                var mapId = new MapId(1);
                mapManager.CreateNewMapEntity(mapId);

                var entityManager = IoCManager.Resolve <IEntityManager>();
                var gridId        = new GridId(1);
                var grid          = mapManager.CreateGrid(mapId, gridId);
                var coordinates   = grid.GridEntityId.ToCoordinates();
                var tileManager   = IoCManager.Resolve <ITileDefinitionManager>();
                var tileId        = tileManager["underplating"].TileId;
                var tile          = new Tile(tileId);

                grid.SetTile(coordinates, tile);

                human = entityManager.SpawnEntity("HumanMob_Content", coordinates);
                chair = entityManager.SpawnEntity("ChairWood", coordinates);

                // Component sanity check
                Assert.True(human.TryGetComponent(out buckle));
                Assert.True(chair.HasComponent <StrapComponent>());

                // Buckle
                Assert.True(buckle.TryBuckle(human, chair));
                Assert.NotNull(buckle.BuckledTo);
                Assert.True(buckle.Buckled);

                // Move the buckled entity away
                human.Transform.LocalPosition += (100, 0);
            });

            await WaitUntil(server, () => !buckle.Buckled, maxTicks : 10);

            Assert.False(buckle.Buckled);

            await server.WaitAssertion(() =>
            {
                // Move the now unbuckled entity back onto the chair
                human.Transform.LocalPosition -= (100, 0);

                // Buckle
                Assert.True(buckle.TryBuckle(human, chair));
                Assert.NotNull(buckle.BuckledTo);
                Assert.True(buckle.Buckled);
            });

            await server.WaitRunTicks(60);

            await server.WaitAssertion(() =>
            {
                // Still buckled
                Assert.NotNull(buckle.BuckledTo);
                Assert.True(buckle.Buckled);
            });
        }
Exemple #52
0
 public SortieStart(FleetId fleetId, MapId mapId)
 {
     FleetId = fleetId;
     MapId   = mapId;
 }
Exemple #53
0
        private HashSet <IEntity> ArcRayCast(Vector2 position, Angle angle, float arcWidth, float range, MapId mapId, IEntity ignore)
        {
            var widthRad   = Angle.FromDegrees(arcWidth);
            var increments = 1 + 35 * (int)Math.Ceiling(widthRad / (2 * Math.PI));
            var increment  = widthRad / increments;
            var baseAngle  = angle - widthRad / 2;

            var resSet = new HashSet <IEntity>();

            for (var i = 0; i < increments; i++)
            {
                var castAngle = new Angle(baseAngle + increment * i);
                var res       = EntitySystem.Get <SharedBroadphaseSystem>().IntersectRay(mapId,
                                                                                         new CollisionRay(position, castAngle.ToWorldVec(),
                                                                                                          (int)(CollisionGroup.Impassable | CollisionGroup.MobImpassable)), range, ignore).ToList();

                if (res.Count != 0)
                {
                    resSet.Add(res[0].HitEntity);
                }
            }

            return(resSet);
        }
 public MapComponentState(MapId mapId)
     : base(NetIDs.MAP_MAP)
 {
     MapId = mapId;
 }
Exemple #55
0
        /// <inheritdoc />
        public IEnumerable <IEntity> GetEntitiesInRange(MapId mapId, Box2 box, float range, bool approximate = false)
        {
            var aabb = box.Enlarged(range);

            return(GetEntitiesIntersecting(mapId, aabb, approximate));
        }
Exemple #56
0
 public static List <NPCSpawnPoolTemplate> GetSpawnPoolTemplatesByMap(MapId map)
 {
     return(SpawnPoolsByMap[(int)map]);
 }
Exemple #57
0
 public MapChunkLocation(MapId mapId, Vector2i chunkIndices)
 {
     MapId        = mapId;
     ChunkIndices = chunkIndices;
 }
Exemple #58
0
 /// <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(MapId map, Vector3 pos, Unit owner)
 {
     return(Spawn(World.GetNonInstancedMap(map), pos, owner));
 }
Exemple #59
0
 /// <summary>
 /// Returns the GOTemplate of this entry that is closest to the given location
 /// </summary>
 public GOSpawnEntry GetClosestTemplate(MapId rgn, Vector3 pos)
 {
     return(SpawnEntries.GetClosestEntry(new WorldLocationStruct(rgn, pos, 1U)));
 }
 private BroadPhase this[MapId mapId] => _treesPerMap.GetOrAdd(mapId, _ => new BroadPhase());