Ejemplo n.º 1
0
        /// <summary>
        /// Applies the special properties to the slot loadable.
        /// </summary>
        /// <param name="__instance"></param>
        /// <param name="dinfo"></param>
        /// <param name="totalDamageDealt"></param>
        public static void PostApplyDamage_PostFix(Pawn __instance, DamageInfo dinfo, float totalDamageDealt)
        {
            if (__instance == null)
            {
                return;
            }
            if (__instance.Dead || __instance.equipment == null)
            {
                return;
            }
            ThingWithComps thingWithComps = __instance.equipment.Primary;

            if (thingWithComps != null)
            {
                ThingComp comp = thingWithComps.AllComps.FirstOrDefault((ThingComp x) => x is CompSlotLoadable);
                if (comp != null)
                {
                    CompSlotLoadable compSlotLoadable = comp as CompSlotLoadable;
                    if (compSlotLoadable.Slots != null && compSlotLoadable.Slots.Count > 0)
                    {
                        foreach (SlotLoadable slot in compSlotLoadable.Slots)
                        {
                            if (!slot.IsEmpty())
                            {
                                CompSlottedBonus slotBonus = slot.SlotOccupant.TryGetComp <CompSlottedBonus>();
                                if (slotBonus != null)
                                {
                                    if (slotBonus.Props != null)
                                    {
                                        SlotBonusProps_DefensiveHealChance defensiveHealChance = slotBonus.Props.defensiveHealChance;
                                        if (defensiveHealChance != null)
                                        {
                                            //Log.Message("defensiveHealingCalled");
                                            float randValue = Rand.Value;
                                            //Log.Message("randValue = " + randValue.ToString());
                                            if (randValue <= defensiveHealChance.chance)
                                            {
                                                MoteMaker.ThrowText(__instance.DrawPos, __instance.Map, "Heal Chance: Success", 6f);
                                                ApplyHealing(__instance, defensiveHealChance.woundLimit);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        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());
        }