performance with nested Otherwise statements

jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
edited April 2012 in Working with GS (Mac)
I finished coding my entire nested otherwise statements for automatic level creation, and it's killed the level loading time. when I manually place the buildings in the level it takes 3.2 seconds to load. when my level directors, it takes over 14.

I'm not sure i've done this the most efficient way, has anyone else had a large number of otherwise statements?

what I have right now is 7 positions. each position has it's own actor with 60 nested otherwise statements. I tried having everything contained within a single actor, but it was taking a minute to open it each time.

for example in actor 1, I have two groups:

if buildingNumber < 30 and if buildingNumber > 30

and in each of those, I have rules that go like this:

if buildingNumber = 1
spawn building1
otherwise
if buildingNumber = 2
spawn building2
otherwise
if buildingNumber = 3
spawn building3
otherwise
.....

so on and so forth until I hit 30, then the next rule group takes over.

is there a better way to do this that is more efficient? I'm hoping that once the new engine comes out that it will solve problems like this, but i'd rather not wish on the wind. I've read that having nested statements is better than 60 separate if statements, but this is no picnic.

is there a better way to do this?

Best Answer

Answers

Sign In or Register to comment.