Ejemplo n.º 1
0
    internal static bool ProspectSuccess(Pawn p, out float radius)
    {
        var skill = Math.Min(20, p.skills.GetSkill(SkillDefOf.Mining).Level);

        radius = Mathf.Lerp(50f, 100f, Math.Min(0f, (20f - skill) / 20f));
        var chance = Math.Max(1, (int)(skill * (Controller.Settings.BaseChance / 100f)));

        return(ProspectingUtility.Rnd100() <= chance);
    }
Ejemplo n.º 2
0
    public void CheckBreakdown(Thing WideBoy)
    {
        if (Find.TickManager.TicksGame <= lastBreakCheck)
        {
            return;
        }

        lastBreakCheck = Find.TickManager.TicksGame + ProspectingUtility.RndBits(7500, 90000);
        var miningSkill = 0;

        if (lastDriller > 0)
        {
            var interactCell = WideBoy.InteractionCell;
            if (WideBoy.Map != null)
            {
                var list = interactCell.GetThingList(WideBoy.Map);
                if (list.Count > 0)
                {
                    foreach (var thing in list)
                    {
                        if (thing is not Pawn pawn || pawn.thingIDNumber != lastDriller)
                        {
                            continue;
                        }

                        miningSkill = Math.Max(0,
                                               Math.Min(20, pawn.skills.GetSkill(SkillDefOf.Mining).Level));
                        break;
                    }
                }
            }
        }

        var breakChance = 20 - (int)(miningSkill / 2f);

        if (ProspectingUtility.Rnd100() >= breakChance || WideBoy.IsBrokenDown())
        {
            return;
        }

        var compBreak = WideBoy.TryGetComp <CompBreakdownable>();

        compBreak?.DoBreakdown();
    }
Ejemplo n.º 3
0
    public static void PostFix(ref Mineable __instance, Map map, float yieldChance, bool moteOnWaste, Pawn pawn)
    {
        if (map == null || pawn == null || !ProspectingUtility.IsValidToIndicate(__instance, map))
        {
            return;
        }

        var mining      = 0;
        var skills      = pawn.skills;
        var miningSkill = skills?.GetSkill(SkillDefOf.Mining) != null;

        if (miningSkill)
        {
            mining = pawn.skills.GetSkill(SkillDefOf.Mining).Level / 4;
        }

        var chance = (int)(Controller.Settings.BaseChance + mining);

        if (ProspectingUtility.Rnd100() <= chance &&
            ProspectingUtility.ProspectCandidate(map, __instance.Position, out var def))
        {
            ProspectingUtility.YieldExtra(pawn, def);
        }
    }