public override void ReadData(Reader reader) { //Clear out any current jobs. while (normalJobs.Count > 0) { Cancel(normalJobs.First()); } while (emergencyJobs.Count > 0) { Cancel(emergencyJobs.First()); } //Stop JobQueries from doing stuff until after deserialization is done. JobQueries.Dispose(); base.ReadData(reader); reader.Collection("normalJobs", (MyData.Reader rd, ref Job outval, string name) => { outval = Job.Read(rd, name, TheMap); }, (i) => normalJobs); reader.Collection("emergencyJobs", (MyData.Reader rd, ref Job outVal, string name) => { outVal = Job.Read(rd, name, TheMap); }, (i) => emergencyJobs); foreach (Job j in normalJobs.Concat(emergencyJobs)) { InitJob(j); } }
public void NewJobActionSelected(System.Guid jobGuid) { JobDef jobSelected = JobQueries.ByGuid(ManagerBase.jobDefinitions, jobGuid); if (jobSelected == null) { Debug.LogError("Should not have an empty job here"); } string txt = jobSelected.name + "\n" + jobSelected.description + "\n"; if (jobDescriptionText == null) { jobDescriptionText = UIElementFunctions.TextOnly(jobsPanel.transform, txt, new Vector3(180, -50), new Vector2(300, 100)); } else { jobDescriptionText.textGo.text = txt; } // Add prerequisites, colored, here // Figure out what the building needs Sprite output1Sprite = ManagerBase.resourceDefinitions[ManagerBase.resourceIndexOf[jobSelected.outputName[0]]].image; if (jobSelected.inputResources.rqqList.Count > 0) // Has inputs { resourceChoiceDropdown = ResourceDropdownCreator.CreateResourceChoiceDropdown(tileDetailUiPanel.transform, new Vector3(-200, -185), jobSelected.inputResources, jobSelected.name, ManagerBase.domain, output1Sprite); } else { resourceChoiceDropdown = ResourceDropdownCreator.CreateNoResourceDropdown(tileDetailUiPanel.transform, new Vector3(-200, -185), jobSelected.name, ManagerBase.domain, output1Sprite); } resourceChoiceDropdown.jobStartButton.buttonGo.onClick.AddListener(delegate() { StartJobButton(jobSelected); }); }
public override void FinishDeserialization() { base.FinishDeserialization(); JobQueries.Init(); }
public void CreateDropdown(Vector3 localPosition, float w, float h, string surfaceType) { // Create the button actionDropdown = UIElementFunctions.Dropdown(panel, null, "Surface Actions", localPosition, new Vector2(w, h)); actionDropdown.childHeight = 30; actionDropdown.childFontSize = 16; // Demolish actionDropdown.AddChild(); actionDropdown.children[0].textGo.text = "Demolish"; actionDropdown.children[0].buttonGo.onClick.AddListener(() => demolishCallback("Demolish")); actionDropdown.children[0].CloseButton(); // Upgrades int menuInd = actionDropdown.children.Count; actionDropdown.AddChild(); actionDropdown.children[menuInd].textGo.text = "Upgrade"; //actionDropdown.children[upgradeInd].buttonGo.interactable = false; actionDropdown.children[menuInd].CloseButton(); //Debug.Log(surfaceType); IEnumerable <BuildingDef> upgrades = BuildingQueries.ByParent(ManagerBase.buildingDefinitions, surfaceType); int ind = 0; foreach (BuildingDef def in upgrades) { actionDropdown.children[menuInd].AddChild(); actionDropdown.children[menuInd].children[ind].textGo.text = def.name + " (Tier " + def.tier + ")"; Debug.Log(actionDropdown.children[menuInd].children[ind].textGo.text); actionDropdown.children[menuInd].children[ind].buttonGo.onClick.AddListener(() => buildCallback(def.name)); actionDropdown.children[menuInd].children[ind].CloseButton(); ind++; } // Jobs if (ManagerBase.buildingIndexOf.ContainsKey(surfaceType)) { menuInd++; BuildingDef bldgDef = ManagerBase.buildingDefinitions[ManagerBase.buildingIndexOf[surfaceType]]; List <JobDef> jobs = new List <JobDef>(); for (int jeInd = 0; jeInd < bldgDef.jobsEnabled.Count; jeInd++) { jobs.AddRange(JobQueries.ByNameAndMaxTier(ManagerBase.jobDefinitions, bldgDef.jobsEnabled[jeInd], bldgDef.jobMaxTier[bldgDef.jobsEnabled[jeInd]])); } Debug.Log(jobs.Count()); if (jobs.Count() > 0) { actionDropdown.AddChild(); actionDropdown.children[menuInd].textGo.text = "Start Job"; actionDropdown.children[menuInd].buttonGo.interactable = false; actionDropdown.children[menuInd].CloseButton(); actionDropdown.children[menuInd].Init(); ind = 0; foreach (JobDef job in jobs) { string jobString = job.name + " (" + job.outputName[0] + ")"; actionDropdown.children[menuInd].AddChild(); actionDropdown.children[menuInd].children[ind].textGo.text = jobString; actionDropdown.children[menuInd].children[ind].buttonGo.onClick.AddListener(() => newJobCallback(job.guid)); actionDropdown.children[menuInd].children[ind].CloseButton(); ind++; } } } }
public JobsController() { jobQueries = new JobQueries(jobContext); }