Esempio n. 1
0
        // Verse.GhostDrawer
        public static bool HeronDoorGhostHandler(IntVec3 center, Rot4 rot, ThingDef thingDef, Graphic baseGraphic,
                                                 Color ghostCol, AltitudeLayer drawAltitude)
        {
            if (thingDef is DoorExpandedDef def && def.fixedPerspective)
            {
                Graphic graphic = GhostUtility.GhostGraphicFor(baseGraphic, thingDef, ghostCol);
                //Graphic graphic = Traverse.Create(typeof(GhostDrawer)).Method("GhostGraphicFor", new object[] { thingDef.graphic, thingDef, ghostCol }).GetValue<Graphic>();
                Vector3 loc = GenThing.TrueCenter(center, rot, thingDef.Size, drawAltitude.AltitudeFor());

                for (int i = 0; i < 2; i++)
                {
                    bool flipped = (i != 0) ? true : false;
                    Building_DoorExpanded.DrawParams(def, loc, rot, out var mesh, out var matrix, mod: 0,
                                                     flipped: flipped);
                    Graphics.DrawMesh(mesh: mesh, matrix: matrix, material: graphic.MatAt(rot: rot, thing: null),
                                      layer: 0);
                }

                if (thingDef?.PlaceWorkers?.Count > 0)
                {
                    for (int i = 0; i < thingDef.PlaceWorkers.Count; i++)
                    {
                        thingDef.PlaceWorkers[index : i]
                        .DrawGhost(def : thingDef, center : center, rot : rot, ghostCol : ghostCol);
                    }
                }

                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        // Verse.GhostDrawer
        public static bool HeronDoorGhostHandler(IntVec3 center, Rot4 rot, ThingDef thingDef, Graphic baseGraphic, Color ghostCol, AltitudeLayer drawAltitude)
        {
            if (thingDef is DoorExpandedDef def && def.fixedPerspective)
            {
                //Log.Message("1");
                Graphic graphic = (Graphic)AccessTools.Method(typeof(GhostDrawer), "GhostGraphicFor").Invoke(null, new object[] { thingDef.graphic, thingDef, ghostCol });
                //Log.Message("2");
                Vector3 loc = Gen.TrueCenter(center, rot, thingDef.Size, Altitudes.AltitudeFor(drawAltitude));

                for (int i = 0; i < 2; i++)
                {
                    bool      flipped = (i != 0) ? true : false;
                    Mesh      mesh;
                    Matrix4x4 matrix;
                    Building_DoorExpanded.DrawParams(def, loc, rot, out mesh, out matrix, 0, flipped);
                    Graphics.DrawMesh(mesh, matrix, graphic.MatAt(rot, null), 0);
                }

                if (thingDef.PlaceWorkers != null)
                {
                    for (int i = 0; i < thingDef.PlaceWorkers.Count; i++)
                    {
                        thingDef.PlaceWorkers[i].DrawGhost(thingDef, center, rot);
                    }
                }
                return(false);
            }
            return(true);
        }
Esempio n. 3
0
 public override bool ShouldShowFor(StatRequest req)
 {
     if (req.Def is ThingDef {
         IsDoor : true
     } thingDef)
     {
         if (!Building_DoorExpanded.DoorNeedsPower(thingDef))
         {
             return(stat == HeronDefOf.DoorOpenTime);
         }
         if (!req.HasThing)
         {
             return(stat != HeronDefOf.DoorOpenTime);
         }
         if (stat == HeronDefOf.DoorOpenTime)
         {
             return(true);
         }
         if (Building_DoorExpanded.DoorIsPoweredOn(req.Thing) is bool doorPowerOn)
         {
             return(doorPowerOn ? stat == HeronDefOf.UnpoweredDoorOpenTime : stat == HeronDefOf.PoweredDoorOpenTime);
         }
     }
     return(false);
 }
Esempio n. 4
0
        //GenGrid
        public static void CanBeSeenOver(Building b, ref bool __result)
        {
            //Ignores fillage
            Building_DoorExpanded building_DoorEx = b as Building_DoorExpanded;

            if (building_DoorEx != null)
            {
                __result = building_DoorEx != null && building_DoorEx.Open;
            }
        }
 private bool DoorPowerOn(StatRequest req)
 {
     if (stat == HeronDefOf.PoweredDoorOpenTime)
     {
         return(true);
     }
     if (stat == HeronDefOf.UnpoweredDoorOpenTime)
     {
         return(false);
     }
     return(Building_DoorExpanded.DoorIsPoweredOn(req.Thing) ?? Building_DoorExpanded.DoorNeedsPower((ThingDef)req.Def));
 }
Esempio n. 6
0
        //// Verse.ThingDef
        //public static void HeronDoorIsDoor(ThingDef __instance, ref bool __result)
        //{
        //    __result = __result || (typeof(Building_DoorExpanded).IsAssignableFrom(__instance.thingClass) && __instance.thingClass != typeof(Building_DoorFixedPerspective));
        //}


        /// <summary>
        /// Duplicate code of RimWorld.Building_Door
        /// The code is modified to detect if there is
        /// a Thing with the Class Building_DoorExpanded, so the
        /// door does not stay open indefinitely by thinking that
        /// something is blocking its path.
        /// </summary>
        /// <param name="__instance"></param>
        /// <param name="__result"></param>
        public static void InvisDoorWillCloseSoon(Building_Door __instance, ref bool __result)
        {
            if (__instance is Building_DoorRegionHandler)
            {
                for (int i = 0; i < 5; i++)
                {
                    IntVec3 c = __instance.Position + GenAdj.CardinalDirectionsAndInside[i];
                    if (c.InBounds(map: __instance.Map))
                    {
                        List <Thing> thingList = c.GetThingList(map: __instance.Map);
                        for (int j = 0; j < thingList.Count; j++)
                        {
                            Building_DoorExpanded b = thingList[index : j] as Building_DoorExpanded;
                            if (b != null)
                            {
                                __result = false;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 7
0
        public static void ShouldNotEnterCellInvisDoors(Pawn pawn, Map map, IntVec3 dest, ref bool __result)
        {
            if (__result)
            {
                return;
            }
            Building edifice = dest.GetEdifice(map);

            if (edifice != null)
            {
                Building_DoorExpanded building_doorEx = edifice as Building_DoorExpanded;
                if (building_doorEx != null)
                {
                    if (building_doorEx.IsForbidden(pawn))
                    {
                        __result = true;
                    }
                    if (!building_doorEx.PawnCanOpen(pawn))
                    {
                        __result = true;
                    }
                }
            }
        }
 public override float GetValueUnfinalized(StatRequest req, bool applyPostProcess = true)
 {
     return(Building_DoorExpanded.DoorOpenTime(req, DoorPowerOn(req), applyPostProcess));
 }
 public override string GetExplanationUnfinalized(StatRequest req, ToStringNumberSense numberSense)
 {
     return(Building_DoorExpanded.DoorOpenTimeExplanation(req, DoorPowerOn(req), stat));
 }