public static void get_Graphic_PostFix(Thing __instance, ref Graphic __result) { ThingWithComps thingWithComps = __instance as ThingWithComps; if (thingWithComps != null) { //Log.Message("3"); CompSlotLoadable CompSlotLoadable = thingWithComps.GetComp <CompSlotLoadable>(); if (CompSlotLoadable != null) { //ThingComp activatableEffect = thingWithComps.AllComps.FirstOrDefault<ThingComp>((ThingComp y) => y.GetType().ToString() == "CompActivatableEffect.CompActivatableEffect"); SlotLoadable slot = CompSlotLoadable.ColorChangingSlot; if (slot != null) { if (!slot.IsEmpty()) { CompSlottedBonus slotBonus = slot.SlotOccupant.TryGetComp <CompSlottedBonus>(); if (slotBonus != null) { //if (activatableEffect != null) //{ // AccessTools.Field(activatableEffect.GetType(), "overrideColor").SetValue(activatableEffect, slot.SlotOccupant.DrawColor); // Log.ErrorOnce("GraphicPostFix_Called_Activatable", 1866); //} //else //{ Graphic tempGraphic = (Graphic)AccessTools.Field(typeof(Thing), "graphicInt").GetValue(__instance); if (tempGraphic != null) { if (tempGraphic.Shader != null) { tempGraphic = tempGraphic.GetColoredVersion(tempGraphic.Shader, slotBonus.Props.color, slotBonus.Props.color); //slot.SlotOccupant.DrawColor; __result = tempGraphic; //Log.Message("SlotLoadableDraw"); } } } //Log.ErrorOnce("GraphicPostFix_Called_5", 1866); //} } } } } }
public static void DrawColorTwoPostFix(Thing __instance, ref Color __result) { if (__instance is ThingWithComps thingWithComps) { //Log.Message("3"); CompSlotLoadable CompSlotLoadable = thingWithComps.GetComp <CompSlotLoadable>(); if (CompSlotLoadable != null) { SlotLoadable slot = CompSlotLoadable.SecondColorChangingSlot; if (slot != null) { if (!slot.IsEmpty()) { __result = slot.SlotOccupant.DrawColor; __instance.Graphic.colorTwo = slot.SlotOccupant.DrawColor; } } } } }
public virtual string SlotDesc(SlotLoadable slot) { StringBuilder s = new StringBuilder(); s.AppendLine(slot.GetDescription()); 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) { CompSlottedBonus 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 (StatModifier mod in slotBonus.Props.statModifiers) { float v = DetermineSlottableStatAugment(slot.SlotOccupant, mod.stat); string 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); * } * } */ } DamageDef damageDef = slotBonus.Props.damageDef; if (damageDef != null) { s.AppendLine(); s.AppendLine(string.Format(StringOf.DamageType, new object[] { damageDef.LabelCap })); } SlotBonusProps_DefensiveHealChance defHealChance = slotBonus.Props.defensiveHealChance; if (defHealChance != null) { string healText = StringOf.all; if (defHealChance.woundLimit != 0) { healText = defHealChance.woundLimit.ToString(); } s.AppendLine(" " + string.Format(StringOf.DefensiveHealChance, new object[] { healText, defHealChance.chance.ToStringPercent() })); } SlotBonusProps_VampiricEffect vampChance = slotBonus.Props.vampiricHealChance; if (vampChance != null) { string 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) { List <ThingDef> loadTypes = new List <ThingDef>(); List <FloatMenuOption> floatList = new List <FloatMenuOption>(); if (!this.isGathering) { Map map = this.GetMap; loadTypes = slot.SlottableTypes; if (slot.SlotOccupant == null) { if (loadTypes != null) { if (loadTypes.Count != 0) { foreach (ThingDef current in loadTypes) { List <Thing> thingsWithDef = new List <Thing>(map.listerThings.AllThings.FindAll((Thing x) => x.def == current)); if (thingsWithDef != null) { if (thingsWithDef.Count > 0) { Thing thingToLoad = thingsWithDef.FirstOrDefault((Thing x) => map.reservationManager.CanReserve(this.GetPawn, x)); if (thingToLoad != null) { string 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 { this.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)); } } } } else { //TryCancel(); } if (!slot.IsEmpty()) { string 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)); }