コード例 #1
0
        public static bool HasKeycardAccess(this Thing t, Pawn pawn)
        {
            if (Faction.OfPlayer is null)
            {
                return(false);
            }
            if (Faction.OfPlayer != t.Faction)
            {
                return(false);
            }
            if (!pawn.RaceProps.Humanlike)
            {
                return(false);
            }
            if (!(t as ThingWithComps).GetComp <CompPowerTrader>().PowerOn)
            {
                return(false);
            }
            ThingWithComps thingWithComps = t as ThingWithComps;

            if (thingWithComps is null)
            {
                return(true);
            }
            CompKeycard comp = thingWithComps.GetComp <CompKeycard>();

            if (comp.Locked)
            {
                return(false);
            }
            return(comp.Level <= pawn.def.GetModExtension <KeycardHandler>().AccessLevel ? true : false);
        }
コード例 #2
0
        public static void SetKeycard(this Thing t, int value, bool warnOnFail = true)
        {
            if (t is null)
            {
                if (warnOnFail)
                {
                    Log.Error("Tried to Set Keycard on null Thing.", false);
                }
                return;
            }
            ThingWithComps thing = t as ThingWithComps;

            if (thing is null)
            {
                if (warnOnFail)
                {
                    Log.Error("Tried to Set Keycard on non-ThingWithComps Thing " + t, false);
                }
                return;
            }
            CompKeycard comp = thing.GetComp <CompKeycard>();

            if (comp is null)
            {
                if (warnOnFail)
                {
                    Log.Error("Tried to Set Keycard on non-Keycard thing " + t, false);
                }
                return;
            }
            comp.Level = value;
        }
コード例 #3
0
ファイル: HarmonyPatches.cs プロジェクト: dninemfive/SCP
 public static bool EnterRoomKeycard(Thing t, Pawn pawn, ref bool __result)
 {
     if (t.Spawned && !((t as Building_Door) is null))
     {
         CompKeycard key = (t as ThingWithComps).GetComp <CompKeycard>();
         __result = !(key is null);
         return(false);
     }
     return(true);
 }
コード例 #4
0
ファイル: HarmonyPatches.cs プロジェクト: dninemfive/SCP
 public static bool EnterCellKeycard(Thing t, Faction faction, ref bool __result)
 {
     if (!((t as ThingWithComps) is null))
     {
         Building_Door b = t as Building_Door;
         if (!(b is null) && !((t as ThingWithComps).GetComp <CompKeycard>() is null))
         {
             CompKeycard key = (t as ThingWithComps).GetComp <CompKeycard>();
             __result = !(key is null);
             return(false);
         }
     }
     return(true);
 }