public static void _Postfix(ITab_Pawn_Needs __instance)
        {
            if (Find.CurrentMap == null)
            {
                return;
            }
            if (!TableDiner.settings.useExtraFeatures)
            {
                return;
            }
            Pawn SelPawn = Find.Selector.SingleSelectedThing as Pawn;

            if (SelPawn != null && SelPawn.IsColonist)
            {
                Vector2 size       = NeedsCardUtility.GetSize(SelPawn);
                Rect    tabRect    = new Rect(20, size.y - (ITab_Table.WinSize.y) + 10, ITab_Table.WinSize.x - 40, ITab_Table.WinSize.y - 20);
                Rect    tabRectBig = new Rect(10, size.y - (ITab_Table.WinSize.y) + 5, ITab_Table.WinSize.x - 20, ITab_Table.WinSize.y - 10);
                float   tr         = TableDinerGlobal.GetTableRadius(SelPawn.ThingID);
                GUI.color = Color.white;
                if (tr > TableDiner.settings.tableDistance)
                {
                    GUI.color = Color.yellow;
                }
                if (Mouse.IsOver(tabRect))
                {
                    Widgets.DrawHighlight(tabRectBig);
                    mOver = true;
                }
                TableDinerGlobal.tableRadii[SelPawn.ThingID] = Mathf.Pow(Widgets.HorizontalSlider(tabRect, Mathf.Sqrt(tr), 0, 23, true, tr < 1 ? "TDiner.Ignored".Translate() : Mathf.Round(tr).ToString(), "TDiner.TRSlideLabel".Translate()), 2);
                GUI.color = Color.white;
            }
        }
示例#2
0
        protected override void FillTab()
        {
            Rect tabRect    = new Rect(20, 10, this.size.x - 40, this.size.y - 20);
            Rect tabRectBig = new Rect(10, 5, this.size.x - 20, this.size.y - 10);

            if (!TableDiner.settings.useExtraFeatures)
            {
                Widgets.Label(tabRect, "TDiner.ExtraDisabled".Translate());
                return;
            }

            float tr = TableDinerGlobal.GetTableRadius(SelThing.ThingID);

            GUI.color = Color.white;
            if (tr > TableDiner.settings.tableDistance)
            {
                GUI.color = Color.yellow;
            }
            if (Mouse.IsOver(tabRect))
            {
                Widgets.DrawHighlight(tabRectBig);
            }
            TableDinerGlobal.tableRadii[SelThing.ThingID] = Mathf.Pow(Widgets.HorizontalSlider(tabRect, Mathf.Sqrt(tr), 0, 23, true, tr < 1 ? "TDiner.Ignored".Translate() : Mathf.Round(tr).ToString(), "TDiner.TRSlideLabel".Translate()), 2);
            GUI.color = Color.white;
        }
 public static void _Postfix(Pawn __instance)
 {
     if (!TableDiner.settings.useExtraFeatures)
     {
         return;
     }
     if (__instance.IsColonist)
     {
         float td = TableDinerGlobal.GetTableRadius(__instance.ThingID);
         Scribe_Values.Look(ref td, "TableDiner_TableDistance", 0);
         TableDinerGlobal.tableRadii[__instance.ThingID] = td;
     }
 }
        public static void _Postfix(Thing __instance)
        {
            if (!TableDiner.settings.useExtraFeatures)
            {
                return;
            }
            bool bp = false;

            //check if a blueprint
            if (__instance.def.entityDefToBuild != null)
            {
                ThingDef td = __instance.def.entityDefToBuild as ThingDef;
                bp = (td != null && td.surfaceType == SurfaceType.Eat);
            }
            //if eat surface / eat surface blueprint, draw circle.
            if (TableDiner.settings.displayRing && (__instance.def.surfaceType == SurfaceType.Eat || bp))
            {
                float td = TableDinerGlobal.GetTableRadius(__instance.ThingID);
                Scribe_Values.Look(ref td, "TableDiner_TableDistance", 0);
                TableDinerGlobal.tableRadii[__instance.ThingID] = td;
            }
        }
        public static void __Postfix(ITab_Pawn_Needs __instance)
        {
            if (Find.CurrentMap == null)
            {
                return;
            }
            if (!TableDiner.settings.displayRing)
            {
                return;
            }
            Pawn SelPawn = Find.Selector.SingleSelectedThing as Pawn;

            if (SelPawn != null && SelPawn.IsColonist && FillTab.mOver)
            {
                float r = TableDinerGlobal.GetTableRadius(SelPawn.ThingID);
                if (r < 1)
                {
                    r = TableDiner.settings.tableDistance;
                }
                Graphics.DrawMesh(TableDiner.tableCircle, Matrix4x4.TRS(SelPawn.TrueCenter() + Vector3.up * 10, Quaternion.identity, new Vector3(r, r, r)), TableDinerGlobal.circleMaterial, 0);
                FillTab.mOver = false;
            }
        }
        public static void _Postfix(Thing __instance)
        {
            bool bp = false;

            //check if a blueprint
            if (__instance.def.entityDefToBuild != null)
            {
                ThingDef td = __instance.def.entityDefToBuild as ThingDef;
                bp = (td != null && td.surfaceType == SurfaceType.Eat);
            }
            //if eat surface / eat surface blueprint, draw circle.
            if (TableDiner.settings.displayRing && (__instance.def.surfaceType == SurfaceType.Eat || bp))
            {
                //we draw a custom circle, because GenDraw.DrawRadiusRing is limited in it's radius.

                float r = TableDinerGlobal.GetTableRadius(__instance.ThingID);
                if (r < 1)
                {
                    r = TableDiner.settings.tableDistance;
                }
                //Graphics.DrawMesh(TableDiner.tableCircle, Matrix4x4.TRS(__instance.TrueCenter() + Vector3.up * 10, Quaternion.identity, new Vector3(TableDiner.settings.tableDistance, TableDiner.settings.tableDistance, TableDiner.settings.tableDistance)),bp ? TableDinerGlobal.circleMaterialBP : TableDinerGlobal.circleMaterial, 0);
                Graphics.DrawMesh(TableDiner.tableCircle, Matrix4x4.TRS(__instance.TrueCenter() + Vector3.up * 10, Quaternion.identity, new Vector3(r, r, r)), bp ? TableDinerGlobal.circleMaterialBP : TableDinerGlobal.circleMaterial, 0);
            }
        }
        public static bool __Prefix(Pawn pawn, TargetIndex ingestibleInd, ref Toil __result)
        {
            if (!TableDiner.settings.useExtraFeatures)
            {
                return(true);
            }
            Toil toil = new Verse.AI.Toil();

            toil.initAction = delegate
            {
                Pawn              actor              = toil.actor;
                IntVec3           intVec             = IntVec3.Invalid;
                Thing             thing              = null;
                Thing             thing2             = actor.CurJob.GetTarget(ingestibleInd).Thing;
                Predicate <Thing> baseChairValidator = delegate(Thing t)
                {
                    bool result;
                    if (t.def.building == null || !t.def.building.isSittable)
                    {
                        result = false;
                    }
                    else if (t.IsForbidden(pawn))
                    {
                        result = false;
                    }
                    else if (!actor.CanReserve(t, 1, -1, null, false))
                    {
                        result = false;
                    }
                    else if (!t.IsSociallyProper(actor))
                    {
                        result = false;
                    }
                    else if (t.IsBurning())
                    {
                        result = false;
                    }
                    else if (t.HostileTo(pawn))
                    {
                        result = false;
                    }
                    else
                    {
                        bool flag = false;
                        for (int i = 0; i < 4; i++)
                        {
                            IntVec3  c       = t.Position + GenAdj.CardinalDirections[i];
                            Building edifice = c.GetEdifice(t.Map);
                            if (edifice != null && edifice.def.surfaceType == SurfaceType.Eat)
                            {
                                float tr = TableDinerGlobal.GetTableRadius(edifice.ThingID);
                                float pr = TableDinerGlobal.GetTableRadius(actor.ThingID);

                                if (tr >= 1 || pr >= 1)
                                {
                                    float r2 = (edifice.TrueCenter() - actor.TrueCenter()).sqrMagnitude;
                                    if (tr < 1)
                                    {
                                        if (r2 <= Mathf.Pow(pr, 2))
                                        {
                                            flag = true;
                                            break;
                                        }
                                    }
                                    else if (pr < 1)
                                    {
                                        if (r2 <= Mathf.Pow(tr, 2))
                                        {
                                            flag = true;
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        if (r2 <= Mathf.Pow(Mathf.Min(tr, pr), 2))
                                        {
                                            flag = true;
                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    flag = true;
                                    break;
                                }
                            }
                        }
                        result = flag;
                    }
                    return(result);
                };
                if (thing2.def.ingestible.chairSearchRadius > 0f)
                {
                    thing = GenClosest.ClosestThingReachable(actor.Position, actor.Map, ThingRequest.ForGroup(ThingRequestGroup.BuildingArtificial), PathEndMode.OnCell, TraverseParms.For(actor, Danger.Deadly, TraverseMode.ByPawn, false), thing2.def.ingestible.chairSearchRadius, (Thing t) => baseChairValidator(t) && t.Position.GetDangerFor(pawn, t.Map) == Danger.None, null, 0, -1, false, RegionType.Set_Passable, false);
                }
                if (thing == null)
                {
                    intVec = RCellFinder.SpotToChewStandingNear(actor, actor.CurJob.GetTarget(ingestibleInd).Thing);
                    Danger chewSpotDanger = intVec.GetDangerFor(pawn, actor.Map);
                    if (chewSpotDanger != Danger.None)
                    {
                        thing = GenClosest.ClosestThingReachable(actor.Position, actor.Map, ThingRequest.ForGroup(ThingRequestGroup.BuildingArtificial), PathEndMode.OnCell, TraverseParms.For(actor, Danger.Deadly, TraverseMode.ByPawn, false), thing2.def.ingestible.chairSearchRadius, (Thing t) => baseChairValidator(t) && t.Position.GetDangerFor(pawn, t.Map) <= chewSpotDanger, null, 0, -1, false, RegionType.Set_Passable, false);
                    }
                }
                if (thing != null)
                {
                    intVec = thing.Position;
                    actor.Reserve(thing, actor.CurJob, 1, -1, null);
                }
                actor.Map.pawnDestinationReservationManager.Reserve(actor, actor.CurJob, intVec);
                actor.pather.StartPath(intVec, PathEndMode.OnCell);
            };
            toil.defaultCompleteMode = ToilCompleteMode.PatherArrival;
            __result = toil;
            return(false);
        }