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

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

            if (comp == null)
            {
                return(false);
            }
            comp.Forbidden = value;
            return(false);
        }
 public static void set_Forbidden(CompForbiddable __instance, bool value)
 {
     if (__instance.parent.Map != null)
     {
         HaulingCache.ReregisterHaulableItem(__instance.parent);
     }
 }
Esempio n. 3
0
 public static bool DontDrawInvisDoorForbiddenIcons(CompForbiddable __instance)
 {
     if (__instance.parent is Building_DoorRegionHandler)
     {
         return(false);
     }
     return(true);
 }
Esempio n. 4
0
 static bool Prefix(ref CompForbiddable __instance, ref IEnumerable <Gizmo> __result)
 {
     if (__instance.Forbidden && __instance.parent.IsOwnedByCity())
     {
         __result = Enumerable.Empty <Gizmo>();
         return(false);
     }
     return(true);
 }
Esempio n. 5
0
        // Token: 0x0600002E RID: 46 RVA: 0x00003004 File Offset: 0x00001204
        public virtual bool IsForbidden()
        {
            if (this == null)
            {
                return(false);
            }
            CompForbiddable comp = GetComp <CompForbiddable>();

            return(comp != null && comp.Forbidden);
        }
Esempio n. 6
0
        public override AcceptanceReport CanDesignateThing(Thing t)
        {
            bool validBlueprint = (t.def.IsBlueprint || t.def.IsFrame) && t.Faction == Faction.OfPlayer;

            if (!validBlueprint)
            {
                return(false);
            }

            CompForbiddable compForbiddable = t.TryGetComp <CompForbiddable>();

            return(compForbiddable != null && !compForbiddable.Forbidden);
        }
Esempio n. 7
0
        public override void SpawnSetup(Map map, bool respawningAfterLoad)
        {
            base.SpawnSetup(map, respawningAfterLoad);
            compRefuelable = GetComp <CompRefuelable>();
            forbiddable    = GetComp <CompForbiddable>();
            fillpct        = 0;
            histolysisPct  = 0;
            BioReactorDef reactorDef = def as BioReactorDef;

            if (reactorDef != null)
            {
                innerDrawOffset = ((BioReactorDef)def).innerDrawOffset;
                waterDrawCenter = ((BioReactorDef)def).waterDrawCenter;
                waterDrawOffset = ((BioReactorDef)def).waterDrawOffset;
            }
        }
Esempio n. 8
0
        public static void SpawnDoorAt(IntVec3 position, ref OG_OutpostData outpostData)
        {
            ThingDef autodoorDef = OG_Util.FireproofAutodoorDef;
            Building edifice     = position.GetEdifice();

            if ((edifice != null) &&
                (edifice.def == autodoorDef))
            {
                // Avoid spawning another door on the same spot. This creates troubles with region links...
                return;
            }
            Thing           door            = OG_Common.TrySpawnThingAt(autodoorDef, ThingDefOf.Steel, position, false, Rot4.North, ref outpostData, false, true);
            CompForbiddable compForbiddable = door.TryGetComp <CompForbiddable>();

            if (compForbiddable != null)
            {
                compForbiddable.Forbidden = true; // Avoid colonists going into outpost at start-up.
            }
        }
Esempio n. 9
0
 public override void ExposeData()
 {
     base.ExposeData();
     Scribe_Values.Look <ReactorState>(ref state, "state");
     Scribe_Values.Look <float>(ref fillpct, "fillpct");
     Scribe_Values.Look <float>(ref histolysisPct, "histolysisPct");
     if (Scribe.mode == LoadSaveMode.PostLoadInit)
     {
         BioReactorDef reactorDef = def as BioReactorDef;
         if (reactorDef != null)
         {
             innerDrawOffset = ((BioReactorDef)def).innerDrawOffset;
             waterDrawCenter = ((BioReactorDef)def).waterDrawCenter;
             waterDrawOffset = ((BioReactorDef)def).waterDrawOffset;
         }
     }
     compRefuelable = GetComp <CompRefuelable>();
     forbiddable    = GetComp <CompForbiddable>();
 }
Esempio n. 10
0
    public static void SetForbidden(this Thing t, bool value)
    {
        ThingWithComponents twc = t as ThingWithComponents;

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

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

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

        f.forbidden = value;
    }
Esempio n. 11
0
        static void Prefix(CompForbiddable __instance, Thing ___parent, bool value)
        {
            if (Multiplayer.Client == null)
            {
                return;
            }
            if (Multiplayer.ShouldSync)
            {
                return;                         // Will get synced
            }
            bool changed = false;

            if (Multiplayer.Client != null && ___parent.Spawned)
            {
                var set = ___parent.Map.MpComp().GetCurrentCustomFactionData().unforbidden;
                changed = value ? set.Remove(___parent) : set.Add(___parent);
            }

            // After the prefix the method early returns if (value == forbiddenInt)
            // Setting forbiddenInt to !value forces an update (prevents the early return)
            __instance.forbiddenInt = changed ? !value : value;
        }
Esempio n. 12
0
    public static bool IsForbidden(this Thing t)
    {
        ThingWithComponents twc = t as ThingWithComponents;

        if (twc == null)
        {
            return(false);
        }

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

        if (f == null)
        {
            return(false);
        }

        if (f.forbidden)
        {
            return(true);
        }

        return(false);
    }
 public static IEnumerable <FloatMenuOption> ExtraFloatMenuOptions(this Droid droid, IntVec3 sq, IEnumerable <FloatMenuOption> options)
 {
     foreach (var thing in sq.GetThingList())
     {
         CompMannable mannable = thing.TryGetComp <CompMannable>();
         if (mannable != null && !mannable.MannedNow)
         {
             yield return(new FloatMenuOption("DroidManThing".Translate(thing.Label), delegate
             {
                 droid.jobs.StartJob(new Job(JobDefOf.ManTurret, thing), JobCondition.InterruptForced);
             }));
         }
         if (droid.equipment != null && (thing.def.IsMeleeWeapon || thing.def.IsRangedWeapon))
         {
             yield return(new FloatMenuOption("Equip".Translate(thing.Label), delegate
             {
                 CompForbiddable f = thing.TryGetComp <CompForbiddable>();
                 if (f != null && f.Forbidden)
                 {
                     f.Forbidden = false;
                 }
                 droid.jobs.StartJob(new Job(JobDefOf.Equip, thing), JobCondition.InterruptForced);
             }));
         }
         if (thing is Pawn)
         {
             Pawn p = thing as Pawn;
             if (p.RaceProps.intelligence >= Intelligence.Humanlike)
             {
                 if (droid.playerController.Drafted && p.CanBeArrested() && droid.CanReserveAndReach(p, PathEndMode.Touch, Danger.Some))
                 {
                     //Try to arrest
                     yield return(new FloatMenuOption("TryToArrest".Translate(p.LabelCap), delegate
                     {
                         Building_Bed bed = Find.ListerBuildings.AllBuildingsColonistOfClass <Building_Bed>().Where((Building_Bed b) => b.ForPrisoners && b.owner == null).FirstOrDefault();
                         if (bed != null)
                         {
                             Job job = new Job(JobDefOf.Arrest, p, bed);
                             job.maxNumToCarry = 1;
                             droid.jobs.StartJob(job, JobCondition.InterruptForced);
                         }
                         else
                         {
                             Messages.Message("DroidArrestNoBedsAvailable".Translate(), MessageSound.RejectInput);
                         }
                     }));
                 }
                 if (p.Downed)
                 {
                     if (droid.work.Contains(WorkTypeDefOf.Doctor) && droid.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
                     {
                         if (!p.HostileTo(Faction.OfColony) && p.def.race.intelligence >= Intelligence.Humanlike)
                         {
                             //Rescue a downed colonist or visitor
                             yield return(new FloatMenuOption("Rescue".Translate(p.LabelCap), delegate
                             {
                                 Building_Bed freeBed = Find.ListerBuildings.AllBuildingsColonistOfClass <Building_Bed>().Where(b =>
                                                                                                                                (b.Medical ||
                                                                                                                                 b.owner == p ||
                                                                                                                                 b.owner == null) &&
                                                                                                                                b.CurOccupant == null && !b.ForPrisoners).OrderByDescending(b => (b.def.building != null) ? b.def.building.bed_medicalBonusFactor : 0f).FirstOrDefault();
                                 if (freeBed != null)
                                 {
                                     Job job = new Job(JobDefOf.Rescue, p, freeBed);
                                     job.maxNumToCarry = 1;
                                     droid.jobs.StartJob(job, JobCondition.InterruptForced);
                                 }
                                 else
                                 {
                                     Messages.Message("DroidRescueNoMedicalBedsAvailable".Translate(), MessageSound.RejectInput);
                                 }
                             }));
                         }
                         if (p.HostileTo(Faction.OfColony))
                         {
                             //Capture a downed enemy or broken colonist
                             yield return(new FloatMenuOption("Capture".Translate(p.LabelCap), delegate
                             {
                                 Building_Bed freeBed = Find.ListerBuildings.AllBuildingsColonistOfClass <Building_Bed>().Where(b =>
                                                                                                                                (b.Medical ||
                                                                                                                                 b.owner == p ||
                                                                                                                                 b.owner == null) &&
                                                                                                                                b.CurOccupant == null && b.ForPrisoners).OrderByDescending(b => (b.def.building != null) ? b.def.building.bed_medicalBonusFactor : 0f).FirstOrDefault();
                                 if (freeBed != null)
                                 {
                                     Job job = new Job(JobDefOf.Capture, p, freeBed);
                                     job.maxNumToCarry = 1;
                                     droid.jobs.StartJob(job, JobCondition.InterruptForced);
                                 }
                                 else
                                 {
                                     Messages.Message("DroidArrestNoBedsAvailable".Translate(), MessageSound.RejectInput);
                                 }
                             }));
                         }
                     }
                     if (p.AnythingToStrip())
                     {
                         yield return(new FloatMenuOption("Strip".Translate(p.LabelCap), delegate
                         {
                             droid.jobs.StartJob(new Job(JobDefOf.Strip, p), JobCondition.InterruptForced);
                         }));
                     }
                 }
             }
         }
         if (thing is Corpse)
         {
             Corpse c = thing as Corpse;
             if (c.AnythingToStrip())
             {
                 yield return(new FloatMenuOption("Strip".Translate(c.LabelCap), delegate
                 {
                     droid.jobs.StartJob(new Job(JobDefOf.Strip, c), JobCondition.InterruptForced);
                 }));
             }
         }
     }
     foreach (var o in options)
     {
         yield return(o);
     }
 }
Esempio n. 14
0
 static void Postfix(CompForbiddable __instance, bool __state)
 {
     __instance.forbiddenInt = __state;
     FactionContext.Pop();
 }
Esempio n. 15
0
 static void Prefix(CompForbiddable __instance, ref bool __state)
 {
     FactionContext.Push(Multiplayer.RealPlayerFaction);
     __state = __instance.forbiddenInt;
     __instance.forbiddenInt = __instance.Forbidden;
 }
Esempio n. 16
0
        public override void SpawnSetup(Map map, bool respawningAfterLoad)
        {
            base.SpawnSetup(map, respawningAfterLoad);

            forbiddable = GetComp <CompForbiddable>();
        }
Esempio n. 17
0
 public override void PostSpawnSetup(bool respawningAfterLoad)
 {
     base.PostSpawnSetup(respawningAfterLoad);
     forbiddable = parent.GetComp <CompForbiddable>();
 }