protected override void Dispose(bool disposing) { base.Dispose(disposing); if (disposing) { _display?.Dispose(); _template = null; _parts.Clear(); } }
public void UpdateDisplay(BodyScannerTemplateData template, Dictionary <string, BodyScannerBodyPartData> parts) { _template = template; _parts = parts; _slots = new List <string>(); foreach (var(key, value) in _parts) { _slots.Add(key); //We have to do this since ItemLists only return the index of what item is selected and dictionaries don't allow you to explicitly grab things by index. //So we put the contents of the dictionary into a list so that we can grab the list by index. I don't know either. BodyPartList.AddItem(CultureInfo.CurrentCulture.TextInfo.ToTitleCase(key)); } }
protected override void UpdateState(BoundUserInterfaceState state) { base.UpdateState(state); if (!(state is BodyScannerInterfaceState scannerState)) { return; } _template = scannerState.Template; _parts = scannerState.Parts; _display.UpdateDisplay(_template, _parts); }
/// <summary> /// Copy BodyTemplate and BodyPart data into a common data class that the client can read. /// </summary> private BodyScannerInterfaceState PrepareBodyScannerInterfaceState(BodyTemplate template, Dictionary <string, BodyPart> bodyParts) { Dictionary <string, BodyScannerBodyPartData> partsData = new Dictionary <string, BodyScannerBodyPartData>(); foreach (var(slotname, bpart) in bodyParts) { List <BodyScannerMechanismData> mechanismData = new List <BodyScannerMechanismData>(); foreach (var mech in bpart.Mechanisms) { mechanismData.Add(new BodyScannerMechanismData(mech.Name, mech.Description, mech.RSIPath, mech.RSIState, mech.MaxDurability, mech.CurrentDurability)); } partsData.Add(slotname, new BodyScannerBodyPartData(bpart.Name, bpart.RSIPath, bpart.RSIState, bpart.MaxDurability, bpart.CurrentDurability, mechanismData)); } BodyScannerTemplateData templateData = new BodyScannerTemplateData(template.Name, template.Slots); return(new BodyScannerInterfaceState(partsData, templateData)); }
public void UpdateDisplay(BodyScannerTemplateData template, Dictionary <string, BodyScannerBodyPartData> parts) { _template = template; _parts = parts; _slots = new List <string>(); BodyPartList.Clear(); foreach (var slotName in _parts.Keys) { // We have to do this since ItemLists only return the index of what item is // selected and dictionaries don't allow you to explicitly grab things by index. // So we put the contents of the dictionary into a list so // that we can grab the list by index. I don't know either. _slots.Add(slotName); BodyPartList.AddItem(Loc.GetString(slotName)); } }
private BodyScannerInterfaceState InterfaceState(BodyTemplate template, IReadOnlyDictionary <string, IBodyPart> bodyParts) { var partsData = new Dictionary <string, BodyScannerBodyPartData>(); foreach (var(slotName, part) in bodyParts) { var mechanismData = new List <BodyScannerMechanismData>(); foreach (var mechanism in part.Mechanisms) { mechanismData.Add(new BodyScannerMechanismData(mechanism.Name, mechanism.Description, mechanism.RSIPath, mechanism.RSIState, mechanism.MaxDurability, mechanism.CurrentDurability)); } partsData.Add(slotName, new BodyScannerBodyPartData(part.Name, part.RSIPath, part.RSIState, part.MaxDurability, part.CurrentDurability, mechanismData)); } var templateData = new BodyScannerTemplateData(template.Name, template.Slots); return(new BodyScannerInterfaceState(partsData, templateData)); }