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 Hediff BuildHediff(PartCustomisePack pack, BodyPartRecord rec, Droid d) { Hediff_DroidStatsApplier hediff = (Hediff_DroidStatsApplier)HediffMaker.MakeHediff(DroidsDefOf.MD3_DroidStatsApplier, d, rec); HediffStageSaveable stage = new HediffStageSaveable(); stage.statOffsets = new List <StatModifier>(); hediff.AddedPartHealth = pack.Part.addedPartHealth; if (pack.Part.statOffsets != null && pack.Part.statOffsets.Count > 0) { stage.statOffsets.AddRange(pack.Part.statOffsets); } if (pack.Part.requirements != null && pack.Part.requirements.Count > 0) { stage.statOffsets.AddRange(pack.Part.requirements); } if (pack.Part.capMods.Count > 0) { foreach (var capMod in pack.Part.capMods) { stage.capMods.Add(capMod); } } hediff.Stage = stage; hediff.label = pack.Part.LabelCap; return(hediff); }
public override bool Equals(object obj) { if (obj is PartCustomisePack) { PartCustomisePack pack = obj as PartCustomisePack; return(ChassisPoint == pack.ChassisPoint && BodyPosition == pack.BodyPosition && Part == pack.Part); } return(false); }
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 Setup() { List <PartCustomisePack> list = design.GetPartCustomisePacks(group).ToList(); if (list.Count > 0) { int count = Mathf.Min(6, list.Count); //Initialise the values of each slot for (int i = 0; i < count; i++) { switch (i) { case 0: Slot1 = list[i]; Slot1Temp = Slot1.CreateCopy(); break; case 1: Slot2 = list[i]; Slot2Temp = Slot2.CreateCopy(); break; case 2: Slot3 = list[i]; Slot3Temp = Slot3.CreateCopy(); break; case 3: Slot4 = list[i]; Slot4Temp = Slot4.CreateCopy(); break; case 4: Slot5 = list[i]; Slot5Temp = Slot5.CreateCopy(); break; case 5: Slot6 = list[i]; Slot6Temp = Slot6.CreateCopy(); break; default: break; } } } }
public static void DrawSlot(PartCustomisePack slot, Rect rect, ChassisType ct, BlueprintHandlerState state) { try { GUI.BeginGroup(rect); Rect slotRect = new Rect(rect.width / 2 - SlotRectSize.x / 2, 0f, SlotRectSize.x, SlotRectSize.y); if (Mouse.IsOver(slotRect)) { Widgets.DrawHighlightSelected(slotRect); TooltipHandler.TipRegion(slotRect, slot.Part.GetTooltip()); } else { Widgets.DrawHighlight(slotRect); } Widgets.DrawBox(slotRect); Rect imageRect = new Rect(slotRect.center.x - IconRectSize.x / 2, slotRect.center.y - IconRectSize.y / 2, IconRectSize.x, IconRectSize.y); Widgets.DrawTextureFitted(imageRect, DefaultSlotIcon, 1f);//TODO:: show slot icon Rect labelRect = new Rect(0f, SlotRectSize.y, rect.width, SlotLabelHeight); Text.Anchor = TextAnchor.MiddleCenter; if (slot.Part.color != null) { GUI.color = slot.Part.color.GetColor(); } Widgets.Label(labelRect, slot.Part.LabelCap); GUI.color = Color.white; if (state == BlueprintHandlerState.New || state == BlueprintHandlerState.Edit) { if (Widgets.ButtonInvisible(slotRect)) { Dialog_SelectPart sp = new Dialog_SelectPart(slot, ct); Find.WindowStack.Add(sp); } } } finally { Text.Anchor = TextAnchor.UpperLeft; GUI.EndGroup(); } }
public void CopyFrom(PartCustomisePack pack) { chassisPoint = pack.ChassisPoint; bodyPosition = pack.BodyPosition; part = pack.Part; }
public GroupPackPair(DroidCustomiseGroupDef group, PartCustomisePack pack) { this.group = group; this.pack = pack; }