// delete all objects in a particular area public int deleteArea(int x1, int y1, int x2, int y2, int containerId = 0) { // get all objects in the area and mark each one for delete int result = 0; clsObject obj = new clsObject(_db); result += obj.deleteArea(x1, y1, x2, y2, containerId); return result; }
// destroy all objects in a particular area public int destroyArea(clsPoint topLeft, clsPoint bottomRight, int containerId = 0) { // initiate destruction method for each object int result = 0; clsObject obj = new clsObject(_db); result += obj.destroyArea((int)topLeft.x, (int)topLeft.y, (int)bottomRight.x, (int)bottomRight.y, containerId); return result; }
public int destroyAll() { int result = 0; clsObject obj = new clsObject(_db); result += obj.destroyAll(); clsAttribute attribute = new clsAttribute(_db); result += attribute.destroyAll(); return result; }
public List<clsObject> getArea(int x1, int y1, int x2, int y2, int containerId = 0, DateTime? modified = null) { clsObject obj = new clsObject(_db); return obj.getArea(x1, y1, x2, y2, containerId, modified); }
public int deleteAll() { clsObject obj = new clsObject(_db); return obj.deleteAll(); }
public List<clsObject> getObjectsByType(string objectType) { clsObject obj = new clsObject(_db); return obj.getByType(objectType); }
public List<clsObject> getAllObjects() { clsObject obj = new clsObject(_db); return obj.getAll(); }
public string SaveMap(clsPoint worldLocation) { int size = heights.GetLength(0); // clear block clsPoint worldLocationBotRight = new clsPoint(worldLocation.x + heights.Length - 1, worldLocation.y + heights.Length - 1); this.destroyArea(worldLocation, worldLocationBotRight); // load templates clsTemplate template = new clsTemplate(_db); List<clsTemplate> templates = template.getAllTemplates(); int waterLevel = 0; // save results to database clsObject obj = new clsObject(_db); List<clsObject> results = new List<clsObject>(); for (int y = 0; y < size; y++) { for (int x = 0; x < size; x++) { obj = this.createObject((int)worldLocation.x + x, (int)worldLocation.y + y, heights[x, y] * 32, templates.Find(i => i.name.Contains("MC Grass"))); if (heights[x, y] < waterLevel) { for (int z = heights[x, y] + 1; z <= waterLevel; z++) { obj = this.createObject((int)worldLocation.x + x, (int)worldLocation.y + y, z * 32, templates.Find(i => i.name.Contains("MC Water"))); } } } } // height map to JSON string JSON; JSON = "{"; JSON = "\"objectsCreated\":" + results.Count + ""; JSON += "}"; return JSON; }
public List<clsObject> fromJSON(JArray JSONArray) { List<clsObject> results = new List<clsObject>(); // loop thorugh all the JSON obects in the JSON array foreach (JObject JSONObject in JSONArray) { clsObject obj = new clsObject(_db); // create new blank template obj.fromJSON(JSONObject); // load based on JSON Object results.Add(obj); // add new to results } return results; }