Automatically updating MapHud if you have Celestials running
by Stephen Zepp · in RTS Starter Kit · 11/16/2004 (6:57 pm) · 4 replies
This is a consolidation of the original thread posted here.
NOTE: This mod is designed for those that have the Day/Night Cycles with Seasons working in their current code, and want to have the MapHud update periodically based on the current lighting.
It requires all the things that Day/Night does--specifically, the Celestials object defined in your mission file, and SunFlare objects as well in your mission file (these are what trigger the updateSunPosition if you have the resource implemented).
You need to change Celestial.h:
after the line: (approx line 99)
U32 mTimeOfYear; // Number of days since the last winter equinox
add
U32 mLastHudImpulse; // last time we told the RTS gui hud to rebuild
in Celestial.cc, in void Celestials::UpdateSunPosition()
change
NOTE: This mod is designed for those that have the Day/Night Cycles with Seasons working in their current code, and want to have the MapHud update periodically based on the current lighting.
It requires all the things that Day/Night does--specifically, the Celestials object defined in your mission file, and SunFlare objects as well in your mission file (these are what trigger the updateSunPosition if you have the resource implemented).
You need to change Celestial.h:
after the line: (approx line 99)
U32 mTimeOfYear; // Number of days since the last winter equinox
add
U32 mLastHudImpulse; // last time we told the RTS gui hud to rebuild
in Celestial.cc, in void Celestials::UpdateSunPosition()
change
if(prevTime > mTimeOfDay)
mTimeOfYear = (++mTimeOfYear) % mYearLen;toif(prevTime > mTimeOfDay)
{
// this is the day turnover
mTimeOfYear = (++mTimeOfYear) % mYearLen;
mLastHudImpulse = 0; // we know we need an impulse since this turnover happens only at midnight
}
// loose tracking of hours. used to impulse the HudMap to rebuild itself
if ( ( (mTimeOfDay >= (mDayLen/24) ) &&
(mTimeOfDay - (mDayLen/24) > mLastHudImpulse) ) ||
(mLastHudImpulse == 0) )
{
// it has been a game hour
mLastHudImpulse = mTimeOfDay;
// trigger RTS MapHud relight/rebuild
SimObject * guiMapHudObj = Sim::findObject("MapHud");
Con::printf("Celestials::updateSunPosition: Pinging MapHud to update based on every hour, using %s. Time of day is %i",
guiMapHudObj ? guiMapHudObj->getName() : "GuiMapHud not found!",
mTimeOfDay);
Con::executef(guiMapHudObj, 4, "schedule", "10", "rebuildMap", "true" );
}
// calculate sun decline and meridian angle (in radians)
#2
04/11/2008 (9:57 am)
Works good but unfortually it also stores the selection ring in the guiMapHudObj.
#3
04/24/2008 (8:41 am)
Thomas, is a minimap bug, solved by Guy Allard in this thread: Minimap Re-draw enhancement
#4
04/24/2008 (11:07 am)
Thanks novack :)
Torque Owner Josh Williams
Default Studio Name