public override IEnumerator <YieldInstruction> Apply(GameEventOwner owner, Character ownerChar, Character character, MapStatus status, bool msg) { if (character != null) { yield break; } MapCheckState destChecks = ((MapStatus)owner).StatusStates.GetWithDefault <MapCheckState>(); MapCheckState srcChecks = status.StatusStates.GetWithDefault <MapCheckState>(); foreach (SingleCharEvent effect in srcChecks.CheckEvents) { destChecks.CheckEvents.Add(effect); } }
protected void AddIntrudeStep(T map, CheckIntrudeBoundsEvent check) { //TODO: remove this magic number int intrudeStatus = 33; MapStatus status; if (map.Map.Status.TryGetValue(intrudeStatus, out status)) { MapCheckState destChecks = status.StatusStates.GetWithDefault <MapCheckState>(); destChecks.CheckEvents.Add(check); } else { status = new MapStatus(intrudeStatus); status.LoadFromData(); MapCheckState checkState = status.StatusStates.GetWithDefault <MapCheckState>(); checkState.CheckEvents.Add(check); map.Map.Status.Add(intrudeStatus, status); } }
public override void Apply(T map) { //TODO: move magic numbers out of here EffectTile spawnedChest = new EffectTile(44, true); List <Loc> freeTiles = ((IPlaceableGenContext <EffectTile>)map).GetAllFreeTiles(); int randIndex = map.Rand.Next(freeTiles.Count); Loc chosenLoc = freeTiles[randIndex]; ((IPlaceableGenContext <EffectTile>)map).PlaceItem(chosenLoc, spawnedChest); //also put a monster house here RandRange amount = new RandRange(7, 13); int mobCount = amount.Pick(map.Rand); List <MobSpawn> chosenMobs = new List <MobSpawn>(); if (map.TeamSpawns.Count > 0) { for (int ii = 0; ii < mobCount; ii++) { List <MobSpawn> exampleList = map.TeamSpawns.Pick(map.Rand).ChooseSpawns(map.Rand); if (exampleList.Count > 0) { chosenMobs.AddRange(exampleList); } if (chosenMobs.Count >= mobCount) { break; } } } if (chosenMobs.Count > 0) { Rect bounds = new Rect(chosenLoc - new Loc(4), new Loc(9)); bounds = Rect.Intersect(bounds, new Rect(0, 0, map.Width, map.Height)); for (int xx = bounds.X; xx < bounds.End.X; xx++) { for (int yy = bounds.Y; yy < bounds.End.Y; yy++) { if ((xx == bounds.X || xx == bounds.End.X - 1) && (yy == bounds.Y || yy == bounds.End.Y - 1)) { continue; } if (map.GetTile(new Loc(xx, yy)).TileEquivalent(map.WallTerrain)) { map.SetTile(new Loc(xx, yy), map.RoomTerrain.Copy()); } } } //cover the room in a check that holds all of the monsters, and covers the room's bounds CheckIntrudeBoundsEvent check = new CheckIntrudeBoundsEvent(); check.Bounds = bounds; { MonsterHouseMapEvent house = new MonsterHouseMapEvent(); house.Bounds = check.Bounds; foreach (MobSpawn mob in chosenMobs) { house.Mobs.Add(mob.Copy()); } check.Effects.Add(house); } int intrudeStatus = 33; MapStatus status = new MapStatus(intrudeStatus); status.LoadFromData(); MapCheckState checkState = status.StatusStates.GetWithDefault <MapCheckState>(); checkState.CheckEvents.Add(check); map.Map.Status.Add(intrudeStatus, status); } }