Okay - here's one piece of my last bit of creative crude work before switching back into infrastructure mode for a while.
https://github.com/Cervator/Blockmania/ ... a8f21747ce
I've implemented a half-working Portal concept including the spawning of mobs (slimes) without player interaction. Updated the terrain.png to get at a "portal like" block I could add to the Groovy file, probably not really what the real portal block is, but hey, this one looks weird enough
Moved some other related stuff around a bit with a new "game" package for core game content.
On game startup I check to see if an actual Portal object exists in the new PortalManager (over time there might be multiple Portals) and if not (which is currently always the case as Portals are not persisted) a new one will be created both in Block and Portal shape (relative to player position). If you manage to save the game and reload you might then manage to get a new Block and keep the old one as the Portal doesn't persist. So there's some strangeness to it.
I was trying to make two distinct spawning setups work, one "wild" type (goal is to spawn mid-far away from a Portal), one "local" type (goal is to only spawn locally if there's an "attracting" element present near the Portal, like a player estate / workshop). Currently that is only manifested by making the wild type spawn above the Portal and the local type below it. This will likely go totally weird in a new world.
Some things that need more thought / feedback
* What's up with the y = 32 on the player spawn location? I was trying to base the portal off the player's spawn location, but that embedded it deep within rock. I later accidentally spawned slimes in the same deep rock, which made them pop to the surface, is that the trick used to get the player in a valid spot? What's a better strategy to place the "default" Portal in a world that makes sense, like overwriting the block immediately below where the player ends up? One tricky bit seems to be finding a good time during load before the game loop begins where you have enough data available to intelligently place the block (with a brand new world there aren't any blocks yet?).
* While the portal block persists the Portal object and their relationship do not. We don't save Blueprints either, so I guess it is time to find a way to persist extra data like this to disk - any thoughts on easy (and efficient) architecture?
* Currently the Portal object stores its position as a Vector3f (is that the right way to do it?), but there might be a disconnect between it and its portal block. Would it be smarter to generate / reload the portal block based off a position stored in the Portal object? I was thinking about making Portal extend Block, but not sure how that architecture would work out and we may end up with a Portal object consisting of multiple blocks anyway.
* Alternatively, should there even be a standard portal block (player shouldn't be able to place one easily if at all) owned by the BlockManager? Are we looking at a block-like alternative, one loaded differently, or something?
* I need to calculate distance from the Portal object when determining where to spawn mobs. What's the best way to do that, and would a circle or a square be better? I'm thinking only two dimensions matter and height can be figured out somehow (tho it needs to account for any valid block position in the height layer, including caves, possibly varying what to spawn based on depth and exposure to sunlight). Reason I'm considering a square is from future thinking - in multiplayer the world might get cut into independent pieces based around a Portal each for efficiency reasons. Think keeping one set of mobs per Portal area, then maybe one global set for creatures that wander outside a Portal area (a player walks into the wilderness, still need to spawn mobs somehow). Transferring mobs between square area Sets rather than circular ones seems "easier" to me?
Portals are very much key to the game concept I have in mind - both for gameplay reasons and architectural reasons behind the scene, such as the multiplayer note above. In theory you could probably even run a multi-node server for larger player bases by dividing the portal areas between the nodes. Portals are also going to be the center of player-made "cities" and serve lots of other functions.
Next up: Workshops! These will piggy-back on the Blueprint concept by being defined as a blueprint in space, enclosing whatever is inside them. So another reason we need to be able to persist Blueprints
https://github.com/Cervator/Blockmania/ ... a8f21747ce
I've implemented a half-working Portal concept including the spawning of mobs (slimes) without player interaction. Updated the terrain.png to get at a "portal like" block I could add to the Groovy file, probably not really what the real portal block is, but hey, this one looks weird enough
On game startup I check to see if an actual Portal object exists in the new PortalManager (over time there might be multiple Portals) and if not (which is currently always the case as Portals are not persisted) a new one will be created both in Block and Portal shape (relative to player position). If you manage to save the game and reload you might then manage to get a new Block and keep the old one as the Portal doesn't persist. So there's some strangeness to it.
I was trying to make two distinct spawning setups work, one "wild" type (goal is to spawn mid-far away from a Portal), one "local" type (goal is to only spawn locally if there's an "attracting" element present near the Portal, like a player estate / workshop). Currently that is only manifested by making the wild type spawn above the Portal and the local type below it. This will likely go totally weird in a new world.
Some things that need more thought / feedback
* What's up with the y = 32 on the player spawn location? I was trying to base the portal off the player's spawn location, but that embedded it deep within rock. I later accidentally spawned slimes in the same deep rock, which made them pop to the surface, is that the trick used to get the player in a valid spot? What's a better strategy to place the "default" Portal in a world that makes sense, like overwriting the block immediately below where the player ends up? One tricky bit seems to be finding a good time during load before the game loop begins where you have enough data available to intelligently place the block (with a brand new world there aren't any blocks yet?).
* While the portal block persists the Portal object and their relationship do not. We don't save Blueprints either, so I guess it is time to find a way to persist extra data like this to disk - any thoughts on easy (and efficient) architecture?
* Currently the Portal object stores its position as a Vector3f (is that the right way to do it?), but there might be a disconnect between it and its portal block. Would it be smarter to generate / reload the portal block based off a position stored in the Portal object? I was thinking about making Portal extend Block, but not sure how that architecture would work out and we may end up with a Portal object consisting of multiple blocks anyway.
* Alternatively, should there even be a standard portal block (player shouldn't be able to place one easily if at all) owned by the BlockManager? Are we looking at a block-like alternative, one loaded differently, or something?
* I need to calculate distance from the Portal object when determining where to spawn mobs. What's the best way to do that, and would a circle or a square be better? I'm thinking only two dimensions matter and height can be figured out somehow (tho it needs to account for any valid block position in the height layer, including caves, possibly varying what to spawn based on depth and exposure to sunlight). Reason I'm considering a square is from future thinking - in multiplayer the world might get cut into independent pieces based around a Portal each for efficiency reasons. Think keeping one set of mobs per Portal area, then maybe one global set for creatures that wander outside a Portal area (a player walks into the wilderness, still need to spawn mobs somehow). Transferring mobs between square area Sets rather than circular ones seems "easier" to me?
Portals are very much key to the game concept I have in mind - both for gameplay reasons and architectural reasons behind the scene, such as the multiplayer note above. In theory you could probably even run a multi-node server for larger player bases by dividing the portal areas between the nodes. Portals are also going to be the center of player-made "cities" and serve lots of other functions.
Next up: Workshops! These will piggy-back on the Blueprint concept by being defined as a blueprint in space, enclosing whatever is inside them. So another reason we need to be able to persist Blueprints