/// <summary> /// Created to avoid exception that key exist already /// </summary> void AddToAll(RegFile regFile) { var key = regFile.MyId; //if key exsit will add this number at the end . //This can happen when spawing a building and an old building has the same name and ID # if (_allBuilding.ContainsKey(key)) { key = key + "1983"; } regFile.MyId = key; var build = BuildingPot.Control.CurrentSpawnBuild; //means is a CancelDemolish if (build == null) { build = SelectBuilding; BuildingPot.Control.CurrentSpawnBuild = SelectBuilding; } build.MyId = key; build.transform.name = key; AllRegFile.Add(regFile); _allBuilding.Add(key, build); }
/// <summary> /// Will update Propersties on AllRegFile so when is saved is there to be loaded /// /// Prop that Update so far: /// BookedHome1 /// Instruction /// Families /// Invetory /// PeopleDic /// PositionFilled /// Anchors /// DollarsPay /// Dock1 /// PlantSave1 /// Dispatch /// BuildersManager1 /// CurrentProd /// </summary> public void ResaveOnRegistro(string myIdP) { //for when Building is loading and writing PeopleDict if (!AllBuilding.ContainsKey(myIdP)) { return; } var build = AllBuilding[myIdP]; int index = AllRegFile.FindIndex(a => a.MyId == myIdP); //bz when destroying Way this method is called if (index == -1) { return; } AllRegFile[index].BookedHome1 = build.BookedHome1; AllRegFile[index].Instruction = build.Instruction; AllRegFile[index].Familes = build.Families; AllRegFile[index].Inventory = build.Inventory; AllRegFile[index].PeopleDict = build.PeopleDict; AllRegFile[index].Anchors = build.Anchors.ToArray(); //UVisHelp.CreateHelpers(build.Anchors, Root.yellowCube); AllRegFile[index].DollarsPay = build.DollarsPay; AllRegFile[index].Dock1 = build.Dock1; AllRegFile[index].Dispatch1 = build.Dispatch1; AllRegFile[index].BuildersManager1 = build.BuildersManager1; AllRegFile[index].PlantSave1 = build.PlantSave1; AllRegFile[index].CurrentProd = build.CurrentProd; AllRegFile[index].Name = build.NameBuilding(); }
public List <Vector3> ReturnMySavedAnchors(string MyIdP) { var miSave = AllRegFile.Find(a => a.MyId == MyIdP); if (miSave != null) { return(miSave.Anchors.ToList()); } return(new List <Vector3>()); }
/// <summary> /// So its removed at the end so no new buildings are created on top of building that will be removed soon /// </summary> /// <param name="myId"></param> public void RemoveFromAllRegFile(string myId) { int index = AllRegFile.FindIndex(a => a.MyId == myId); //bz when destroying Way this method is called at least two times. //the 2nd time doesnt find the index bz was removed already if (index == -1) { return; } AllRegFile.RemoveAt(index); }
/// <summary> /// This is intended to save the new material assigned to the building on disk /// </summary> public void UpdateItemMaterial(Ca cat, string myId, string newMatKey) { int index = AllRegFile.FindIndex(a => a.MyId == myId); AllRegFile[index].MaterialKey = newMatKey; if (cat == Ca.Way) { Ways[myId].MaterialKey = newMatKey; } else if (cat == Ca.Structure || cat == Ca.Shore) { Structures[myId].MaterialKey = newMatKey; } else if (cat == Ca.DraggableSquare) { DragSquares[myId].MaterialKey = newMatKey; } }