Creating an NRaas project Tempest Update

Talk nerdy to us here.
icarus_allsorts
Reactions:
Posts: 213
Joined: March 8th, 2012, 6:00 pm

Tempest Update

Post by icarus_allsorts » January 30th, 2014, 4:30 pm

I took a shot at updating Tempest to handle the leaves remaining on the world lot after fall issue, and turns out it all I had to do was to tag on the one line telling the game to clean up all the leaves on the world lot at the same place where Twallan had Tempest decaying leaves on all lots during Spring and Summer (added Winter as well for good measure). I did a quick test run on a short game of mine and it SEEMS to work as it should (all leaves on lots and the world lot faded away the moment Fall ended and Winter began) so I was thinking it can be uploaded for testing perhaps? But which file exactly should I upload, the dll, the package, or the entire project perhaps?

User avatar
Chain_Reaction
Site Admin
Reactions:
Posts: 7596
Joined: December 30th, 2011, 6:00 pm
Answers: 81
Contact:

Post by Chain_Reaction » January 30th, 2014, 11:02 pm

You'll want to grab the latest Tempest from here and import your DLL into it (which you probably did) then zip it up and upload it. Next you'll want to hit Edit on another page, Shooless Testing perhaps, copy the contents then create a new page named Tempest Testing, paste and edit to fit tempest. Then edit the Update History Testing page.

As for the source, you can upload the changed .CS file and I'll commit it to the source for you if you don't feel like getting a Github account and pushing it to me that way. :)

icarus_allsorts
Reactions:
Posts: 213
Joined: March 8th, 2012, 6:00 pm

Post by icarus_allsorts » January 31st, 2014, 4:53 am

Okay I uploaded the updated SeasonWatch.cs for now (sorry for the double upload, thought the uploader was being flakey on me), I'll see about get a Github account later, if only to keep the source files updated. Goes in the TempestSpace/Helpers folder btw.

icarus_allsorts
Reactions:
Posts: 213
Joined: March 8th, 2012, 6:00 pm

Post by icarus_allsorts » February 1st, 2014, 1:52 pm

I've added a bit more code to assist in the leaf removal on lots since I myself and quite a few other testers have noticed that it doesn't work 100% as advertised (the world lot leaf removal on the other hand seems absolutely fine). I've tested it again on a small world and this time the mod manages to remove every leaf on every lot on the world regardless of how the season is changed (whether by natural progression or by cheats), which was cause for celebration BUT I am concerned that on larger worlds with many lots with leaves on them the process may turn out to be on the taxing side. This is the part of the SeasonWatch.cd that I added to the previous update, which I've added to again this time with a new method to clean up leaves on lots:

protected static void ApplySeason(Season season)
{
ApplySpawnerSuppression(season == Season.Winter);

switch (season)
{
case Season.Spring:
case Season.Summer:
case Season.Winter:
WeatherControl.SetWorldLeavesAmount(0f);
foreach (Lot lot in LotManager.Lots)
{
RemoveLeaves (lot.LotId);
}
break;
}
}

protected static void RemoveLeaves(ulong lotId)
{
World.DecayLeaves(lotId, 1f);
LotLocation[] leavesTiles = World.GetLeavesTiles (lotId, LotLocation.Invalid);
if (leavesTiles.Length > 0)
{
foreach (LotLocation tile in leavesTiles)
{
World.SetLeaves (lotId, tile, false);
}
}
}

GetLeavesTiles supposedly returns an array of every 'LotLocation' (which either refers to a floor tile or just a point on the lot) that has leaves on it. SetLeaves with false as the 3rd argument will remove the leaves from the LotLocation specified (true will add leaves to it). Found them both while looking through the code for the Rake interaction.

I'm not sure how intensive running the GetLeavesTiles method on every lot on the world can potentially be (I didn't experience any hiccups when it was running, but my test world was a really small one) I guess there's really no way to know without further testing, but I wonder if I should still go ahead and spring it on a few more willing testers out there anyways?

icarus_allsorts
Reactions:
Posts: 213
Joined: March 8th, 2012, 6:00 pm

Post by icarus_allsorts » February 1st, 2014, 2:50 pm

Hmm, foreach has been causing me quite some trouble on a few occasions, which was why at least I added the check that the array wasn't empty. The foreach in ApplySeasons is as Twallan wrote it... Now if this is where the original leaf removal is was stopped I think I'll swear never to use foreach again!

User avatar
JunJayMdM
Reactions:
Posts: 262
Joined: April 2nd, 2012, 6:00 pm

Post by JunJayMdM » February 2nd, 2014, 7:28 am

If you're concerned about the leaves removal impact, add this class to SeasonWatch :

<!-- ws:start:WikiTextCodeRule:0:
<pre class="text"> public class Task : Common.FunctionTask<br/> {<br/> private ulong mLotID;<br/><br/> public Task(ulong lotID)<br/> {<br/> mLotID = lotID;<br/> }<br/><br/> public static void Perform(ulong lotID)<br/> {<br/> new Task(lotID).AddToSimulator();<br/> }<br/><br/> protected override void OnPerform()<br/> {<br/> World.DecayLeaves(mLotID, 1f);<br/> LotLocation[] leavesTiles = World.GetLeavesTiles(mLotID, LotLocation.Invalid);<br/> if (leavesTiles.Length &gt; 0)<br/> {<br/> foreach (LotLocation tile in leavesTiles)<br/> {<br/> World.SetLeaves(mLotID, tile, false);<br/> }<br/> }<br/> }<br/> }</pre>
-->
<style type="text/css"><!--
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.text {font-family:monospace;}
.text .imp {font-weight: bold; color: red;}
.text span.xtra { display:block; }

-->
</style><pre class="text"> public class Task : Common.FunctionTask
{
private ulong mLotID;
&nbsp;
public Task(ulong lotID)
{
mLotID = lotID;
}
&nbsp;
public static void Perform(ulong lotID)
{
new Task(lotID).AddToSimulator();
}
&nbsp;
protected override void OnPerform()
{
World.DecayLeaves(mLotID, 1f);
LotLocation[] leavesTiles = World.GetLeavesTiles(mLotID, LotLocation.Invalid);
if (leavesTiles.Length > 0)
{
foreach (LotLocation tile in leavesTiles)
{
World.SetLeaves(mLotID, tile, false);
}
}
}
}</pre>


Then to call it :

<!-- ws:start:WikiTextCodeRule:1:
<pre class="text">foreach (Lot lot in LotManager.Lots)<br/>{<br/> Task.Perform(lot.LotId);<br/>}</pre>
-->
<style type="text/css"><!--
/**
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.text {font-family:monospace;}
.text .imp {font-weight: bold; color: red;}
.text span.xtra { display:block; }

-->
</style><pre class="text">foreach (Lot lot in LotManager.Lots)
{
Task.Perform(lot.LotId);
}</pre>


This will be run as a separate and indipendent process, hence causing no slowdowns :)

P.S. If you wish, you can have the first foreach in the task so only one is run, instead of a task for each lot

User avatar
Chain_Reaction
Site Admin
Reactions:
Posts: 7596
Joined: December 30th, 2011, 6:00 pm
Answers: 81
Contact:

Post by Chain_Reaction » February 2nd, 2014, 2:13 pm

Junjay ftw. Something else to add to my notes.

icarus_allsorts
Reactions:
Posts: 213
Joined: March 8th, 2012, 6:00 pm

Post by icarus_allsorts » February 2nd, 2014, 3:28 pm

Interesting, I think I night go ahead and do this even though I haven:t received any reports on lag (yet). I'm unsure about one thing though, if I were to put the first foreach into the task, where should it go, in OnPerform?

Post Reply