public Dialog_SelectPart(PartCustomisePack pcp, ChassisType ct) { if (pcp == null) { Log.Error("PartCustomisePack was null"); } this.pcp = pcp; availableParts = (from t in DefDatabase <DroidChassisPartDef> .AllDefs where (t.ChassisType == ct || t.ChassisType == ChassisType.Any) && t.ChassisPoint == pcp.ChassisPoint select t).ToList(); var list = (from t in availableParts where t.BasePart == true select t).ToList(); if (list.Count > 0) { basePart = list.First(); availableParts.Remove(basePart); } if (pcp.Part is DroidChassisPartDef) { var p = pcp.Part as DroidChassisPartDef; selPart = p; } absorbInputAroundWindow = true; forcePause = true; }
public List <PartCustomisePack> GetPartCustomisePacks(DroidCustomiseGroupDef group, bool silentFail = false) { if (!partsGrouped.Keys.Contains(group)) { List <PartCustomisePack> list = new List <PartCustomisePack>(); foreach (var li in group.Parts) { //Make a new part customise pack var baseParts = GetBasePartAt(li.ChassisPoint, li.BodyPosition).ToList(); if (baseParts.Count > 0) { foreach (var partRecord in baseParts) { if (partRecord is DroidChassisPartRecord) { //Check the body position. If the position passed is undefined, don't care what position the part has DroidChassisPartRecord droidRecord = partRecord as DroidChassisPartRecord; if (li.BodyPosition == BodyPosition.Undefined || droidRecord.bodyPosition == li.BodyPosition) { DroidChassisPartDef dcpd = droidRecord.defAsDroidDef; if (dcpd == null) { throw new InvalidOperationException($"{partRecord.body.defName} contains a bodypart which is not type DroidChassisPartDef: {partRecord.def.defName}"); } var newPCP = new PartCustomisePack(li.ChassisPoint, dcpd, droidRecord.bodyPosition); list.Add(newPCP); } } else { //Otherwise, just make a new part with undefined body position DroidChassisPartDef dcpd = partRecord.GetChassisPartDef(); if (dcpd == null) { throw new InvalidOperationException($"{partRecord.body.defName} contains a bodypart which is not type DroidChassisPartDef: {partRecord.def.defName}"); } var newPCP = new PartCustomisePack(li.ChassisPoint, dcpd); list.Add(newPCP); } } } else { if (!silentFail) { Log.Error($"Unable to find any base parts at ChassisPoint: {li.ChassisPoint} and BodyPosition: {li.BodyPosition} for BaseBodyDef: {BaseBodyDef.defName}"); } } } partsGrouped.Add(group, list); return(partsGrouped[group]); } else { return(partsGrouped[group]); } }
private void DrawEntry(DroidChassisPartDef d, Rect rect, bool alternate, string label = "") { string labelToUse = label.NullOrEmpty() ? d.LabelCap : label; if (d == selPart) { Widgets.DrawHighlightSelected(rect); if (Mouse.IsOver(rect)) { TooltipHandler.TipRegion(rect, d.GetTooltip()); } } else if (Mouse.IsOver(rect)) { Widgets.DrawHighlight(rect); TooltipHandler.TipRegion(rect, d.GetTooltip()); } else if (alternate) { Widgets.DrawAltRect(rect); } if (Widgets.ButtonInvisible(rect)) { selPart = d; } Text.Anchor = TextAnchor.MiddleLeft; if (d.color != null) { GUI.color = d.color.GetColor(); } Widgets.Label(rect, labelToUse); Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; }
public void CopyFrom(PartCustomisePack pack) { chassisPoint = pack.ChassisPoint; bodyPosition = pack.BodyPosition; part = pack.Part; }
public PartCustomisePack(ChassisPoint cp, DroidChassisPartDef part = null, BodyPosition position = BodyPosition.Undefined) { chassisPoint = cp; this.part = part; bodyPosition = position; }