//############################################################################ //# Rendering and Unrendering Entities # //# An entity should be in the rendered or unrendered form, but not both. # //############################################################################ public void Save() { OverworldData data = new OverworldData(this); AdventureDb db = new AdventureDb(saveFile); db.SaveData(data); }
public TerrainCell RenderCell(int id) { if (!Util.ValidCellIndex(id, WorldWidth)) { return(null); } if (cells.ContainsKey(id)) { return(cells[id]); } if (!cellsData.ContainsKey(id)) { AdventureDb db = new AdventureDb(saveFile); TerrainCellData data = db.LoadCell(id); cellsData.Add(id, data); } TerrainCellData cellData = cellsData[id]; cellsData.Remove(id); TerrainCell cell = new TerrainCell(cellData, CellSize, BaseBlockSize()); Vector3 cellPos = Util.CellPositionFromCoords(cell.coords, GetCellScale()); cell.SetCenteredPosition(cellPos); cells.Add(cell.id, cell); AddChild(cell); foreach (ActorData actor in ActorsDataAtCoords(cell.coords)) { RenderActor(actor.id); } foreach (ItemData item in ItemDataAtCoords(cell.coords)) { GD.Print("Item found at " + cell.coords); RenderItem(item.id); } return(cell); }
/* Asks the cartographer to make a new world */ public void InitWorld() { if (Session.session.adventureSettings != null && Session.session.adventureSettings.load) { AdventureDb db = new AdventureDb(saveFile); OverworldData dat = db.LoadData(); actorsData = dat.actorsData; itemsData = dat.itemsData; return; } Cartographer cart = new Cartographer(); cart.GenerateWorld(this); cellsData = cart.cells; itemsData = cart.items; actorsData = cart.actors; }