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; }
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); }
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); }
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); }
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; }
public override void PostSpawnSetup(bool respawningAfterLoad) { base.PostSpawnSetup(respawningAfterLoad); powerComp = parent.GetComp <CompPowerTrader>(); forbiddable = parent.GetComp <CompForbiddable>(); }