public virtual string SlotDesc(SlotLoadable slot) { var s = new StringBuilder(); s.AppendLine(slot.def.description); //TODO if (!slot.IsEmpty()) { s.AppendLine(); s.AppendLine(string.Format(StringOf.CurrentlyLoaded, new object[] { slot.SlotOccupant.LabelCap })); if (((SlotLoadableDef)slot.def).doesChangeColor) { s.AppendLine(); s.AppendLine(StringOf.Effects); s.AppendLine(" " + StringOf.ChangesPrimaryColor); } if (((SlotLoadableDef)slot.def).doesChangeStats) { var slotBonus = slot.SlotOccupant.TryGetComp <CompSlottedBonus>(); if (slotBonus != null) { if (slotBonus.Props != null) { if (slotBonus.Props.statModifiers != null && slotBonus.Props.statModifiers.Count > 0) { s.AppendLine(); s.AppendLine(StringOf.StatModifiers); foreach (var mod in slotBonus.Props.statModifiers) { var v = SlotLoadableUtility.DetermineSlottableStatAugment(slot.SlotOccupant, mod.stat); var modstring = mod.stat.ValueToString(v, ToStringNumberSense.Offset); //Log.Message("Determined slot stat augment "+v+" and made string "+modstring); s.AppendLine(" " + mod.stat.LabelCap + " " + modstring); //s.AppendLine("\t" + mod.stat.LabelCap + " " + mod.ToStringAsOffset); } /* * //Log.Message("fix this to display statModifiers"); * List<StatModifier> statMods = slot.SlotOccupant.def.statBases.FindAll( * (StatModifier z) => z.stat.category == StatCategoryDefOf.Weapon || * z.stat.category == StatCategoryDefOf.EquippedStatOffsets); * if (statMods != null && statMods.Count > 0) * { * s.AppendLine(); * s.AppendLine("StatModifiers".Translate() + ":"); * foreach (StatModifier mod in statMods) * { * s.AppendLine("\t" + mod.stat.LabelCap + " " + mod.ToStringAsOffset); * } * } */ } var damageDef = slotBonus.Props.damageDef; if (damageDef != null) { s.AppendLine(); s.AppendLine(string.Format(StringOf.DamageType, new object[] { damageDef.LabelCap })); } var defHealChance = slotBonus.Props.defensiveHealChance; if (defHealChance != null) { var healText = StringOf.all; if (defHealChance.woundLimit != 0) { healText = defHealChance.woundLimit.ToString(); } s.AppendLine(" " + string.Format(StringOf.DefensiveHealChance, new object[] { healText, defHealChance.chance.ToStringPercent() })); } var vampChance = slotBonus.Props.vampiricHealChance; if (vampChance != null) { var vampText = StringOf.all; if (vampChance.woundLimit != 0) { vampText = defHealChance.woundLimit.ToString(); } s.AppendLine(" " + string.Format(StringOf.VampiricChance, new object[] { vampText, vampChance.chance.ToStringPercent() })); } } } } } return(s.ToString()); }
public void ProcessInput(SlotLoadable slot) { var loadTypes = new List <ThingDef>(); var floatList = new List <FloatMenuOption>(); if (!isGathering) { var map = GetMap; loadTypes = slot.SlottableTypes; if (slot.SlotOccupant == null) { if (loadTypes != null) { if (loadTypes.Count != 0) { foreach (var current in loadTypes) { var thingsWithDef = new List <Thing>(map.listerThings.AllThings.FindAll(x => x.def == current)); if (thingsWithDef != null) { if (thingsWithDef.Count > 0) { var thingToLoad = thingsWithDef.FirstOrDefault(x => map.reservationManager.CanReserve(GetPawn, x)); if (thingToLoad != null) { var text = "Load".Translate() + " " + thingToLoad.def.label; //Func<Rect, bool> extraPartOnGUI = (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, current); floatList.Add(new FloatMenuOption(text, delegate { TryGiveLoadSlotJob(thingToLoad); }, MenuOptionPriority.Default, null, null, 29f, null, null)); } else { floatList.Add(new FloatMenuOption( string.Format(StringOf.Unavailable, new object[] { current.label }), delegate { }, MenuOptionPriority.Default)); } } else { floatList.Add(new FloatMenuOption( string.Format(StringOf.Unavailable, new object[] { current.label }), delegate { }, MenuOptionPriority.Default)); } } else { floatList.Add(new FloatMenuOption( string.Format(StringOf.Unavailable, new object[] { current.label }), delegate { }, MenuOptionPriority.Default)); } } } else { floatList.Add(new FloatMenuOption(StringOf.NoLoadOptions, delegate { }, MenuOptionPriority.Default)); } } } } if (!slot.IsEmpty()) { var text = string.Format(StringOf.Unload, new object[] { slot.SlotOccupant.Label }); //Func<Rect, bool> extraPartOnGUI = (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, current); floatList.Add(new FloatMenuOption(text, delegate { TryEmptySlot(slot); }, MenuOptionPriority.Default, null, null, 29f, null, null)); } Find.WindowStack.Add(new FloatMenu(floatList)); }