예제 #1
0
        public static void SetForbidden(this Thing t, bool value, bool warnOnFail = true)
        {
            if (t == null)
            {
                if (warnOnFail)
                {
                    Log.Error("Tried to SetForbidden on null Thing.", false);
                }
                return;
            }
            ThingWithComps thingWithComps = t as ThingWithComps;

            if (thingWithComps == null)
            {
                if (warnOnFail)
                {
                    Log.Error("Tried to SetForbidden on non-ThingWithComps Thing " + t, false);
                }
                return;
            }
            CompForbiddable comp = thingWithComps.GetComp <CompForbiddable>();

            if (comp == null)
            {
                if (warnOnFail)
                {
                    Log.Error("Tried to SetForbidden on non-Forbiddable Thing " + t, false);
                }
                return;
            }
            comp.Forbidden = value;
        }
예제 #2
0
        public static bool IsForbidden(this Thing t, Faction faction)
        {
            bool result;

            if (faction == null)
            {
                result = false;
            }
            else if (faction != Faction.OfPlayer)
            {
                result = false;
            }
            else
            {
                ThingWithComps thingWithComps = t as ThingWithComps;
                if (thingWithComps == null)
                {
                    result = false;
                }
                else
                {
                    CompForbiddable comp = thingWithComps.GetComp <CompForbiddable>();
                    result = (comp != null && comp.Forbidden);
                }
            }
            return(result);
        }
예제 #3
0
        public override AcceptanceReport CanDesignateThing(Thing t)
        {
            if (t.def.category != ThingCategory.Item)
            {
                return(false);
            }
            CompForbiddable compForbiddable = t.TryGetComp <CompForbiddable>();

            return(compForbiddable != null && !compForbiddable.Forbidden);
        }
        public override AcceptanceReport CanDesignateThing(Thing t)
        {
            AcceptanceReport result;

            if (t.def.category != ThingCategory.Item)
            {
                result = false;
            }
            else
            {
                CompForbiddable compForbiddable = t.TryGetComp <CompForbiddable>();
                result = (compForbiddable != null && !compForbiddable.Forbidden);
            }
            return(result);
        }
예제 #5
0
        public static bool IsForbidden(this Thing t, Faction faction)
        {
            if (faction == null)
            {
                return(false);
            }
            if (faction != Faction.OfPlayer)
            {
                return(false);
            }
            ThingWithComps thingWithComps = t as ThingWithComps;

            if (thingWithComps == null)
            {
                return(false);
            }
            CompForbiddable comp = thingWithComps.GetComp <CompForbiddable>();

            return(comp != null && comp.Forbidden);
        }
예제 #6
0
        public static void SetForbidden(this Thing t, bool value, bool warnOnFail = true)
        {
            if (t == null)
            {
                if (warnOnFail)
                {
                    Log.Error("Tried to SetForbidden on null Thing.");
                }
                return;
            }

            ThingWithComps twc = t as ThingWithComps;

            if (twc == null)
            {
                if (warnOnFail)
                {
                    Log.Error("Tried to SetForbidden on non-ThingWithComps Thing " + t);
                }
                return;
            }

            CompForbiddable f = twc.GetComp <CompForbiddable>();

            if (f == null)
            {
                if (warnOnFail)
                {
                    Log.Error("Tried to SetForbidden on non-Forbiddable Thing " + t);
                }

                return;
            }

            f.Forbidden = value;
        }
예제 #7
0
 public override void PostSpawnSetup(bool respawningAfterLoad)
 {
     base.PostSpawnSetup(respawningAfterLoad);
     powerComp   = parent.GetComp <CompPowerTrader>();
     forbiddable = parent.GetComp <CompForbiddable>();
 }