Example #1
0
        private static void Postfix(ref Zone_Growing __instance)
        {
            var allowTill = TillToggle.IsAllowed(__instance);

            Scribe_Values.Look(ref allowTill, "allowTill", true);
            TillToggle.SetAllowed(__instance, allowTill);
        }
Example #2
0
        public override IEnumerable <IntVec3> PotentialWorkCellsGlobal(Pawn pawn)
        {
            if (!ResearchProjectDefOf.AC_Tilling.IsFinished)
            {
                yield break;
            }
            Danger              maxDanger = pawn.NormalMaxDanger();
            List <Zone>         zonesList = pawn.Map.zoneManager.AllZones;
            ReservationLayerDef layer     = ReservationLayerDefOf.Floor;

            for (int j = 0; j < zonesList.Count; j++)
            {
                Zone_Growing growZone = zonesList[j] as Zone_Growing;
                if (growZone != null && TillToggle.IsAllowed(growZone))
                {
                    if (growZone.cells.Count == 0)
                    {
                        Log.ErrorOnce("Grow zone has 0 cells: " + growZone, -563487, false);
                    }
                    else if (!growZone.ContainsStaticFire && pawn.CanReach(growZone.Cells[0], PathEndMode.OnCell, maxDanger))
                    {
                        for (int k = 0; k < growZone.cells.Count; k++)
                        {
                            IntVec3 c = growZone.cells[k];
                            if (pawn.Map.terrainGrid.TerrainAt(c).GetModExtension <TerrainExtension>() != null &&
                                pawn.Map.terrainGrid.TerrainAt(c).GetModExtension <TerrainExtension>().tillsTo != null &&
                                pawn.CanReach(growZone.Cells[0], PathEndMode.OnCell, maxDanger) &&
                                pawn.CanReserve(c, 1, -1, layer, false))
                            {
                                if (c.GetPlant(pawn.Map) != null)
                                {
                                    if (!c.GetPlant(pawn.Map).sown)
                                    {
                                        yield return(growZone.cells[k]);
                                    }
                                }
                                else
                                {
                                    yield return(growZone.cells[k]);
                                }
                            }
                        }
                    }
                }
            }
            yield break;
        }
Example #3
0
        private static void Postfix(Zone_Growing __instance, ref IEnumerable <Gizmo> __result)
        {
            if (ResearchProjectDefOf.AC_Tilling.IsFinished)
            {
                var toggleTillCommand = new Command_Toggle
                {
                    defaultLabel = "AC.CommandToggleTill".Translate(),
                    defaultDesc  = "AC.CommandToggleTillDesc".Translate(),
                    icon         = TexCommand.Till,
                    isActive     = () => TillToggle.IsAllowed(__instance),
                    toggleAction = () => TillToggle.SetAllowed(__instance, !TillToggle.IsAllowed(__instance))
                };

                __result = new List <Gizmo>(__result)
                {
                    toggleTillCommand
                };
            }
            else
            {
                __result = new List <Gizmo>(__result);
            }
        }