GameCondition: Weather Condition

Started by CannibarRechter, August 15, 2017, 05:47:30 PM

Previous topic - Next topic

CannibarRechter

Hi,

I had a mod a while back called Wicked Winter that produced a pronounced Winter affect. I'm refreshing it for A17, but I've noticed that the GenDate class has been updated.

I originally hardcoded an offset, to be applied on DayOfYear:

      static int[] offset = {
         -14, -16, -18, -20, -20, -20, -20, -20, -20, -20, -20, -20, -18, -16, -14,
         -12, -10, -8, -6, -3, -2, -1, 0, 0, 1, 1, 2, 2, 3, 3,
         6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
         3, 3, 2, 2, 1, 1, 0, 0, -1, -2, -3, -6, -8, -10, -12      
      };

        public override float TemperatureOffset()
        {
         int dayOfYear = GenDate.DayOfYear;
         float tempCelcius = offset[dayOfYear];
         
//         Debug.Log( string.Concat(new object[] { "CR. DayOfYear = ", dayOfYear, " Temp = ",

tempCelcius }) );
         
         return tempCelcius;
        }

The thing is, DayOfYear is now not available on GenDate. That's okay, but I think the real issue is that it might not be valid to assume that days 0-14 are wintry, any more. I'm thinking that, because I can find some analogous functions in GenDate that require latlons, and so forth, which seems to imply that seasons are now latitude dependent.

I could figure it out with a bit of trial and error if I have to, but I'm looking to not have to do that entirely from scratch.

Can someone enlighten me a bit, pretty please?
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

Oblitus

Quote from: CannibarRechter on August 15, 2017, 05:47:30 PM
The thing is, DayOfYear is now not available on GenDate.
You probably want this:
// RimWorld.GenLocalDate
public static int DayOfYear(int tile)
{
if (Current.ProgramState == ProgramState.Playing)
{
return GenDate.DayOfYear((long)GenLocalDate.TicksAbs, Find.WorldGrid.LongLatOf(tile).x);
}
return 0;
}


CannibarRechter

Hey, that's helpful. Surely I can imagine it producing a result. But I think my main question is it valid to continue to assume DayOfYear 0-14 are still always winter, or is there something hinky going on? Now the interesting thing about what you wrote there, is that DayOfYear() appears to take a latitude as an input. That's almost as if the game by definition consider the year to be time adjusted, and therfore is considering Day 0 to be the first day of Winter in the adjusted time zone. Is that correct?
CR All Mods and Tools Download Link
CR Total Texture Overhaul : Gives RimWorld a Natural Feel
CR Moddable: make RimWorld more moddable.
CR CompFX: display dynamic effects over RimWorld objects

Oblitus

Since DayOfSeason is based on DayOfYear, probably yes.