public void UnloadMap(SegLoc id) { if (maps.ContainsKey(id)) { maps.Remove(id); } }
/// <summary> /// Loads a new map of the specified name into the current zone (temporarily) for dev usage. /// </summary> /// <param name="mapname"></param> public void DevLoadMap(string mapname) { exitMap(); CurrentMap = DataManager.Instance.GetMap(mapname); CurrentMapID = new SegLoc(0, 0); }
/// <summary> /// Loads a new ground map of the specified name into the current zone (temporarily) for dev usage. /// </summary> /// <param name="mapname"></param> public void DevLoadGround(string mapname) { exitMap(); CurrentGround = DataManager.Instance.GetGround(mapname); CurrentMapID = new SegLoc(-1, 0); }
/// <summary> /// Creates a new ground map of the specified name into the current zone (temporarily) for dev usage. /// </summary> public void DevNewGround() { exitMap(); CurrentGround = new GroundMap(); CurrentGround.CreateNew(16, 16, Content.GraphicsManager.DungeonTexSize); CurrentMapID = new SegLoc(-1, 0); }
/// <summary> /// Creates a new map of the specified name into the current zone (temporarily) for dev usage. /// </summary> public void DevNewMap() { exitMap(); CurrentMap = new Map(); CurrentMap.CreateNew(10, 10); CurrentMapID = new SegLoc(0, 0); }
/// <summary> /// Creates a new map of the specified name into the current zone (temporarily) for dev usage. /// </summary> public void DevNewMap() { exitMap(); CurrentMap = new Map(); CurrentMap.CreateNew(10, 10); CurrentMap.EntryPoints.Add(new LocRay8(new Loc(CurrentMap.Width / 2, CurrentMap.Height / 2), Dir8.Down)); CurrentMapID = new SegLoc(0, -1); }
public Map GetMap(SegLoc id) { if (!maps.ContainsKey(id)) { //NOTE: with the way this is currently done, the random numbers used by the maps end up being related to the random numbers used by the postprocs //not that anyone would really notice... ReRandom totalRand = new ReRandom(rand.FirstSeed); for (int ii = 0; ii < id.Segment; ii++) { totalRand.NextUInt64(); } ulong structSeed = totalRand.NextUInt64(); DiagManager.Instance.LogInfo("Struct Seed: " + structSeed); ReRandom structRand = new ReRandom(structSeed); for (int ii = 0; ii < id.ID; ii++) { structRand.NextUInt64(); } ulong mapSeed = structRand.NextUInt64(); //load the struct context if it isn't present yet if (!structureContexts.ContainsKey(id.Segment)) { ReRandom initRand = new ReRandom(structSeed); ZoneGenContext newContext = new ZoneGenContext(); newContext.CurrentZone = zoneIndex; newContext.CurrentSegment = id.Segment; foreach (ZonePostProc zoneStep in Structures[id.Segment].PostProcessingSteps) { //TODO: find a better way to feed ZonePostProcs into full structures. //Is there a way for them to be stateless? //Additionally, the ZonePostProcs themselves sometimes hold IGenSteps that are copied over to the layouts. //Is that really OK? (I would guess yes because there is no chance by design for them to be mutated when generating...) ZonePostProc newStep = zoneStep.Instantiate(initRand.NextUInt64()); newContext.ZoneSteps.Add(newStep); } structureContexts[id.Segment] = newContext; } ZoneGenContext zoneContext = structureContexts[id.Segment]; zoneContext.CurrentID = id.ID; zoneContext.Seed = mapSeed; //TODO: remove the need for this explicit cast //make a parameterized version of zonestructure and then make zonestructure itself put in basemapgencontext as the parameter Map map = ((BaseMapGenContext)Structures[id.Segment].GetMap(zoneContext)).Map; //uncomment this to cache the state of every map after its generation. it's not nice on memory though... //maps.Add(id, map); return(map); } return(maps[id]); }
//include a current groundmap, with moveto methods included public void MoveToZone(int zoneIndex, SegLoc mapId, ulong seed) { if (CurrentZone != null) { CurrentZone.DoCleanup(); } CurrentZoneID = zoneIndex; ZoneData zone = DataManager.Instance.GetZone(zoneIndex); if (zone != null) { CurrentZone = zone.CreateActiveZone(seed, zoneIndex); CurrentZone.SetCurrentMap(mapId); } }
/// <summary> /// Finds the mapname in this zone's map list, and loads it. /// </summary> /// <param name="mapname"></param> public void SetCurrentGround(string mapname) { exitMap(); int index = GroundMaps.FindIndex((str) => (str == mapname)); if (index > -1) { CurrentGround = GetGround(new SegLoc(-1, index)); } else { throw new Exception(String.Format("Cannot find ground map of name {0} in {1}.", mapname, Name.DefaultText)); } CurrentMapID = new SegLoc(-1, index); }
public void SetCurrentMap(SegLoc map) { exitMap(); if (map.IsValid()) { if (map.Segment > -1) { CurrentMap = GetMap(map); } else { CurrentGround = GetGround(map); } } CurrentMapID = map; }
public ZoneLoc(int id, SegLoc structId, int entryPoint) { ID = id; StructID = structId; EntryPoint = entryPoint; }
public ZoneLoc(int id, SegLoc structId) { ID = id; StructID = structId; EntryPoint = 0; }
public ZoneLoc(int structure, int id) { ID = -1; StructID = new SegLoc(structure, id); EntryPoint = 0; }
public GroundMap GetGround(SegLoc id) { return(DataManager.Instance.GetGround(GroundMaps[id.ID])); }