public static bool ExtraSocialiteParties(VoluntarilyJoinableLordsStarter __instance) { //Transpiler? Map map = Traverse.Create(__instance).Field("map").GetValue <Map>(); if (map.IsPlayerHome) { return(false); } int socialiteMod = 1; IEnumerable <Pawn> allPawnsSpawned = map.mapPawns.FreeColonistsSpawned; foreach (Pawn pawn in allPawnsSpawned) { if (pawn.RaceProps.Humanlike && pawn.story.traits.HasTrait(TraitDefOfPsychology.Socialite)) { socialiteMod++; } } if (Find.TickManager.TicksGame % GenDate.TicksPerHour * 2 == 0) { if (Rand.MTBEventOccurs(40f, GenDate.TicksPerDay, (GenDate.TicksPerHour * 2f * socialiteMod))) { Traverse.Create(__instance).Field("startPartyASAP").SetValue(true); } if (Traverse.Create(__instance).Field("startPartyASAP").GetValue <bool>() && Find.TickManager.TicksGame - Traverse.Create(__instance).Field("lastLordStartTick").GetValue <int>() >= (int)(GenDate.TicksPerSeason * 2 / socialiteMod) && PartyUtility.AcceptableGameConditionsToStartParty(map)) { Traverse.Create(__instance).Method("TryStartParty", new object[] { }).GetValue(); } } return(false); }
internal static void _Tick_TryStartParty(this VoluntarilyJoinableLordsStarter _this) { if (!_this.GetMap().IsPlayerHome) { return; } int socialiteMod = 1; List <Pawn> allPawnsSpawned = _this.GetMap().mapPawns.AllPawnsSpawned; foreach (Pawn pawn in allPawnsSpawned) { if (pawn.RaceProps.Humanlike && pawn.story.traits.HasTrait(TraitDefOfPsychology.Socialite)) { socialiteMod++; } } if (Find.TickManager.TicksGame % 5000 == 0) { if (Rand.MTBEventOccurs(40f, 60000f, (5000f * socialiteMod))) { _this.SetStartPartyASAP(true); } if (_this.GetStartPartyASAP() && Find.TickManager.TicksGame - _this.GetLastLordStartTick() >= (int)(600000 / socialiteMod) && PartyUtility.AcceptableMapConditionsToStartParty(_this.GetMap())) { _this.TryStartParty(); } } }
internal static int GetLastLordStartTick(this VoluntarilyJoinableLordsStarter _this) { if (_lastLordStartTick == null) { _lastLordStartTick = typeof(VoluntarilyJoinableLordsStarter).GetField("lastLordStartTick", BindingFlags.Instance | BindingFlags.NonPublic); if (_lastLordStartTick == null) { Log.ErrorOnce("Unable to reflect VoluntarilyJoinableLordsStarter.lastLordStartTick!", 305432421); } } return((int)_lastLordStartTick.GetValue(_this)); }
internal static void SetStartPartyASAP(this VoluntarilyJoinableLordsStarter _this, bool val) { if (_startPartyASAP == null) { _startPartyASAP = typeof(VoluntarilyJoinableLordsStarter).GetField("startPartyASAP", BindingFlags.Instance | BindingFlags.NonPublic); if (_startPartyASAP == null) { Log.ErrorOnce("Unable to reflect VoluntarilyJoinableLordsStarter.startPartyASAP!", 305432421); } } _startPartyASAP.SetValue(_this, val); }
internal static Map GetMap(this VoluntarilyJoinableLordsStarter _this) { if (_map == null) { _map = typeof(VoluntarilyJoinableLordsStarter).GetField("map", BindingFlags.Instance | BindingFlags.NonPublic); if (_map == null) { Log.ErrorOnce("Unable to reflect VoluntarilyJoinableLordsStarter.map!", 305432421); } } return((Map)_map.GetValue(_this)); }
static bool Prefix(ref VoluntarilyJoinableLordsStarter __instance) { if (!__instance.map.IsPlayerHome || Find.TickManager.TicksGame % 5000 > RefcellRespeedConfig.currentTimeMultiplier - 1) { return(false); } if (Rand.MTBEventOccurs(40f, 60000f, 5000f)) { __instance.startRandomGatheringASAP = true; } if (!__instance.startRandomGatheringASAP || Find.TickManager.TicksGame - __instance.lastLordStartTick < 600000) { return(false); } __instance.TryStartRandomGathering(); return(false); }
public static bool ExtraSocialiteParties(VoluntarilyJoinableLordsStarter __instance) { //Transpiler? Map map = Traverse.Create(__instance).Field("map").GetValue <Map>(); if (!map.IsPlayerHome) { return(false); } int socialiteMod = 1 + map.mapPawns.FreeColonistsSpawned.Where(p => p.story.traits.HasTrait(TraitDefOfPsychology.Socialite)).Count(); if (Find.TickManager.TicksGame % (GenDate.TicksPerHour * 2) == 0) { if (Rand.MTBEventOccurs(40f, GenDate.TicksPerDay, (GenDate.TicksPerHour * 2f * (1 + (socialiteMod / (map.mapPawns.ColonistCount > 0 ? map.mapPawns.ColonistCount : 1)))))) { Traverse.Create(__instance).Field("startPartyASAP").SetValue(true); } if (Traverse.Create(__instance).Field("startPartyASAP").GetValue <bool>() && Find.TickManager.TicksGame - Traverse.Create(__instance).Field("lastLordStartTick").GetValue <int>() >= (int)(GenDate.TicksPerSeason * 2 / (1 + (socialiteMod / (map.mapPawns.ColonistCount > 0 ? map.mapPawns.ColonistCount : 1)))) && PartyUtility.AcceptableGameConditionsToStartParty(map)) { Traverse.Create(__instance).Method("TryStartParty", new object[] { }).GetValue(); } } return(false); }
public void ConstructComponents() { this.spawnedThings = new ThingOwner <Thing>(this); this.cellIndices = new CellIndices(this); this.listerThings = new ListerThings(ListerThingsUse.Global); this.listerBuildings = new ListerBuildings(); this.mapPawns = new MapPawns(this); this.dynamicDrawManager = new DynamicDrawManager(this); this.mapDrawer = new MapDrawer(this); this.tooltipGiverList = new TooltipGiverList(); this.pawnDestinationReservationManager = new PawnDestinationReservationManager(); this.reservationManager = new ReservationManager(this); this.physicalInteractionReservationManager = new PhysicalInteractionReservationManager(); this.designationManager = new DesignationManager(this); this.lordManager = new LordManager(this); this.debugDrawer = new DebugCellDrawer(); this.passingShipManager = new PassingShipManager(this); this.haulDestinationManager = new HaulDestinationManager(this); this.gameConditionManager = new GameConditionManager(this); this.weatherManager = new WeatherManager(this); this.zoneManager = new ZoneManager(this); this.resourceCounter = new ResourceCounter(this); this.mapTemperature = new MapTemperature(this); this.temperatureCache = new TemperatureCache(this); this.areaManager = new AreaManager(this); this.attackTargetsCache = new AttackTargetsCache(this); this.attackTargetReservationManager = new AttackTargetReservationManager(this); this.lordsStarter = new VoluntarilyJoinableLordsStarter(this); this.thingGrid = new ThingGrid(this); this.coverGrid = new CoverGrid(this); this.edificeGrid = new EdificeGrid(this); this.blueprintGrid = new BlueprintGrid(this); this.fogGrid = new FogGrid(this); this.glowGrid = new GlowGrid(this); this.regionGrid = new RegionGrid(this); this.terrainGrid = new TerrainGrid(this); this.pathGrid = new PathGrid(this); this.roofGrid = new RoofGrid(this); this.fertilityGrid = new FertilityGrid(this); this.snowGrid = new SnowGrid(this); this.deepResourceGrid = new DeepResourceGrid(this); this.exitMapGrid = new ExitMapGrid(this); this.linkGrid = new LinkGrid(this); this.glowFlooder = new GlowFlooder(this); this.powerNetManager = new PowerNetManager(this); this.powerNetGrid = new PowerNetGrid(this); this.regionMaker = new RegionMaker(this); this.pathFinder = new PathFinder(this); this.pawnPathPool = new PawnPathPool(this); this.regionAndRoomUpdater = new RegionAndRoomUpdater(this); this.regionLinkDatabase = new RegionLinkDatabase(); this.moteCounter = new MoteCounter(); this.gatherSpotLister = new GatherSpotLister(); this.windManager = new WindManager(this); this.listerBuildingsRepairable = new ListerBuildingsRepairable(); this.listerHaulables = new ListerHaulables(this); this.listerMergeables = new ListerMergeables(this); this.listerFilthInHomeArea = new ListerFilthInHomeArea(this); this.reachability = new Reachability(this); this.itemAvailability = new ItemAvailability(this); this.autoBuildRoofAreaSetter = new AutoBuildRoofAreaSetter(this); this.roofCollapseBufferResolver = new RoofCollapseBufferResolver(this); this.roofCollapseBuffer = new RoofCollapseBuffer(); this.wildAnimalSpawner = new WildAnimalSpawner(this); this.wildPlantSpawner = new WildPlantSpawner(this); this.steadyEnvironmentEffects = new SteadyEnvironmentEffects(this); this.skyManager = new SkyManager(this); this.overlayDrawer = new OverlayDrawer(); this.floodFiller = new FloodFiller(this); this.weatherDecider = new WeatherDecider(this); this.fireWatcher = new FireWatcher(this); this.dangerWatcher = new DangerWatcher(this); this.damageWatcher = new DamageWatcher(); this.strengthWatcher = new StrengthWatcher(this); this.wealthWatcher = new WealthWatcher(this); this.regionDirtyer = new RegionDirtyer(this); this.cellsInRandomOrder = new MapCellsInRandomOrder(this); this.rememberedCameraPos = new RememberedCameraPos(this); this.mineStrikeManager = new MineStrikeManager(); this.storyState = new StoryState(this); this.retainedCaravanData = new RetainedCaravanData(this); this.components.Clear(); this.FillComponents(); }