private void RemoveNamelessObject(MapObjectNameless item) { if (item.Imported) { int j = 0; for (int i = 0; i < NamedObjects.Count && NamelessObjects[i] != item; i++) { j += NamelessObjects[i].Imported ? 1 : 0; } NamelessIdList.RemoveAt(j); } NamelessObjects.Remove(item); }
public bool Select_PreviousNameless() { bool changed = false; MapObjectNameless toBeSelected = null; int i; for (i = NamedObjects.Count - 1; i >= 0; i--) { changed = changed || NamedObjects[i].Selected; NamedObjects[i].Selected = false; } if (SelectionNameless == null) { if (NamelessObjects.Count == 0) { return(changed); } SelectionNameless = NamelessObjects[NamelessObjects.Count - 1]; return(true); } if (NamelessObjects.Count == 1) { return(changed); } i = NamelessObjects.Count - 1; bool foundSelected = false; while (toBeSelected == null) { if (foundSelected) { toBeSelected = NamelessObjects[i]; } if (SelectionNameless == NamelessObjects[i]) { foundSelected = true; } i--; i = i < 0 ? NamelessObjects.Count - 1 : i; } SelectionNameless = toBeSelected; return(true); }
public bool Select_All() { bool changed = false; if (_selectionNameless != null) { changed = true; _selectionNameless = null; } foreach (MapObjectNamed item in NamedObjects) { changed = changed || !item.Selected; item.Selected = true; } return(changed); }
public bool Select_None() { bool foundOne = false; bool changed = false; if (_selectionNameless != null) { changed = true; _selectionNameless = null; } foreach (MapObjectNamed item in NamedObjects) { if (item.Selected) { foundOne = true; item.Selected = false; } } return(foundOne || changed); }
public int Delete_Selected() { int somethingDeleted = 0; if (SelectionNameless != null) { RemoveNamelessObject(SelectionNameless); _selectionNameless = null; return(1); } for (int i = NamedObjects.Count - 1; i >= 0; i--) { if (NamedObjects[i].Selected) { RemoveNamedObject(NamedObjects[i]); somethingDeleted++; } } return(somethingDeleted); }
//COPIER public void Copy(bool excludeStartCoordinate, MapObjectNameless source) { if (source == null) { return; } if (!excludeStartCoordinate) { this._coordinatesStart = source._coordinatesStart; } this._coordinatesEnd = this._coordinatesStart + source._coordinatesEnd - source._coordinatesStart; this._aEnd = source._aEnd; this._aStart = source._aStart; this._count = source._count; this._radius = source._radius; this._randomRange = source._randomRange; this._randomSeed = source._randomSeed; if (this._type == MapObjectNamelessType.nothing) { this._type = source._type; } }
public static MapObjectNameless NewFromXml(XmlNode item) { if (!(item is XmlElement)) { return(null); } string type = ""; MapObjectNameless mo = null; foreach (XmlAttribute att in item.Attributes) { if (att.Name == "type") { type = att.Value.ToString(); } } switch (type) { case "nebulas": mo = new MapObjectNameless(type: type); break; case "asteroids": mo = new MapObjectNameless(type: type); break; case "mines": mo = new MapObjectNameless(type: type); break; default: return(null); } mo.FromXml(item); return(mo); }
public bool IsCreateNamelessStatement() { if (CanBeCreateNamelessStatement()) { try { SpaceMap.MapObjectNameless nmo = SpaceMap.MapObjectNameless.NewFromXml(ToXml(new XmlDocument(), true)); if (nmo == null) { throw new FormatException(); } } catch (FormatException) { // The object contains expressions and cannot be edited on space map return(false); } return(true); } else { return(false); } }
public bool Select_AtPoint(int x, int z, int pixelsInOne, double y_scale = 0.0, bool additive = false, bool removative = false) { List <MapObjectNamed> objectsSelectedUnderCursor = new List <MapObjectNamed>(); List <MapObjectNamed> objectsUnderCursor = new List <MapObjectNamed>(); List <MapObjectNamed> objectsSelectedNotUnderCursor = new List <MapObjectNamed>(); int i; bool changed = false; if (_selectionNameless != null) { changed = true; _selectionNameless = null; } foreach (MapObjectNamed item in NamedObjects) { if ((Math.Sqrt(Math.Pow(item.Coordinates.X_Scr - x, 2) + Math.Pow(item.Coordinates.Z_Scr - z, 2)) < item._selectionSize * (item._selectionAbsolute ? 1 : pixelsInOne)) || (Math.Sqrt(Math.Pow(item.Coordinates.X_Scr - x, 2) + Math.Pow(item.Coordinates.Z_Scr - item.Coordinates.Y_Scr * y_scale - z, 2)) < item._selectionSize * (item._selectionAbsolute ? 1 : pixelsInOne))) { objectsUnderCursor.Add(item); if (item.Selected) { objectsSelectedUnderCursor.Add(item); } } else { if (item.Selected) { objectsSelectedNotUnderCursor.Add(item); } } } if (additive) { //if there are objects under cursor that are not selected and those that are => select them in usual order if (objectsUnderCursor.Count > objectsSelectedUnderCursor.Count && objectsSelectedUnderCursor.Count > 0) { MapObjectNamed toBeSelected = null, cur = null; i = 0; bool foundSelected = false; while (toBeSelected == null) { cur = objectsUnderCursor[i]; if (!cur.Selected && foundSelected) { toBeSelected = cur; } if (objectsSelectedUnderCursor.Contains(cur)) { foundSelected = true; } i = (i + 1) % objectsUnderCursor.Count; } toBeSelected.Selected = true; return(true); } //if there are objects under cursor that are not selected and none under cursor are selected => select first from the list if (objectsUnderCursor.Count > 0 && objectsSelectedUnderCursor.Count == 0) { objectsUnderCursor[0].Selected = true; return(true); } return(changed); } if (removative) { if (objectsSelectedUnderCursor.Count > 0) { objectsSelectedUnderCursor[0].Selected = false; return(true); } return(changed); } //If more than one selected total and at least one selected under cursor => deselect everything and try again if (objectsSelectedUnderCursor.Count + objectsSelectedNotUnderCursor.Count > 1 && objectsSelectedUnderCursor.Count > 0) { for (i = NamedObjects.Count - 1; i >= 0; i--) { NamedObjects[i].Selected = false; } return(Select_AtPoint(x, z, pixelsInOne)); } //If there is something to select under cursor and nothing is selected there => just select first (and deselect everything else) if (objectsUnderCursor.Count > 0 && objectsSelectedUnderCursor.Count == 0) { for (i = NamedObjects.Count - 1; i >= 0; i--) { NamedObjects[i].Selected = false; } objectsUnderCursor[0].Selected = true; return(true); } //If only one object under cursor and its already selected => do nothing, let it remain selected if (objectsUnderCursor.Count == 1 && objectsSelectedUnderCursor.Count == 1) { return(changed); } //If there is something to select under cursor but something is already selected there = > we will select the next unselected after a selected one if (objectsUnderCursor.Count > 0 && objectsSelectedUnderCursor.Count > 0) { MapObjectNamed toBeSelected = null, cur = null; i = 0; bool foundSelected = false; while (toBeSelected == null) { cur = objectsUnderCursor[i]; if (!cur.Selected && foundSelected) { toBeSelected = cur; } if (objectsSelectedUnderCursor.Contains(cur)) { foundSelected = true; } i = (i + 1) % objectsUnderCursor.Count; } for (i = NamedObjects.Count - 1; i >= 0; i--) { NamedObjects[i].Selected = false; } toBeSelected.Selected = true; return(true); } //If there is nothing to select under cursor but something selected elsewhere - clear it if (objectsSelectedNotUnderCursor.Count > 0) { for (i = NamedObjects.Count - 1; i >= 0; i--) { NamedObjects[i].Selected = false; } return(true); } //If nothing is or was selected if (objectsSelectedNotUnderCursor.Count == 0 && objectsUnderCursor.Count == 0) { return(changed); } throw new Exception("Select_AtPoint reached the end in normal mode! This means an error in function's logic."); //return false; }
public bool Select_All() { bool changed = false; if (_selectionNameless != null) { changed = true; _selectionNameless = null; } foreach (MapObjectNamed item in NamedObjects) { changed = changed || !item.Selected; item.Selected = true; } return changed; }
public int Delete_Selected() { int somethingDeleted = 0; if (SelectionNameless != null) { RemoveNamelessObject(SelectionNameless); _selectionNameless = null; return 1; } for (int i = NamedObjects.Count - 1; i >= 0; i--) { if (NamedObjects[i].Selected) { RemoveNamedObject(NamedObjects[i]); somethingDeleted++; } } return somethingDeleted; }
public bool Select_AtPoint(int x, int z, int pixelsInOne, double y_scale = 0.0, bool additive = false, bool removative = false) { List<MapObjectNamed> objectsSelectedUnderCursor = new List<MapObjectNamed>(); List<MapObjectNamed> objectsUnderCursor = new List<MapObjectNamed>(); List<MapObjectNamed> objectsSelectedNotUnderCursor = new List<MapObjectNamed>(); int i; bool changed = false; if (_selectionNameless != null) { changed = true; _selectionNameless = null; } foreach (MapObjectNamed item in NamedObjects) { if ((Math.Sqrt(Math.Pow(item.Coordinates.X_Scr - x, 2) + Math.Pow(item.Coordinates.Z_Scr - z, 2)) < item._selectionSize * (item._selectionAbsolute ? 1 : pixelsInOne)) || (Math.Sqrt(Math.Pow(item.Coordinates.X_Scr - x, 2) + Math.Pow(item.Coordinates.Z_Scr- item.Coordinates.Y_Scr* y_scale - z, 2)) < item._selectionSize * (item._selectionAbsolute ? 1 : pixelsInOne))) { objectsUnderCursor.Add(item); if (item.Selected) objectsSelectedUnderCursor.Add(item); } else { if (item.Selected) objectsSelectedNotUnderCursor.Add(item); } } if (additive) { //if there are objects under cursor that are not selected and those that are => select them in usual order if (objectsUnderCursor.Count > objectsSelectedUnderCursor.Count && objectsSelectedUnderCursor.Count > 0) { MapObjectNamed toBeSelected = null, cur = null; i = 0; bool foundSelected = false; while (toBeSelected == null) { cur = objectsUnderCursor[i]; if (!cur.Selected && foundSelected) toBeSelected = cur; if (objectsSelectedUnderCursor.Contains(cur)) foundSelected = true; i = (i + 1) % objectsUnderCursor.Count; } toBeSelected.Selected = true; return true; } //if there are objects under cursor that are not selected and none under cursor are selected => select first from the list if (objectsUnderCursor.Count > 0 && objectsSelectedUnderCursor.Count == 0) { objectsUnderCursor[0].Selected = true; return true; } return changed; } if (removative) { if (objectsSelectedUnderCursor.Count > 0) { objectsSelectedUnderCursor[0].Selected = false; return true; } return changed; } //If more than one selected total and at least one selected under cursor => deselect everything and try again if (objectsSelectedUnderCursor.Count + objectsSelectedNotUnderCursor.Count > 1 && objectsSelectedUnderCursor.Count > 0) { for (i = NamedObjects.Count - 1; i >= 0; i--) NamedObjects[i].Selected = false; return Select_AtPoint(x, z, pixelsInOne); } //If there is something to select under cursor and nothing is selected there => just select first (and deselect everything else) if (objectsUnderCursor.Count > 0 && objectsSelectedUnderCursor.Count == 0) { for (i = NamedObjects.Count - 1; i >= 0; i--) NamedObjects[i].Selected = false; objectsUnderCursor[0].Selected = true; return true; } //If only one object under cursor and its already selected => do nothing, let it remain selected if (objectsUnderCursor.Count == 1 && objectsSelectedUnderCursor.Count == 1) { return changed; } //If there is something to select under cursor but something is already selected there = > we will select the next unselected after a selected one if (objectsUnderCursor.Count > 0 && objectsSelectedUnderCursor.Count > 0) { MapObjectNamed toBeSelected = null, cur = null; i = 0; bool foundSelected= false; while (toBeSelected == null) { cur = objectsUnderCursor[i]; if (!cur.Selected && foundSelected) toBeSelected = cur; if (objectsSelectedUnderCursor.Contains(cur)) foundSelected = true; i = (i + 1) % objectsUnderCursor.Count; } for (i = NamedObjects.Count - 1; i >= 0; i--) NamedObjects[i].Selected = false; toBeSelected.Selected = true; return true; } //If there is nothing to select under cursor but something selected elsewhere - clear it if (objectsSelectedNotUnderCursor.Count > 0) { for (i = NamedObjects.Count - 1; i >= 0; i--) NamedObjects[i].Selected = false; return true; } //If nothing is or was selected if (objectsSelectedNotUnderCursor.Count == 0 && objectsUnderCursor.Count == 0) { return changed; } throw new Exception("Select_AtPoint reached the end in normal mode! This means an error in function's logic."); //return false; }
public bool DrawSpaceMap_GetPoint(double screen_y_scale, Random rnd, MapObjectNameless item, int i, double angleStart, double angleEnd, out double x, out double zy, out double z) { int j; double a, length; Coordinates3D c = new Coordinates3D(); c._allow_out_of_range = true; if (item.radius > 0) { //point on a circle switch (item._type) { case MapObjectNamelessType.asteroids: KeyValuePair<double, double> result = GetAsteroidPositionOnArc(item.radius, angleEnd - angleStart, i, item.count); a = 3 * Math.PI / 2 - //Convert from map coords to screen coords (angleStart + ((angleEnd - angleStart) * result.Value)); //start angle plus position inside arc from start to end angle length = result.Key; break; default: a = 3 * Math.PI / 2 - //Convert from map coords to screen coords (angleStart + ((angleEnd - angleStart) * ((i + 0.5) / item.count))); //start angle plus position inside arc from start to end angle length = item.radius; break; } c.X = item.CoordinatesStart.X + (int)Math.Round(length * Math.Cos(a)) + item.randomRange - rnd.Next(2 * item.randomRange); c.Y = item._coordinatesStart.Y; c.Z = item.CoordinatesStart.Z + (int)Math.Round(length * Math.Sin(a)) + item.randomRange - rnd.Next(2 * item.randomRange); } else { a = item.count == 1 ? 0.5 : (double)i / (double)(item.count - 1.0); c.X = (int)Math.Round(a * item.CoordinatesStart.X + (1 - a) * item.CoordinatesEnd.X + item.randomRange - rnd.Next(2 * (item.randomRange))); c.Y = (int)Math.Round(a * item.CoordinatesStart.Y + (1 - a) * item.CoordinatesEnd.Y); c.Z = (int)Math.Round(a * item.CoordinatesStart.Z + (1 - a) * item.CoordinatesEnd.Z + item.randomRange - rnd.Next(2 * item.randomRange)); } switch (item._type) { case MapObjectNamelessType.asteroids: j = Space.AsteroidWidth * 19 / 64; c.X = c.X + j - rnd.Next(2 * j); c.Y = c.Y + j - rnd.Next(2 * j); c.Z = c.Z + j - rnd.Next(2 * j); break; default: break; } //WTF IS THIS? //if (c.X < SpaceMap._minX || c.Y < SpaceMap._minY || c.Z < SpaceMap._minZ || c.X > SpaceMap._maxX || c.Y > SpaceMap._maxY || c.Z > SpaceMap._maxZ) //{ x = -1; z = -1; zy = -1; return false; } else { } x = PointXToScreen(c.X_Scr); zy = PointZToScreen(c.Z_Scr) - c.Y_Scr * screen_y_scale; z = PointZToScreen(c.Z_Scr); return true; }
public bool Select_None() { bool foundOne = false; bool changed = false; if (_selectionNameless != null) { changed = true; _selectionNameless = null; } foreach (MapObjectNamed item in NamedObjects) { if (item.Selected) { foundOne = true; item.Selected = false; } } return foundOne || changed; }
public bool Select_InRectangle(int x1, int z1, int x2, int z2, int pixelsInOne, double y_scale = 0.0, bool additive = false, bool removative = false) { List<MapObjectNamed> objectsSelectedOutside = new List<MapObjectNamed>(); List<MapObjectNamed> objectsInside = new List<MapObjectNamed>(); List<MapObjectNamed> objectsSelectedInside = new List<MapObjectNamed>(); int tmp; bool changed = false; if (_selectionNameless != null) { changed = true; _selectionNameless = null; } if (x1 > x2) { tmp = x1; x1 = x2; x2 = tmp; } if (z1 > z2) { tmp = z1; z1 = z2; z2 = tmp; } foreach (MapObjectNamed item in NamedObjects) { if ((item.Coordinates.X_Scr > x1 - pixelsInOne && item.Coordinates.X_Scr < x2 + pixelsInOne && item.Coordinates.Z_Scr > z1 - pixelsInOne && item.Coordinates.Z_Scr < z2 + pixelsInOne) || (item.Coordinates.X_Scr > x1 - pixelsInOne && item.Coordinates.X_Scr < x2 + pixelsInOne && item.Coordinates.Z_Scr - item.Coordinates.Y_Scr * y_scale > z1 - pixelsInOne && item.Coordinates.Z_Scr - item.Coordinates.Y_Scr * y_scale < z2 + pixelsInOne)) { objectsInside.Add(item); if (item.Selected) objectsSelectedInside.Add(item); } else if (item.Selected) objectsSelectedOutside.Add(item); } if (additive) { //if there are unselected objects inside => select them if (objectsInside.Count > objectsSelectedInside.Count) { foreach (MapObjectNamed item in objectsInside) item.Selected = true; return true; } return changed; } if (removative) { //if there are selected objects inside => unselect them if (objectsSelectedInside.Count > 0) { foreach (MapObjectNamed item in objectsSelectedInside) item.Selected = false; return true; } return changed; } //if there are objects selected outside but no objects inside unselect everything if (objectsSelectedOutside.Count > 0 && objectsInside.Count == 0) { foreach (MapObjectNamed item in objectsSelectedOutside) item.Selected = false; return true; } //If we have nothing to select inside or deselect outside if (objectsInside.Count == objectsSelectedInside.Count && objectsSelectedOutside.Count == 0) return changed; //if there are objects to be selected inside - select them, after unselecting everything if (objectsInside.Count > objectsSelectedInside.Count) { foreach (MapObjectNamed item in objectsSelectedOutside) item.Selected = false; foreach (MapObjectNamed item in objectsInside) item.Selected = true; return true; } return changed; }
public bool Select_InRectangle(int x1, int z1, int x2, int z2, int pixelsInOne, double y_scale = 0.0, bool additive = false, bool removative = false) { List <MapObjectNamed> objectsSelectedOutside = new List <MapObjectNamed>(); List <MapObjectNamed> objectsInside = new List <MapObjectNamed>(); List <MapObjectNamed> objectsSelectedInside = new List <MapObjectNamed>(); int tmp; bool changed = false; if (_selectionNameless != null) { changed = true; _selectionNameless = null; } if (x1 > x2) { tmp = x1; x1 = x2; x2 = tmp; } if (z1 > z2) { tmp = z1; z1 = z2; z2 = tmp; } foreach (MapObjectNamed item in NamedObjects) { if ((item.Coordinates.X_Scr > x1 - pixelsInOne && item.Coordinates.X_Scr < x2 + pixelsInOne && item.Coordinates.Z_Scr > z1 - pixelsInOne && item.Coordinates.Z_Scr < z2 + pixelsInOne) || (item.Coordinates.X_Scr > x1 - pixelsInOne && item.Coordinates.X_Scr < x2 + pixelsInOne && item.Coordinates.Z_Scr - item.Coordinates.Y_Scr * y_scale > z1 - pixelsInOne && item.Coordinates.Z_Scr - item.Coordinates.Y_Scr * y_scale < z2 + pixelsInOne)) { objectsInside.Add(item); if (item.Selected) { objectsSelectedInside.Add(item); } } else if (item.Selected) { objectsSelectedOutside.Add(item); } } if (additive) { //if there are unselected objects inside => select them if (objectsInside.Count > objectsSelectedInside.Count) { foreach (MapObjectNamed item in objectsInside) { item.Selected = true; } return(true); } return(changed); } if (removative) { //if there are selected objects inside => unselect them if (objectsSelectedInside.Count > 0) { foreach (MapObjectNamed item in objectsSelectedInside) { item.Selected = false; } return(true); } return(changed); } //if there are objects selected outside but no objects inside unselect everything if (objectsSelectedOutside.Count > 0 && objectsInside.Count == 0) { foreach (MapObjectNamed item in objectsSelectedOutside) { item.Selected = false; } return(true); } //If we have nothing to select inside or deselect outside if (objectsInside.Count == objectsSelectedInside.Count && objectsSelectedOutside.Count == 0) { return(changed); } //if there are objects to be selected inside - select them, after unselecting everything if (objectsInside.Count > objectsSelectedInside.Count) { foreach (MapObjectNamed item in objectsSelectedOutside) { item.Selected = false; } foreach (MapObjectNamed item in objectsInside) { item.Selected = true; } return(true); } return(changed); }
private void RemoveNamelessObject(MapObjectNameless item) { if (item.Imported) { int j = 0; for (int i = 0; i < NamedObjects.Count && NamelessObjects[i] != item; i++) j += NamelessObjects[i].Imported ? 1 : 0; NamelessIdList.RemoveAt(j); } NamelessObjects.Remove(item); }
public static MapObjectNameless NewFromXml(XmlNode item) { if (!(item is XmlElement)) return null; string type = ""; MapObjectNameless mo = null; foreach (XmlAttribute att in item.Attributes) if (att.Name == "type") type = att.Value.ToString(); switch (type) { case "nebulas": mo = new MapObjectNameless(type: type); break; case "asteroids": mo = new MapObjectNameless(type: type); break; case "mines": mo = new MapObjectNameless(type: type); break; default: return null; } mo.FromXml(item); return mo; }
public void FromXml(string text) { XmlDocument xDoc = new XmlDocument(); try { xDoc.LoadXml(text); } catch (Exception ex) { Log.Add("Failed to load space map from xml for the following reasons:"); Log.Add(ex); return; } XmlNode root = null; foreach (XmlNode node in xDoc.ChildNodes) { if (node.Name == "createInput" || node.Name == "statementInput" || node.Name == "bgInput" || node.Name == "output") { root = node; } } if (root == null) { Log.Add("Failed to load space map from xml for the following reasons:"); Log.Add("Root node \"createInput\" or \"statementInput\" or \"bgInput\" or \"output\"not found!"); return; } if (root.Name == "createInput" || root.Name == "bgInput" || root.Name == "output") { bool bg = root.Name == "bgInput"; if (!bg) { Clear(); } foreach (XmlNode item in root.ChildNodes) { MapObjectNamed mo = MapObjectNamed.NewFromXml(item); MapObjectNameless nmo = MapObjectNameless.NewFromXml(item); if (bg) { if (mo != null) { BacgkroundNamedObjects.Add(mo); } if (nmo != null) { BackgroundNamelessObjects.Add(nmo); } } else { if (mo != null) { NamedObjects.Add(mo); } if (nmo != null) { NamelessObjects.Add(nmo); } } } } if (root.Name == "statementInput") { Clear(); SelectionSpecial = MapObjectSpecial.NewFromXml(root.ChildNodes[0]); } }
public object AddObject(string type, int posX = 0, int posY = 0, int posZ = 0, int angle = 0, bool makeSelected = false) { MapObjectNamed mo = null; MapObjectNameless nmo = null; switch (type) { case "station": mo = new MapObjectNamed_station(posX, posY, posZ, makeSelected, angle); break; case "neutral": mo = new MapObjectNamed_neutral(posX, posY, posZ, makeSelected, angle); break; case "player": mo = new MapObjectNamed_player(posX, posY, posZ, makeSelected, angle); break; case "monster": mo = new MapObjectNamed_monster(posX, posY, posZ, makeSelected, angle); break; case "Anomaly": mo = new MapObjectNamed_Anomaly(posX, posY, posZ, "", makeSelected); break; case "blackHole": mo = new MapObjectNamed_blackHole(posX, posY, posZ, "", makeSelected); break; case "enemy": mo = new MapObjectNamed_enemy(posX, posY, posZ, makeSelected, angle); break; case "genericMesh": mo = new MapObjectNamed_genericMesh(posX, posY, posZ, makeSelected, angle); break; case "whale": mo = new MapObjectNamed_whale(posX, posY, posZ, makeSelected, angle); break; case "nameless": nmo = new MapObjectNameless(posX, posY, posZ, ""); break; case "nebulas": nmo = new MapObjectNameless(posX, posY, posZ, "nebulas"); break; case "asteroids": nmo = new MapObjectNameless(posX, posY, posZ, "asteroids"); break; case "mines": nmo = new MapObjectNameless(posX, posY, posZ, "mines"); break; default: break; } if (mo == null && nmo == null) { throw new NotImplementedException("Attempting to add object of unknown type " + type); } if (mo != null) { NamedObjects.Add(mo); return(mo); } else { NamelessObjects.Add(nmo); if (makeSelected) { Select_None(); SelectionNameless = nmo; } return(nmo); } }
//COPIER public void Copy(bool excludeStartCoordinate, MapObjectNameless source) { if (source == null) return; if (!excludeStartCoordinate) this._coordinatesStart = source._coordinatesStart; this._coordinatesEnd = this._coordinatesStart + source._coordinatesEnd - source._coordinatesStart; this._aEnd = source._aEnd; this._aStart = source._aStart; this._count = source._count; this._radius = source._radius; this._randomRange = source._randomRange; this._randomSeed = source._randomSeed; if (this._type == MapObjectNamelessType.nothing) this._type = source._type; }
public object AddObject(string type, int posX = 0, int posY = 0, int posZ = 0, int angle = 0, bool makeSelected = false) { MapObjectNamed mo = null; MapObjectNameless nmo = null; switch (type) { case "station": mo = new MapObjectNamed_station(posX, posY, posZ, makeSelected, angle); break; case "neutral": mo = new MapObjectNamed_neutral(posX, posY, posZ, makeSelected, angle); break; case "player": mo = new MapObjectNamed_player(posX, posY, posZ, makeSelected, angle); break; case "monster": mo = new MapObjectNamed_monster(posX, posY, posZ, makeSelected, angle); break; case "anomaly": mo = new MapObjectNamed_anomaly(posX, posY, posZ, "", makeSelected); break; case "blackHole": mo = new MapObjectNamed_blackHole(posX, posY, posZ, "", makeSelected); break; case "enemy": mo = new MapObjectNamed_enemy(posX, posY, posZ, makeSelected, angle); break; case "genericMesh": mo = new MapObjectNamed_genericMesh(posX, posY, posZ, makeSelected, angle); break; case "whale": mo = new MapObjectNamed_whale(posX, posY, posZ, makeSelected, angle); break; case "nameless": nmo = new MapObjectNameless(posX, posY, posZ, ""); break; case "nebulas": nmo = new MapObjectNameless(posX, posY, posZ, "nebulas"); break; case "asteroids": nmo = new MapObjectNameless(posX, posY, posZ, "asteroids"); break; case "mines": nmo = new MapObjectNameless(posX, posY, posZ, "mines"); break; default: break; } if (mo == null && nmo==null) throw new NotImplementedException("Attempting to add object of unknown type " + type); if (mo != null) { NamedObjects.Add(mo); return mo; } else { NamelessObjects.Add(nmo); if (makeSelected) { Select_None(); SelectionNameless = nmo; } return nmo; } }