Esempio n. 1
0
        public static void Postfix(ref IEnumerable <Gizmo> __result, ref Pawn_DraftController __instance)
        {
            if (!Main.Instance.IsModEnabled())
            {
                return;
            }

            if (Find.CurrentMap == null || Find.World == null || Find.World.renderer == null ||
                Find.World.renderer.wantedMode == WorldRenderMode.Planet)
            {
                return;
            }

            if (__result == null || !__result.Any())
            {
                return;
            }

            var extendedDataStore = Main.Instance.GetExtendedDataStorage();
            var pawn = __instance.pawn;

            if (!extendedDataStore.CanTrackPawn(pawn))
            {
                return;
            }

            if (!FireConeOverlay.HasValidWeapon(pawn))
            {
                return;
            }

            var pawnData = extendedDataStore.GetExtendedDataFor(pawn);

            var gizmoList = __result.ToList();
            var ourGizmo  = new Command_Toggle
            {
                defaultLabel = "Avoid Friendly Fire",
                icon         = Resources.FriendlyFireIcon,
                isActive     = () => pawnData.AvoidFriendlyFire,
                toggleAction = () => pawnData.AvoidFriendlyFire = !pawnData.AvoidFriendlyFire
            };

            gizmoList.Add(ourGizmo);
            __result = gizmoList;
        }
Esempio n. 2
0
        public bool ShouldPawnAvoidFriendlyFire(Pawn pawn)
        {
            if (!CanTrackPawn(pawn))
            {
                return(false);
            }

            if (!GetExtendedDataFor(pawn).AvoidFriendlyFire)
            {
                return(false);
            }

            if (!FireConeOverlay.HasValidWeapon(pawn))
            {
                return(false);
            }

            return(true);
        }