/// <summary> /// Injected method jump use only /// </summary> public static void _RecalculateAllGlow() { //Log.Message("CustomGlowGrid: RecalculateAllGlow()"); var glowFlooder = Find.CurrentMap.glowFlooder; var initialGlowerLocs = _GlowerGridPropertyHelper.InitialGlowerLocs(); //Log.Message("InitialGlowerLocs count: " + initialGlowerLocs.Count ); var litGlowers = _GlowerGridPropertyHelper.LitGlowers(); //Log.Message("InitialGlowerLocs count: " + litGlowers.Count); //Log.Message("CustomGlowGrid: Got private fields()"); if (Current.ProgramState != ProgramState.Playing) { return; } if (initialGlowerLocs != null) { foreach (var current in initialGlowerLocs) { Find.CurrentMap.glowGrid.MarkGlowGridDirty(current); } initialGlowerLocs = null; } //Log.Message("CustomGlowGrid: MarkGlowGridDirty(IntVec3)"); var ci = Find.CurrentMap.cellIndices; for (var i = 0; i < ci.NumGridCells; i++) { Find.CurrentMap.glowGrid.glowGrid[i] = new Color32(0, 0, 0, 0); //luckily this was public.. phew :) } //Log.Message("CustomGlowGrid: Cleared grid cells with RGB(0,0,0,0)"); foreach (var current2 in litGlowers) { glowFlooder.AddFloodGlowFor(current2, Find.CurrentMap.glowGrid.glowGrid); } //Log.Message("CustomGlowGrid: Recalculated the original flood glower"); //I just wanted this one freaking line in the original game and had to go to all this trouble to hack it in. //It took me about 20hours to figure out how to put this here. //It started out with me playing RimWorld and enjoying it so much that I looked into MOD's. Then I realised that they are pretty easy //to make using the XML documents and then later that you can use C# to make even nicer one. //So from opening VisualStudio and loading in the Rimworld DLL for the first time, first time looking at the code and hardly any documents, 20 man hours later //I finally got this in here. CustomGlowFloodManager.RefreshGlowFlooders(); //Log.Message("CustomGlowGrid: Recalculated universal glowers"); }
protected override void ReceiveCompSignal(string signal) { Log.Safe("LEDHydroponicsBasin Signal:" + signal); if (signal == "PowerTurnedOn") { hydroponicsFlooder.CalculateGlowFlood(); } if (signal == "PowerTurnedOff") { hydroponicsFlooder.Clear(); } //we need to force a lighting refresh manually here CustomGlowFloodManager.RefreshGlowFlooders(); }
protected override void ReceiveCompSignal(string signal) { //Log.Message("AngleLight Signal:" + signal); if (signal == "PowerTurnedOn") { if (!CustomGlowFloodManager.IsGlowerRegistered(thisFlooder)) { registerFlooder(); } thisFlooder.CalculateGlowFlood(); } if (signal == "PowerTurnedOff") { CustomGlowFloodManager.DeRegisterGlower(thisFlooder); } //we need to force a lighting refresh manually here CustomGlowFloodManager.RefreshGlowFlooders(); }
private void registerFlooder() { thisFlooder = new AngledGlowFlooder(Position, Rotation, PowerComp, GetComp <CompPowerTrader>(), Map); CustomGlowFloodManager.RegisterFlooder(thisFlooder); }
// ================================== /// <summary> /// /// </summary> public override void Tick() { if (!instantiated) { //foreach (Thing thing in GetContainer()) //{ // thing.holder.owner = this; //} currentDriverSpeed = VehicleSpeed; instantiated = true; } base.Tick(); #region Headlights #if Headlights { if (Find.GlowGrid.GameGlowAt(Position - Rotation.FacingCell - Rotation.FacingCell) < 0.4f) { // TODO Add headlights to xml & move the flooder initialization to mountableComp if (mountableComp.Driver != null && !compVehicles.AnimalsCanDrive() && flooder == null) { flooder = new HeadLights(Position, Rotation, this); CustomGlowFloodManager.RegisterFlooder(flooder); CustomGlowFloodManager.RefreshGlowFlooders(); } if (mountableComp.Driver == null && flooder != null) { flooder.Clear(); CustomGlowFloodManager.DeRegisterGlower(flooder); CustomGlowFloodManager.RefreshGlowFlooders(); flooder = null; } // TODO optimized performance, lights only at night and when driver is mounted => light switch gizmo? if (flooder != null) { flooder.Position = Position + Rotation.FacingCell + Rotation.FacingCell; flooder.Orientation = Rotation; flooder.Clear(); flooder.CalculateGlowFlood(); } } if (mountableComp.Driver == null && flooder != null || flooder != null) { CustomGlowFloodManager.DeRegisterGlower(flooder); CustomGlowFloodManager.RefreshGlowFlooders(); flooder = null; } } #endif #endregion if (mountableComp.IsMounted) { if (refuelableComp != null) { if (mountableComp.Driver.Faction != Faction.OfPlayer) { if (!fueledByAI) { if (refuelableComp.FuelPercent < 0.550000011920929) { refuelableComp.Refuel( ThingMaker.MakeThing(refuelableComp.Props.fuelFilter.AllowedThingDefs.FirstOrDefault())); } else { fueledByAI = true; } } } } if (mountableComp.Driver.pather.Moving) // || mountableComp.Driver.drafter.pawn.pather.Moving) { if (!mountableComp.Driver.stances.FullBodyBusy && axlesComp.HasAxles()) { wheelRotation += currentDriverSpeed / 3f; tick_time += 0.01f * currentDriverSpeed / 5f; } if (mountableComp.Driver.Position.AdjacentTo8WayOrInside(mountableComp.Driver.pather.Destination.Cell) && axlesComp.HasAxles()) { // Make the breaks sound once and throw some dust if Driver comes to his destination if (!soundPlayed) { SoundDef.Named("VehicleATV_Ambience_Break").PlayOneShot(mountableComp.Driver.Position); MoteMaker.ThrowDustPuff(DrawPos, 0.8f); soundPlayed = true; } } else { soundPlayed = false; } // TODO move all variables like smoke amount and break sound to xml etc. if (Find.TerrainGrid.TerrainAt(DrawPos.ToIntVec3()).takeFootprints || Find.SnowGrid.GetDepth(DrawPos.ToIntVec3()) > 0.2f) { if (vehicleComp.LeaveTrail()) { Vector3 normalized = (DrawPos - _lastFootprintPlacePos).normalized; float rot = normalized.AngleFlat(); Vector3 loc = DrawPos + TrailOffset; if ((loc - _lastFootprintPlacePos).MagnitudeHorizontalSquared() > FootprintIntervalDist) { if (loc.ShouldSpawnMotesAt() && !MoteCounter.SaturatedLowPriority) { MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(ThingDef.Named("Mote_Trail_ATV")); moteThrown.exactRotation = rot; moteThrown.exactPosition = loc; GenSpawn.Spawn(moteThrown, loc.ToIntVec3()); _lastFootprintPlacePos = DrawPos; } } } if (axlesComp.HasAxles()) { MoteMaker.ThrowDustPuff(DrawPos + DustOffset, 0.15f + Mathf.InverseLerp(0, 50, currentDriverSpeed) * 0.6f); } else { MoteMaker.ThrowDustPuff(DrawPos + DustOffset, 0.15f + Mathf.InverseLerp(0, 50, VehicleSpeed) * 0.6f); } } } //Exhaustion fumes - basic // only fumes on vehicles with combustion and no animals driving if (!vehicleComp.MotorizedWithoutFuel() && !vehicleComp.AnimalsCanDrive()) { MoteMaker.ThrowSmoke(DrawPos + FumesOffset, 0.05f + currentDriverSpeed * 0.01f); } if (Find.TickManager.TicksGame - tickCheck >= tickCooldown) { if (mountableComp.Driver.pather.Moving) { if (!mountableComp.Driver.stances.FullBodyBusy) { if (refuelableComp != null) { refuelableComp.Notify_UsedThisTick(); } damagetick -= 1; if (axlesComp.HasAxles()) { currentDriverSpeed = ToolsForHaulUtility.GetMoveSpeed(mountableComp.Driver); } } if (breakdownableComp != null && breakdownableComp.BrokenDown || refuelableComp != null && !refuelableComp.HasFuel) { VehicleSpeed = 0.75f; } else { VehicleSpeed = DesiredSpeed; } tickCheck = Find.TickManager.TicksGame; } if (Position.InNoBuildEdgeArea() && despawnAtEdge && Spawned && (mountableComp.Driver.Faction != Faction.OfPlayer || mountableComp.Driver.MentalState.def == MentalStateDefOf.PanicFlee)) { DeSpawn(); } } } //if (Find.TickManager.TicksGame >= damagetick) //{ // TakeDamage(new DamageInfo(DamageDefOf.Deterioration, 1, null, null, null)); // damagetick = Find.TickManager.TicksGame + 3600; //} if (vehicleComp.tankLeaking) { if (Find.TickManager.TicksGame > _tankSpillTick) { if (refuelableComp.FuelPercent > _tankHitPos) { refuelableComp.ConsumeFuel(0.15f); FilthMaker.MakeFilth(Position, fuelDefName, LabelCap); _tankSpillTick = Find.TickManager.TicksGame + 15; } } } }
private void registerFlooder() { hydroponicsFlooder = new HydroponicsFlooder(Position, Rotation, PowerComp, GetComp <CompPowerTrader>(), Map); CustomGlowFloodManager.RegisterFlooder(hydroponicsFlooder); }