Пример #1
0
        public static void AddHumanlikeOrders_PostFix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
        {
            var c = IntVec3.FromVector3(clickPos);

            var slotLoadable =
                pawn.equipment.AllEquipmentListForReading.FirstOrDefault(x => x.TryGetCompFast <OgsCompSlotLoadable.CompSlotLoadable>() != null);

            if (slotLoadable != null)
            {
                CompSlotLoadable compSlotLoadable = slotLoadable.GetComp <OgsCompSlotLoadable.CompSlotLoadable>();
                if (compSlotLoadable != null && compSlotLoadable.QualityReqMet)
                {
                    var thingList = c.GetThingList(pawn.Map);

                    foreach (var slot in compSlotLoadable.Slots)
                    {
                        var loadableThing = thingList.FirstOrDefault(y => slot.CanLoad(y.def));
                        if (loadableThing != null)
                        {
                            FloatMenuOption itemSlotLoadable;
                            var             labelShort = loadableThing.Label;
                            if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
                            {
                                itemSlotLoadable = new FloatMenuOption(
                                    "CannotEquip".Translate(labelShort) + " (" + "Incapable".Translate() + ")", null,
                                    MenuOptionPriority.Default, null, null, 0f, null, null);
                            }
                            else if (!pawn.CanReach(loadableThing, PathEndMode.ClosestTouch, Danger.Deadly))
                            {
                                itemSlotLoadable = new FloatMenuOption(
                                    "CannotEquip".Translate(labelShort) + " (" + "NoPath".Translate() + ")", null,
                                    MenuOptionPriority.Default, null, null, 0f, null, null);
                            }
                            else if (!pawn.CanReserve(loadableThing, 1))
                            {
                                itemSlotLoadable = new FloatMenuOption(
                                    "CannotEquip".Translate(labelShort) + " (" +
                                    "ReservedBy".Translate(pawn.Map.physicalInteractionReservationManager
                                                           .FirstReserverOf(loadableThing).LabelShort) + ")", null,
                                    MenuOptionPriority.Default, null, null, 0f, null, null);
                            }
                            else
                            {
                                var text2 = "Equip".Translate(labelShort);
                                itemSlotLoadable = new FloatMenuOption(text2, delegate
                                {
                                    loadableThing.SetForbidden(false, true);
                                    pawn.jobs.TryTakeOrderedJob(new Job(DefDatabase <JobDef> .GetNamed("AdeptusMechanicusGatherSlotItem"),
                                                                        loadableThing));
                                    MoteMaker.MakeStaticMote(loadableThing.DrawPos, loadableThing.Map,
                                                             ThingDefOf.Mote_FeedbackEquip, 1f);
                                    //PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total);
                                }, MenuOptionPriority.High, null, null, 0f, null, null);
                            }
                            opts.Add(itemSlotLoadable);
                        }
                    }
                }
            }
        }
Пример #2
0
        // debugging

        /*
         * public static void TicksPerMove_PostFix(Pawn __instance, ref float __result, bool diagonal) {
         *  if ( __instance.IsColonist )  {
         *      float num = __instance.GetStatValue(StatDefOf.MoveSpeed, true);
         *  //    Log.Message("move speed : "+__instance.Name+ " : (GetStatValue of MoveSpeed:" +num+") (TicksPerMove:"+__result+")");
         *  }
         * } */

        public static void PrimaryVerb_PostFix(CompEquippable __instance, ref Verb __result)
        {
            CompSlotLoadable slotLoadable = __instance.parent.TryGetCompFast <OgsCompSlotLoadable.CompSlotLoadable>();

            if (slotLoadable != null)
            {
                foreach (SlotLoadable slot in slotLoadable.Slots)
                {
                    if (slot.SlotOccupant != null)
                    {
                        SlottedBonusExtension bonus = slot.SlotOccupant.def.GetModExtension <SlottedBonusExtension>();
                        if (bonus.verbReplacer != null)
                        {
                            __result.verbProps = bonus.verbReplacer;
                            return;
                        }
                    }
                }
                if (__result.verbProps.LaunchesProjectile && __result.verbProps != __instance.parent.def.Verbs[0])
                {
                    __result.verbProps = __instance.parent.def.Verbs[0];
                }
            }
        }