public void AddEventsToQueue <T>(StablePriorityQueue <GameEventPriority, EventQueueElement <T> > queue, Priority maxPriority, ref Priority nextPriority, PriorityList <T> effectList, Character targetChar) where T : GameEvent { foreach (Priority priority in effectList.GetPriorities()) { //if an item has the same priority variable as the nextPriority, enqueue it //if an item has a higher priority variable than nextPriority, ignore it //if an item has a lower priority variable than nextPriority, check against maxPriority for (int ii = 0; ii < effectList.GetCountAtPriority(priority); ii++) { if (priority == nextPriority) { GameEventPriority gameEventPriority = new GameEventPriority(priority, GameEventPriority.USER_PORT_PRIORITY, GetEventCause(), GetID(), ii); EventQueueElement <T> eventQueueElement = new EventQueueElement <T>(this, null, effectList.Get(priority, ii), targetChar); queue.Enqueue(gameEventPriority, eventQueueElement); } else if (priority < nextPriority || nextPriority == Priority.Invalid) { //if the item has a lower priority variable than maxPriority, ignore it //if the item has a higher priority variable than maxPriority, clear the queue and add the new item if (priority > maxPriority || maxPriority == Priority.Invalid) { nextPriority = priority; queue.Clear(); GameEventPriority gameEventPriority = new GameEventPriority(priority, GameEventPriority.USER_PORT_PRIORITY, GetEventCause(), GetID(), ii); EventQueueElement <T> eventQueueElement = new EventQueueElement <T>(this, null, effectList.Get(priority, ii), targetChar); queue.Enqueue(gameEventPriority, eventQueueElement); } } } } }
public override void Apply(ZoneGenContext zoneContext, IGenContext context, StablePriorityQueue <Priority, IGenStep> queue) { ItemSpawnStep <BaseMapGenContext> spawnStep = new ItemSpawnStep <BaseMapGenContext>(); spawnStep.Spawns = Spawns.GetSpawnList(zoneContext.CurrentID); queue.Enqueue(Priority, spawnStep); }
public void TestIntQueueUpdatePriority() { StablePriorityQueue <Node> stableQueue = new StablePriorityQueue <Node>(100); Node n1 = new Node(); Node n2 = new Node(); Node n3 = new Node(); Node n4 = new Node(); stableQueue.Enqueue(n1, 1); stableQueue.Enqueue(n2, 1); stableQueue.Enqueue(n3, 1); stableQueue.Enqueue(n4, 1); Node node = stableQueue.First; Assert.IsTrue(node == n1); stableQueue.UpdatePriority(n1, 1); node = stableQueue.First; Assert.IsTrue(node == n1); stableQueue.UpdatePriority(n1, 2); node = stableQueue.First; Assert.IsTrue(node == n2); stableQueue.UpdatePriority(n1, 1); node = stableQueue.First; Assert.IsTrue(node == n1); stableQueue.Dequeue(); node = stableQueue.First; Assert.IsTrue(node == n2); stableQueue.Dequeue(); node = stableQueue.First; Assert.IsTrue(node == n3); }
public override void Apply(ZoneGenContext zoneContext, IGenContext context, StablePriorityQueue <Priority, IGenStep> queue) { //find the first postproc that is a GridRoom postproc and add this to its special rooms //NOTE: if a room-based generator is not found as the generation step, it will just skip this floor but treat it as though it was placed. if (SpreadPlan.CheckIfDistributed(zoneContext, context)) { //TODO: allow arbitrary components to be added RoomGenOption genDuo = Spawns.Pick(context.Rand); SetGridSpecialRoomStep <MapGenContext> specialStep = new SetGridSpecialRoomStep <MapGenContext>(); SetSpecialRoomStep <ListMapGenContext> listSpecialStep = new SetSpecialRoomStep <ListMapGenContext>(); specialStep.Filters = genDuo.Filters; if (specialStep.CanApply(context)) { specialStep.Rooms = new PresetPicker <RoomGen <MapGenContext> >(genDuo.GridOption); specialStep.RoomComponents.Set(new ImmutableRoom()); queue.Enqueue(PriorityGrid, specialStep); } else if (listSpecialStep.CanApply(context)) { listSpecialStep.Rooms = new PresetPicker <RoomGen <ListMapGenContext> >(genDuo.ListOption); listSpecialStep.RoomComponents.Set(new ImmutableRoom()); PresetPicker <PermissiveRoomGen <ListMapGenContext> > picker = new PresetPicker <PermissiveRoomGen <ListMapGenContext> >(); picker.ToSpawn = new RoomGenAngledHall <ListMapGenContext>(0); listSpecialStep.Halls = picker; queue.Enqueue(PriorityList, listSpecialStep); } } }
private void preCalculateCoverage(StablePriorityQueue <int, Loc> tilesToHit, int delay) { Loc leftDiff, rightDiff; if (Dir.IsDiagonal()) { leftDiff = DirExt.AddAngles(Dir, Dir8.UpRight).GetLoc(); rightDiff = DirExt.AddAngles(Dir, Dir8.UpLeft).GetLoc(); } else { leftDiff = DirExt.AddAngles(Dir, Dir8.Right).GetLoc(); rightDiff = DirExt.AddAngles(Dir, Dir8.Left).GetLoc(); } Loc candTile = StartPoint; for (int ii = 0; ii < MaxDistance; ii++) { candTile += Dir.GetLoc(); tilesToHit.Enqueue(calculateTimeToHit(StartPoint, candTile) + delay, candTile); if (Wide) { tilesToHit.Enqueue(calculateTimeToHit(StartPoint + leftDiff, candTile + leftDiff) + delay, candTile + leftDiff); tilesToHit.Enqueue(calculateTimeToHit(StartPoint + rightDiff, candTile + rightDiff) + delay, candTile + rightDiff); } } }
/// <summary> /// Correct vertices reuse is required, which is ensured by using the ExportPolygon builder. /// </summary> /// <param name="mesh">Any polygon, preferable a ExportPolygon</param> private void Import(IPolygon mesh) { mesh = ExportPolygon.Convert(mesh); _pq = new StablePriorityQueue <V>(mesh.VertexCount); _triangles = new List <T>(); var verts = new List <V>(); foreach (Vec3 position in mesh.Vertices) { verts.Add(new V(position, this)); } int index = 0; var t = mesh.Triangles.ToArray(); while (index < t.Length) { _triangles.Add(new T(verts[t[index++]], verts[t[index++]], verts[t[index++]], this)); } foreach (V v in verts) { v.ComputeEdgeCostAtVertex(); } }
public void AddEventsToQueue <T>(StablePriorityQueue <GameEventPriority, Tuple <GameEventOwner, Character, T> > queue, Priority maxPriority, ref Priority nextPriority, PriorityList <T> effectList) where T : GameEvent { foreach (Priority priority in effectList.GetPriorities()) { //if an item has the same priority variable as the nextPriority, enqueue it //if an item has a higher priority variable than nextPriority, ignore it //if an item has a lower priority variable than nextPriority, check against maxPriority for (int ii = 0; ii < effectList.GetCountAtPriority(priority); ii++) { if (priority == nextPriority) { queue.Enqueue(new GameEventPriority(priority, PortPriority, Passive.GetEventCause(), Passive.GetID(), ii), new Tuple <GameEventOwner, Character, T>(Passive, EventChar, effectList.Get(priority, ii))); } else if (priority < nextPriority || nextPriority == Priority.Invalid) { //if the item has a lower priority variable than maxPriority, ignore it //if the item has an equal or higher priority variable than maxPriority, clear the queue and add the new item if (priority > maxPriority || maxPriority == Priority.Invalid) { nextPriority = priority; queue.Clear(); queue.Enqueue(new GameEventPriority(priority, PortPriority, Passive.GetEventCause(), Passive.GetID(), ii), new Tuple <GameEventOwner, Character, T>(Passive, EventChar, effectList.Get(priority, ii))); } } } } }
private void addToQueue(ZoneGenContext zoneContext, IGenContext context, StablePriorityQueue <Priority, IGenStep> queue) { int id = zoneContext.CurrentID; IMonsterHouseBaseStep monsterHouseStep = HouseStepSpawns.Pick(context.Rand).CreateNew(); SpawnList <MapItem> itemListSlice = Items.GetSpawnList(id); for (int jj = 0; jj < itemListSlice.Count; jj++) { monsterHouseStep.Items.Add(new MapItem(itemListSlice.GetSpawn(jj)), itemListSlice.GetSpawnRate(jj)); } SpawnList <ItemTheme> itemThemeListSlice = ItemThemes.GetSpawnList(id); for (int jj = 0; jj < itemThemeListSlice.Count; jj++) { monsterHouseStep.ItemThemes.Add(itemThemeListSlice.GetSpawn(jj).Copy(), itemThemeListSlice.GetSpawnRate(jj)); } SpawnList <MobSpawn> mobListSlice = Mobs.GetSpawnList(id); for (int jj = 0; jj < mobListSlice.Count; jj++) { MobSpawn newSpawn = mobListSlice.GetSpawn(jj).Copy(); monsterHouseStep.Mobs.Add(newSpawn, mobListSlice.GetSpawnRate(jj)); } SpawnList <MobTheme> mobThemeListSlice = MobThemes.GetSpawnList(id); for (int jj = 0; jj < mobThemeListSlice.Count; jj++) { monsterHouseStep.MobThemes.Add(mobThemeListSlice.GetSpawn(jj).Copy(), mobThemeListSlice.GetSpawnRate(jj)); } queue.Enqueue(Priority, monsterHouseStep); }
public override void Apply(ZoneGenContext zoneContext, IGenContext context, StablePriorityQueue <Priority, IGenStep> queue) { if (SpreadPlan.CheckIfDistributed(zoneContext, context)) { IGenPriority genStep = Spawns.Pick(context.Rand); queue.Enqueue(genStep.Priority, genStep.GetItem()); } }
public MessageQueue(MessageModule module) { excuteMap = Framework.GlobalAllocate <Dictionary <StablePriorityQueueNode, Message> >(); int count = Framework.GetGlbalPoolCount <StablePriorityQueue <StablePriorityQueueNode> >(); _priorityQueue = count == 0 ? new StablePriorityQueue <StablePriorityQueueNode>() : Framework.GlobalAllocate <StablePriorityQueue <StablePriorityQueueNode> >(); _updatelist = Framework.GlobalAllocate <List <StablePriorityQueueNode> >(); this.module = module; }
public Hitbox(Character user, Loc mapLoc, FiniteEmitter tileEmitter, int delay) { User = user; MapLoc = mapLoc; TileEmitter = (FiniteEmitter)tileEmitter.Clone(); TilesToEmit = new StablePriorityQueue <int, Loc>(); TilesToHit = new StablePriorityQueue <int, Loc>(); LagBehindTime = delay; }
private void preCalculateCoverage(StablePriorityQueue <int, Loc> tilesToHit, int delay) { Loc topLeft = Origin - new Loc(MaxRadius); bool[][] connectionGrid = new bool[MaxRadius * 2 + 1][]; for (int xx = 0; xx < connectionGrid.Length; xx++) { connectionGrid[xx] = new bool[MaxRadius * 2 + 1]; } connectionGrid[Origin.X - topLeft.X][Origin.Y - topLeft.Y] = true; tilesToHit.Enqueue(calculateTimeToHit(Origin) + delay, Origin); Loc backup = Origin; if (MaxRadius > 0 && ZoneManager.Instance.CurrentMap.TileBlocked(Origin, true)) { backup += Dir.Reverse().GetLoc(); } Grid.FloodFill(new Rect(Origin - new Loc(MaxRadius), new Loc(MaxRadius * 2 + 1)), (Loc testLoc) => { if (connectionGrid[testLoc.X - topLeft.X][testLoc.Y - topLeft.Y]) { return(true); } if (!Collision.InBounds(ZoneManager.Instance.CurrentMap.Width, ZoneManager.Instance.CurrentMap.Height, testLoc)) { return(true); } if (!IsInSquareHitbox(testLoc, Origin, MaxRadius, HitArea, Dir)) { return(true); } if (ZoneManager.Instance.CurrentMap.TileBlocked(testLoc, true)) { return(true); } return(false); }, (Loc testLoc) => { return(false); }, (Loc fillLoc) => { if (fillLoc != Origin) { connectionGrid[fillLoc.X - topLeft.X][fillLoc.Y - topLeft.Y] = true; tilesToHit.Enqueue(calculateTimeToHit(fillLoc) + delay, fillLoc); } }, backup); }
public MessageQueue(MessageModule module) { nodePool = new StablePriorityQueueNodePool(); excuteMap = new Dictionary <StablePriorityQueueNode, Message>(); _pool = new MessagePool(); _queue = new StablePriorityQueue <StablePriorityQueueNode>(); _list = new List <StablePriorityQueueNode>(); _tmp = new Queue <Message>(); this.module = module; }
public override void Apply(ZoneGenContext zoneContext, IGenContext context, StablePriorityQueue <Priority, IGenStep> queue) { LuaFunction luafun = LuaEngine.Instance.LuaState.GetFunction("ZONE_GEN_SCRIPT." + Script); if (luafun != null) { LuaTable args = LuaEngine.Instance.RunString("return " + ArgTable).First() as LuaTable; luafun.Call(new object[] { zoneContext, context, queue, seed, args }); } }
public override void Apply(ZoneGenContext zoneContext, IGenContext context, StablePriorityQueue <Priority, IGenStep> queue) { TileSpawnStep <BaseMapGenContext> spawnStep = new TileSpawnStep <BaseMapGenContext>(); SpawnList <EffectTile> spawner = Spawns.GetSpawnList(zoneContext.CurrentID); for (int ii = 0; ii < spawner.Count; ii++) { spawnStep.Spawns.Add(spawner.GetSpawn(ii), spawner.GetSpawnRate(ii)); } queue.Enqueue(Priority, spawnStep); }
/// <summary> /// Initializes a new instance of the <see cref="Scheduler"/> class. /// </summary> /// <param name="logger">The logger to use.</param> public Scheduler(ILogger logger) { logger.ThrowIfNull(nameof(logger)); this.Logger = logger.ForContext <Scheduler>(); this.eventsPerRequestorLock = new object(); this.eventsAvailableLock = new object(); this.startTime = this.CurrentTime; this.priorityQueue = new StablePriorityQueue <BaseEvent>(this.maxQueueNodes); this.cancelledEvents = new HashSet <string>(); this.eventsIndexedByRequestor = new Dictionary <uint, ISet <BaseEvent> >(); }
public override void Apply(ZoneGenContext zoneContext, IGenContext context, StablePriorityQueue <Priority, IGenStep> queue) { GameProgress progress = DataManager.Instance.Save; if (progress != null && progress.Rescue != null && progress.Rescue.Rescuing) { if (progress.Rescue.SOS.Goal.ID == zoneContext.CurrentZone && progress.Rescue.SOS.Goal.StructID.Segment == zoneContext.CurrentSegment && progress.Rescue.SOS.Goal.StructID.ID == zoneContext.CurrentID) { queue.Enqueue(Priority, new RescueSpawner <BaseMapGenContext>()); } } }
public override void Apply(ZoneGenContext zoneContext, IGenContext context, StablePriorityQueue <Priority, IGenStep> queue) { int id = zoneContext.CurrentID; foreach (int floorId in SpreadPlan.DropPoints) { if (floorId != zoneContext.CurrentID) { continue; } foreach (IGenPriority vaultStep in VaultSteps) { queue.Enqueue(vaultStep.Priority, vaultStep.GetItem()); } { SpawnList <MapItem> itemListSlice = Items.GetSpawnList(id); PickerSpawner <ListMapGenContext, MapItem> constructedSpawns = new PickerSpawner <ListMapGenContext, MapItem>(new LoopedRand <MapItem>(itemListSlice, ItemAmount[id])); List <IStepSpawner <ListMapGenContext, MapItem> > steps = new List <IStepSpawner <ListMapGenContext, MapItem> >(); steps.Add(constructedSpawns); if (ItemSpawners.ContainsItem(id)) { IStepSpawner <ListMapGenContext, MapItem> treasures = ItemSpawners[id].Copy(); steps.Add(treasures); } PresetMultiRand <IStepSpawner <ListMapGenContext, MapItem> > groupRand = new PresetMultiRand <IStepSpawner <ListMapGenContext, MapItem> >(steps.ToArray()); RandomRoomSpawnStep <ListMapGenContext, MapItem> detourItems = ItemPlacements[id].Copy(); detourItems.Spawn = new MultiStepSpawner <ListMapGenContext, MapItem>(groupRand); queue.Enqueue(ItemPriority, detourItems); } SpawnList <MobSpawn> mobListSlice = Mobs.GetSpawnList(id); if (mobListSlice.CanPick) { //secret enemies SpecificTeamSpawner specificTeam = new SpecificTeamSpawner(); MobSpawn newSpawn = mobListSlice.Pick(context.Rand).Copy(); specificTeam.Spawns.Add(newSpawn); //use bruteforce clone for this PlaceRandomMobsStep <ListMapGenContext> secretMobPlacement = MobPlacements[id].Copy(); secretMobPlacement.Spawn = new LoopedTeamSpawner <ListMapGenContext>(specificTeam, MobAmount[id]); queue.Enqueue(MobPriority, secretMobPlacement); } } }
private void preCalculateCoverage(StablePriorityQueue <int, Loc> tilesToHit, int delay) { for (int ii = -MaxRadius; ii <= MaxRadius; ii++) { for (int jj = -MaxRadius; jj <= MaxRadius; jj++) { Loc candTile = new Loc(ii, jj) + Origin; if (IsInSquareHitbox(candTile, Origin, MaxRadius, HitArea, Dir) && Collision.InBounds(ZoneManager.Instance.CurrentMap.Width, ZoneManager.Instance.CurrentMap.Height, candTile)) { tilesToHit.Enqueue(calculateTimeToHit(candTile) + delay, candTile); } } } }
public IEnumerator <YieldInstruction> ProcessHitQueue(List <Hitbox> hitboxes, HitboxEffect burstEffect, HitboxEffect tileEffect) { //set the NextStep to update the hit queue; aka call this method again on next (available) update //stop doing it only if, for all hitboxes, everything has been hit and it's "done" //assume none of the hitboxes are blocking while (true) { StablePriorityQueue <int, HitboxHit> hitTargets = new StablePriorityQueue <int, HitboxHit>(); foreach (Hitbox hitbox in hitboxes) { hitbox.UpdateHitQueue(hitTargets); } //hit each target while (hitTargets.Count > 0) { HitboxHit tile = hitTargets.Dequeue(); if (tile.Explode) { yield return(CoroutineManager.Instance.StartCoroutine(burstEffect(tile.Loc))); } else { yield return(CoroutineManager.Instance.StartCoroutine(tileEffect(tile.Loc))); } } bool allDone = true; foreach (Hitbox hitbox in hitboxes) { if (!hitbox.ProcessesDone()) { allDone = false; break; } } if (allDone) { yield break; } yield return(new WaitForFrames(1)); } }
public override void Apply(ZoneGenContext zoneContext, IGenContext context, StablePriorityQueue <Priority, IGenStep> queue) { bool added = false; foreach (int floorId in SpreadPlan.DropPoints) { if (floorId != zoneContext.CurrentID) { continue; } addToQueue(zoneContext, context, queue); added = true; } if (added) { return; } GameProgress progress = DataManager.Instance.Save; if (progress != null && progress.ActiveTeam != null) { int totalMod = 0; foreach (Character chara in progress.ActiveTeam.Players) { foreach (FlagType state in ModStates) { CharState foundState; if (chara.CharStates.TryGet(state.FullType, out foundState)) { totalMod += ((ModGenState)foundState).Mod; } } } if (context.Rand.Next(100) < totalMod) { addToQueue(zoneContext, context, queue); return; } } }
public override void Apply(ZoneGenContext zoneContext, IGenContext context, StablePriorityQueue <Priority, IGenStep> queue) { MobSpawnStep <BaseMapGenContext> spawnStep = new MobSpawnStep <BaseMapGenContext>(); PoolTeamSpawner spawner = new PoolTeamSpawner(); spawner.Spawns = Spawns.GetSpawnList(zoneContext.CurrentID); spawner.TeamSizes = TeamSizes.GetSpawnList(zoneContext.CurrentID); spawnStep.Spawns.Add(spawner, spawner.Spawns.SpawnTotal); SpawnList <SpecificTeamSpawner> specificSpawner = SpecificSpawns.GetSpawnList(zoneContext.CurrentID); for (int ii = 0; ii < specificSpawner.Count; ii++) { spawnStep.Spawns.Add(specificSpawner.GetSpawn(ii), specificSpawner.GetSpawnRate(ii)); } queue.Enqueue(Priority, spawnStep); }
public static List <PointD> ExtractOrderListFromOPTICS(List <PointD> list_of_points, double epsilon, int min_points) { List <PointD> OrderedList = new List <PointD>(); Dictionary <PointD, Tuple <bool, double?> > DictionnaryOfOPTICS = new Dictionary <PointD, Tuple <bool, double?> >(); foreach (PointD point in list_of_points.Distinct().ToList()) { DictionnaryOfOPTICS.Add(point, new Tuple <bool, double?>(false, null)); } foreach (PointD point in DictionnaryOfOPTICS.Keys.ToList()) { if (DictionnaryOfOPTICS[point].Item1 == false) { DictionnaryOfOPTICS[point] = new Tuple <bool, double?>(true, DictionnaryOfOPTICS[point].Item2); OrderedList.Add(point); if (Core_distance(DictionnaryOfOPTICS, point, epsilon, min_points) != null) { List <PointD> list_of_neighbors = Get_neighbors_points_for_Optics(DictionnaryOfOPTICS.Keys.ToList(), point, epsilon); // Get Neighbors StablePriorityQueue <PointDQueue> seeds = new StablePriorityQueue <PointDQueue>(1440); Update_OPTICS(ref DictionnaryOfOPTICS, list_of_neighbors, point, ref seeds, epsilon, min_points); while (seeds.Count > 0) { PointDQueue point_temp = seeds.Dequeue(); PointD neighbor_point = new PointD(point_temp.x, point_temp.y); DictionnaryOfOPTICS[neighbor_point] = new Tuple <bool, double?>(true, DictionnaryOfOPTICS[neighbor_point].Item2); OrderedList.Add(neighbor_point); if (Core_distance(DictionnaryOfOPTICS, point, epsilon, min_points) != null) { Update_OPTICS(ref DictionnaryOfOPTICS, list_of_neighbors, neighbor_point, ref seeds, epsilon, min_points); } } } } } return(OrderedList); }
private void preCalculateCoverage(StablePriorityQueue <int, Loc> tilesToHit, int delay) { HashSet <Loc> hitTiles = new HashSet <Loc>(); HashSet <Loc> returnTiles = new HashSet <Loc>(); Loc candTile = StartPoint; for (int ii = 0; ii < MaxDistance; ii++) { candTile = candTile + Dir.GetLoc(); tilesToHit.Enqueue(calculateTimeToHit(candTile, false) + delay, candTile); } if (Boomerang) { for (int ii = 0; ii < MaxDistance - 1; ii++) { candTile = candTile - Dir.GetLoc(); tilesToHit.Enqueue(calculateTimeToHit(candTile, true) + delay, candTile); } } }
public IEnumerator <YieldInstruction> BeforeExplosion(BattleContext context) { EventEnqueueFunction <BattleEvent> function = (StablePriorityQueue <GameEventPriority, Tuple <GameEventOwner, Character, BattleEvent> > queue, Priority maxPriority, ref Priority nextPriority) => { DataManager.Instance.UniversalEvent.AddEventsToQueue(queue, maxPriority, ref nextPriority, DataManager.Instance.UniversalEvent.BeforeExplosions); context.Data.AddEventsToQueue <BattleEvent>(queue, maxPriority, ref nextPriority, context.Data.BeforeExplosions); StablePriorityQueue <int, Character> charQueue = new StablePriorityQueue <int, Character>(); foreach (Character character in ZoneManager.Instance.CurrentMap.IterateCharacters()) { if (!character.Dead) { charQueue.Enqueue(-character.Speed, character); } } int portPriority = 0; while (charQueue.Count > 0) { Character character = charQueue.Dequeue(); foreach (PassiveContext effectContext in character.IterateProximityPassives(context.User, context.ExplosionTile, portPriority)) { effectContext.AddEventsToQueue(queue, maxPriority, ref nextPriority, ((ProximityData)effectContext.EventData).BeforeExplosions); } portPriority++; } }; foreach (Tuple <GameEventOwner, Character, BattleEvent> effect in IterateEvents <BattleEvent>(function)) { yield return(CoroutineManager.Instance.StartCoroutine(effect.Item3.Apply(effect.Item1, effect.Item2, context))); if (context.CancelState.Cancel) { yield break; } } }
public override void Apply(ZoneGenContext zoneContext, IGenContext context, StablePriorityQueue <Priority, IGenStep> queue) { int id = zoneContext.CurrentID; foreach (int floorId in SpreadPlan.DropPoints) { if (floorId != zoneContext.CurrentID) { continue; } { SpawnList <AddBossRoomStep <ListMapGenContext> > bossListSlice = BossSteps.GetSpawnList(id); if (!bossListSlice.CanPick) { return; } AddBossRoomStep <ListMapGenContext> bossStep = bossListSlice.Pick(context.Rand).Copy(); queue.Enqueue(BossRoomPriority, bossStep); } foreach (IGenPriority vaultStep in VaultSteps) { queue.Enqueue(vaultStep.Priority, vaultStep.GetItem()); } { SpawnList <MapItem> itemListSlice = Items.GetSpawnList(id); PickerSpawner <ListMapGenContext, MapItem> constructedSpawns = new PickerSpawner <ListMapGenContext, MapItem>(new LoopedRand <MapItem>(itemListSlice, ItemAmount[id])); IStepSpawner <ListMapGenContext, MapItem> treasures = ItemSpawners[id].Copy(); PresetMultiRand <IStepSpawner <ListMapGenContext, MapItem> > groupRand = new PresetMultiRand <IStepSpawner <ListMapGenContext, MapItem> >(constructedSpawns, treasures); RandomRoomSpawnStep <ListMapGenContext, MapItem> detourItems = ItemPlacements[id].Copy(); detourItems.Spawn = new MultiStepSpawner <ListMapGenContext, MapItem>(groupRand); queue.Enqueue(RewardPriority, detourItems); } } }
public override void Apply(ZoneGenContext zoneContext, IGenContext context, StablePriorityQueue <Priority, IGenStep> queue) { SpawnDict <string, SpawnList <InvItem> > spawns = new SpawnDict <string, SpawnList <InvItem> >(); //contains all LISTS that intersect the current ID foreach (string key in Spawns.Keys) { //get all items within the spawnrangelist that intersect the current ID SpawnList <InvItem> slicedList = Spawns[key].Spawns.GetSpawnList(zoneContext.CurrentID); // add the spawnlist under the current key, with the key having the spawnrate for this id if (slicedList.CanPick && Spawns[key].SpawnRates.ContainsItem(zoneContext.CurrentID) && Spawns[key].SpawnRates[zoneContext.CurrentID] > 0) { spawns.Add(key, slicedList, Spawns[key].SpawnRates[zoneContext.CurrentID]); } } ItemSpawnStep <BaseMapGenContext> spawnStep = new ItemSpawnStep <BaseMapGenContext>(); spawnStep.Spawns = spawns; queue.Enqueue(Priority, spawnStep); }
public void UpdateHitQueue(StablePriorityQueue <int, HitboxHit> hitTargets) { //when updating, the base will update the time elapsed //when this method is reached, hits will be delegated accordingly while (TilesToHit.Count > 0 && (Finished || time >= TilesToHit.FrontPriority())) { int priority = TilesToHit.FrontPriority(); Loc tile = TilesToHit.Dequeue(); //filter out the hitboxes that are not wanted TargetHitType type = IsValidTileTarget(tile); if (type == TargetHitType.Burst) { hitTargets.Enqueue(priority, new HitboxHit(tile, true)); } else if (type == TargetHitType.Tile) { hitTargets.Enqueue(priority, new HitboxHit(tile, false)); } } }
public IGenContext GenMap(ZoneGenContext zoneContext) { //it will first create the instance of the context, //and set up a local List<GenPriority<IGenStep>> variable //the zonecontext members include runtime zonepostprocs //that will appreciate a IGenContext + List<GenPriority<IGenStep>> being passed into them //then, gensteps will continue on as per usual T map = (T)Activator.CreateInstance(typeof(T)); map.InitSeed(zoneContext.Seed); GenContextDebug.DebugInit(map); //postprocessing steps: StablePriorityQueue <Priority, IGenStep> queue = new StablePriorityQueue <Priority, IGenStep>(); foreach (Priority priority in GenSteps.GetPriorities()) { foreach (IGenStep genStep in GenSteps.GetItems(priority)) { queue.Enqueue(priority, genStep); } } foreach (ZonePostProc zoneStep in zoneContext.ZoneSteps) { zoneStep.Apply(zoneContext, map, queue); } ApplyGenSteps(map, queue); map.FinishGen(); return(map); }
public override void Apply(ZoneGenContext zoneContext, IGenContext context, StablePriorityQueue <Priority, IGenStep> queue) { queue.Enqueue(Priority, new MapNameIDStep <BaseMapGenContext>(zoneContext.CurrentID, LocalText.FormatLocalText(Name, (zoneContext.CurrentID + 1).ToString()))); }