예제 #1
0
        public static void Postfix(Vector3 clickPos, Pawn pawn, ref List <FloatMenuOption> opts)
        {
            IntVec3 c = IntVec3.FromVector3(clickPos);

            foreach (Pair <CompTurret, Thing> pair in CompTurretReloadableUtility.FindPotentiallyReloadableGear(pawn, c.GetThingList(pawn.Map)))
            {
                CompTurretGun comp   = pair.First as CompTurretGun;
                Thing         second = pair.Second;
                string        text4  = "Reload".Translate(comp.parent.Named("GEAR"), comp.AmmoDef.Named("AMMO")) + " (" + comp.LabelRemaining + ")";
                List <Thing>  chosenAmmo;
                if (!pawn.CanReach(second, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
                {
                    opts.Add(new FloatMenuOption(text4 + ": " + "NoPath".Translate().CapitalizeFirst(), null, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                else if (!comp.NeedsReload(true))
                {
                    opts.Add(new FloatMenuOption(text4 + ": " + "ReloadFull".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                else if ((chosenAmmo = CompTurretReloadableUtility.FindEnoughAmmo(pawn, second.Position, comp, true)) == null)
                {
                    opts.Add(new FloatMenuOption(text4 + ": " + "ReloadNotEnough".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null));
                }
                else
                {
                    Action action4 = delegate()
                    {
                        pawn.jobs.TryTakeOrderedJob(JobGiver_ReloadCompTurret.MakeReloadJob(comp, chosenAmmo), JobTag.Misc);
                    };
                    opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text4, action4, MenuOptionPriority.Default, null, null, 0f, null, null), pawn, second, "ReservedBy"));
                }
            }
        }
        public static void Postfix(Apparel __instance, DamageInfo dinfo, ref bool __result)
        {
            if (__instance == null)
            {
                return;
            }
            CompTurret apparel_Turret = __instance.TryGetComp <CompTurret>();

            if (apparel_Turret != null)
            {
                if (dinfo.Def == DamageDefOf.EMP)
                {
                    foreach (ThingComp item in __instance.AllComps)
                    {
                        CompTurretGun Turret = item as CompTurretGun;
                        if (Turret != null && Turret.AffectedByEMP)
                        {
                            Turret.stunTicksLeft += Mathf.RoundToInt(dinfo.Amount * 30f);
                            Turret.stunFromEMP    = true;
                            //    Log.Message(Turret.gun.Label + " turret hit by EMP, disabling for " + Mathf.RoundToInt(dinfo.Amount * 30f) + " ticks, Total: "+ Turret.stunTicksLeft);
                        }
                    }
                }
            }
        }