Browse Source
- Added EntityPlayerSharedData and associated functions for providing easy access to player data - Added EntityLevelOfDetail which will tell modules how much they should simulate things based on where the player is at - Noise now takes a params struct making the interface much less ugly - Added comment stating that Z will be the up axis (this is how Unreal works too) - Added some logging to help indicate what the behavior is when registering component managers. This whole subsystem needs a rework - Fixed ComponentManager UnsubscribeEntities printing the entity list before removing irrelevant entriescombatComponentRefactor

20 changed files with 341 additions and 55 deletions
@ -1,13 +1,32 @@ |
|||
---------------------------------------------------------------------------------------------------- |
|||
TODO |
|||
---------------------------------------------------------------------------------------------------- |
|||
|
|||
Soak test editor - after ~1 hour it was looking pretty glitchy |
|||
|
|||
What does agent component manager do with triggers once plan is done? How to know plan is done? |
|||
|
|||
statics don't work well with hot reloading |
|||
Need some sort of system which makes it easy to tell static shit to reload? |
|||
|
|||
Play with Polyvox chunk scale |
|||
|
|||
**** LEFT OFF AT: |
|||
Pickups sort of working, sometimes they aren't picked up, Actors are being destroyed strangely |
|||
Agents should be destroyed by the AgentComponentManager if DieNow, but they don't seem to be hitting it |
|||
Possibility that pickup actor is falling through the floor (invisible other component hitting KillZ?) YES, it's KillZ |
|||
|
|||
Chunks are fucked |
|||
|
|||
---------------------------------------------------------------------------------------------------- |
|||
DOING |
|||
---------------------------------------------------------------------------------------------------- |
|||
|
|||
Added TrackActorLifetime, which is untested |
|||
Is this executed when pending kills will be sitting around, or right after cleanup? |
|||
|
|||
Added Interact to player, but does not seem to work |
|||
|
|||
Added UnrealMovementComponent Actor/Character spawning |
|||
|
|||
---------------------------------------------------------------------------------------------------- |
|||
DONE |
|||
---------------------------------------------------------------------------------------------------- |
|||
|
|||
Added EntityPlayerSharedData, which is untested |
@ -0,0 +1,23 @@ |
|||
#include "game/EntityLevelOfDetail.hpp" |
|||
#include "entityComponentSystem/EntitySharedData.hpp" |
|||
|
|||
namespace gv |
|||
{ |
|||
namespace EntityLOD |
|||
{ |
|||
EntityLODSettings g_EntityLODSettings; |
|||
|
|||
bool ShouldRenderForPlayer(Position& position) |
|||
{ |
|||
const EntityPlayerSharedData& playerData = EntityPlayerGetSharedData(); |
|||
const Position* playerPosition = playerData.PlayerPosition; |
|||
if (playerPosition) |
|||
{ |
|||
return (playerPosition->ManhattanTo(position) <= g_EntityLODSettings.PlayerManhattanViewDistance); |
|||
} |
|||
else |
|||
// When there's no player nothing should be rendered
|
|||
return false; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,18 @@ |
|||
#pragma once |
|||
|
|||
#include "world/Position.hpp" |
|||
|
|||
namespace gv |
|||
{ |
|||
namespace EntityLOD |
|||
{ |
|||
struct EntityLODSettings |
|||
{ |
|||
float PlayerManhattanViewDistance; |
|||
}; |
|||
|
|||
extern EntityLODSettings g_EntityLODSettings; |
|||
|
|||
bool ShouldRenderForPlayer(Position& position); |
|||
} |
|||
} |
@ -0,0 +1,90 @@ |
|||
#include "ProceduralWorld.hpp" |
|||
|
|||
namespace gv |
|||
{ |
|||
namespace ProceduralWorld |
|||
{ |
|||
static ProceduralWorldParams s_WorldParams; |
|||
|
|||
// This isn't fantastic, but I can replace it with a better system once one is needed
|
|||
ProceduralWorldParams& GetCurrentActiveWorldParams() |
|||
{ |
|||
return s_WorldParams; |
|||
} |
|||
|
|||
static float GetTileHeightForWorldPosition(const Position& tileWorldPosition) |
|||
{ |
|||
static int seed = 0; |
|||
static gv::Noise2d* noise2dGenerator = nullptr; |
|||
|
|||
if (!noise2dGenerator || seed != s_WorldParams.Seed) |
|||
{ |
|||
seed = s_WorldParams.Seed; |
|||
noise2dGenerator = new gv::Noise2d(seed); |
|||
} |
|||
|
|||
/*float tileHeight = noise2dGenerator->scaledOctaveNoise2d(
|
|||
tileWorldPosition.X, tileWorldPosition.Y, s_WorldParams.ScaledNoiseParams);*/ |
|||
|
|||
float tileHeight = 128.f; // FOR DEBUGGING ONLY; DELETE ME!
|
|||
|
|||
return tileHeight; |
|||
} |
|||
|
|||
void GetCellTileMapForPosition(const Position& cellPosition, WorldCellTileMap* tileMapOut) |
|||
{ |
|||
if (!tileMapOut) |
|||
return; |
|||
|
|||
for (int tileY = 0; tileY < WORLD_CELL_Y_SIZE; tileY++) |
|||
{ |
|||
for (int tileX = 0; tileX < WORLD_CELL_X_SIZE; tileX++) |
|||
{ |
|||
// Don't ever care about Z axis because we're working in 2D
|
|||
int tileCoord[] = {tileX, tileY, 0}; |
|||
|
|||
Position tileWorldPosition(cellPosition); |
|||
for (int i = 0; i < 3; i++) |
|||
tileWorldPosition[i] += tileCoord[i] * s_WorldParams.WorldCellTileSize[i]; |
|||
|
|||
float tileHeight = GetTileHeightForWorldPosition(tileWorldPosition); |
|||
|
|||
// Remap tile height, if necessary
|
|||
if (s_WorldParams.ScaledNoiseParams.highBound != 255.f) |
|||
tileHeight = (tileHeight / s_WorldParams.ScaledNoiseParams.highBound) * 255.f; |
|||
|
|||
tileMapOut->TileHeights[tileY][tileX] = (unsigned char)tileHeight; |
|||
} |
|||
} |
|||
} |
|||
|
|||
void SampleWorldCellHeights(const Position& center, int width, int height, |
|||
unsigned char* sampleHeights2d) |
|||
{ |
|||
if (!sampleHeights2d) |
|||
return; |
|||
|
|||
for (int y = 0; y < height; y++) |
|||
{ |
|||
for (int x = 0; x < width; x++) |
|||
{ |
|||
int worldCellSize[] = {WORLD_CELL_X_SIZE, WORLD_CELL_Y_SIZE, WORLD_CELL_Z_SIZE}; |
|||
int sampleCoord[] = {x - (width / 2), y - (height / 2), 0}; |
|||
|
|||
Position cellWorldPosition(center); |
|||
for (int i = 0; i < 3; i++) |
|||
cellWorldPosition[i] += |
|||
sampleCoord[i] * (s_WorldParams.WorldCellTileSize[i] * worldCellSize[i]); |
|||
|
|||
float tileHeight = GetTileHeightForWorldPosition(cellWorldPosition); |
|||
|
|||
// Remap tile height, if necessary
|
|||
if (s_WorldParams.ScaledNoiseParams.highBound != 255.f) |
|||
tileHeight = (tileHeight / s_WorldParams.ScaledNoiseParams.highBound) * 255.f; |
|||
|
|||
sampleHeights2d[(y * width) + x] = (unsigned char)tileHeight; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,38 @@ |
|||
#pragma once |
|||
|
|||
#include "Position.hpp" |
|||
#include "thirdPartyWrapper/noise/noise.hpp" |
|||
|
|||
#define WORLD_CELL_X_SIZE 16 |
|||
#define WORLD_CELL_Y_SIZE 16 |
|||
#define WORLD_CELL_Z_SIZE 255 |
|||
|
|||
namespace gv |
|||
{ |
|||
namespace ProceduralWorld |
|||
{ |
|||
struct ProceduralWorldParams |
|||
{ |
|||
int Seed; |
|||
|
|||
ScaledOctaveNoiseParams ScaledNoiseParams; |
|||
|
|||
// The size of a single 3D tile.
|
|||
float WorldCellTileSize[3]; |
|||
}; |
|||
|
|||
ProceduralWorldParams& GetCurrentActiveWorldParams(); |
|||
|
|||
// TODO: This assumes a 2D world. We need to figure the world out
|
|||
struct WorldCellTileMap |
|||
{ |
|||
unsigned char TileHeights[WORLD_CELL_Y_SIZE][WORLD_CELL_X_SIZE]; |
|||
}; |
|||
|
|||
void GetCellTileMapForPosition(const Position& cellPosition, WorldCellTileMap* tileMapOut); |
|||
|
|||
// Sample (width * height) cell heights (e.g. for world map)
|
|||
void SampleWorldCellHeights(const Position& center, int width, int height, |
|||
unsigned char* sampleHeights2d); |
|||
} |
|||
} |
Loading…
Reference in new issue