Author Topic: MultiMaps  (Read 2449 times)

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
MultiMaps
« on: 2011-12-05, 05:11:28 PM »
Wow, I seem to be asking a lot of things lately! :-[

Ok, I have a new problem, is it possible to load every map in the game at the same time, and call Plans and Sprite Rules all at the same time?

I don't need to render the maps, I just need to call the rules and plans for each map and each sprite on the map.

But for clarity here's what I'm trying to do.
Each map has a sprite called SaveGame Handler.
I have a network game, and my game uses the SaveGame slots to save each map. There's a host and a client.
The host and client code works, fine.
The host needs to run every map at the same time (It don't want to render each map at the same time, I understand that would make the computer unresponsive I just need to run all sprite rules and plans), and call the rules of SaveGame Handler, and the map plans.
When a new player tries to go to a new map, I need
the client to send a request to a server, which tells the host to call a rule on SaveGame Handler to save the specified map to the specified savegame file (Example.. 1.sav is the savegame of the 1st map, 2.sav is the savegame of the second map).
Now, I have everything else done, the server and client, but the only thing I'm asking for help is

What code would I need, to run all (or specified) map's plans, and all sprite rules on the certain map at the same time, without rendering the maps?
I tried exporting the plans code and sprite's code to my clipboard, and tried to create a custom code object that would handle it, but I couldn't get that to work.
« Last Edit: 2011-12-05, 05:16:01 PM by Pizzaman »

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: MultiMaps
« Reply #1 on: 2011-12-05, 06:15:43 PM »
In GameForm.cs you could replace CurrentMap.ExecuteRules() with a loop that calls ExecuteRules on every map in the LoadedMaps collection (or you can call GetMap and ExecuteRules on every type of map in sequence).  The map's ExecuteRules function calls all the ExecuteRules for all the layers/plans and sprites on the map.  So it should be remarkably easy.

Be aware, if you call GetMap on every type of map, it will force all map types to load into memory whereas if you iterate LoadedMaps, it will only process maps that are loaded.  Unused maps can be unloaded with UnloadMap (which is a function in both GameForm and in GeneralRules, which are the common rules for both plans and sprites).

If you want to accomplish this without editing GameForm.cs, you may be able to create a plan or sprite that handles the "OnBeforeExecuteRules" event and loop through all the maps in LoadedMaps except CurrentMap to run ExecuteRules on them.

BTW, I think it's pretty cool if you're actually getting network gaming to work!  I look forward to seeing what you accomplish.
« Last Edit: 2011-12-05, 06:25:23 PM by bluemonkmn »

v6v

  • Clever
  • Fanatic
  • ***
  • Posts: 500
  • Has renamed his project to Galaxy!
    • View Profile
    • My Developer Page!
    • Email
Re: MultiMaps
« Reply #2 on: 2011-12-05, 08:01:13 PM »
Thanks for the quick reply, you have no idea how much it means for me to hear you say that! Thanks.  :)

Really, you're the first person to support one of my projects!

I'll post my results tomorrow.

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: MultiMaps
« Reply #3 on: 2011-12-07, 06:58:30 AM »
It may just be because one of your projects uses one of my projects that I think it's cool, but it's still gotta be worth something :).