@ -1266,53 +1266,167 @@ void AiL::RenderWorld(float fElapsedTime){
m . strategyDraw ( this , m , MONSTER_DATA [ m . GetName ( ) ] . GetAIStrategy ( ) ) ;
}
# pragma region Rendering before Tile Depth Rendering
if ( tilesWithCollision . size ( ) > 0 ) {
const float topTileY = ( * tilesWithCollision . begin ( ) ) - > group - > GetCollisionRange ( ) . middle ( ) . y ;
# pragma region Depth Ordered Rendering
{
auto it = monstersBeforeLower . begin ( ) ;
while ( it ! = monstersBeforeLower . end ( ) ) {
Monster & m = * * it ;
if ( m . pos . y < topTileY ) {
m . Draw ( ) ;
it = monstersBeforeLower . erase ( it ) ;
if ( it = = monstersBeforeLower . end ( ) ) break ;
continue ;
}
break ;
}
}
{
auto it = bulletsLower . begin ( ) ;
while ( it ! = bulletsLower . end ( ) ) {
const Bullet & b = * * it ;
if ( b . pos . y < topTileY ) {
b . Draw ( ) ;
it = bulletsLower . erase ( it ) ;
if ( it = = bulletsLower . end ( ) ) break ;
continue ;
}
break ;
}
}
{
auto it = backgroundEffectsLower . begin ( ) ;
while ( it ! = backgroundEffectsLower . end ( ) ) {
const Effect & e = * * it ;
if ( e . pos . y < topTileY ) {
e . Draw ( ) ;
it = backgroundEffectsLower . erase ( it ) ;
if ( it = = backgroundEffectsLower . end ( ) ) break ;
continue ;
}
break ;
}
}
{
auto it = dropsBeforeLower . begin ( ) ;
while ( it ! = dropsBeforeLower . end ( ) ) {
const ItemDrop & drop = ItemDrop : : drops [ * it ] ;
if ( drop . pos . y < topTileY ) {
drop . Draw ( ) ;
it = dropsBeforeLower . erase ( it ) ;
if ( it = = dropsBeforeLower . end ( ) ) break ;
continue ;
}
break ;
}
}
if ( ! player - > rendered & & ! player - > upperLevel & & player - > GetPos ( ) . y < topTileY ) {
player - > rendered = true ;
if ( player - > GetZ ( ) > 0 ) {
vf2d shadowScale = vf2d { 8 * player - > GetSizeMult ( ) / 3.f , 1 } / std : : max ( 1.f , player - > GetZ ( ) / 24 ) ;
view . DrawDecal ( player - > GetPos ( ) - vf2d { 3 , 3 } * shadowScale / 2 + vf2d { 0 , 6 * player - > GetSizeMult ( ) } , GFX [ " circle.png " ] . Decal ( ) , shadowScale , BLACK ) ;
}
RenderPlayer ( player - > GetPos ( ) , { 1 , 1 } ) ;
}
{
auto it = monstersAfterLower . begin ( ) ;
while ( it ! = monstersAfterLower . end ( ) ) {
Monster & m = * * it ;
if ( m . pos . y < topTileY ) {
m . Draw ( ) ;
it = monstersAfterLower . erase ( it ) ;
if ( it = = monstersAfterLower . end ( ) ) break ;
continue ;
}
break ;
}
}
{
auto it = dropsAfterLower . begin ( ) ;
while ( it ! = dropsAfterLower . end ( ) ) {
const ItemDrop & drop = ItemDrop : : drops [ * it ] ;
if ( drop . pos . y < topTileY ) {
drop . Draw ( ) ;
it = dropsAfterLower . erase ( it ) ;
if ( it = = dropsAfterLower . end ( ) ) break ;
continue ;
}
break ;
}
}
{
auto it = foregroundEffectsLower . begin ( ) ;
while ( it ! = foregroundEffectsLower . end ( ) ) {
const Effect & e = * * it ;
if ( e . pos . y < topTileY ) {
e . Draw ( ) ;
it = foregroundEffectsLower . erase ( it ) ;
if ( it = = foregroundEffectsLower . end ( ) ) break ;
continue ;
}
break ;
}
}
# pragma endregion
}
# pragma endregion
# pragma region Foreground Rendering w / Depth
for ( TileRenderData * tile : tilesWithCollision ) {
# pragma region Depth Ordered Rendering
for ( auto it = monstersBeforeLower . begin ( ) ; it ! = monstersBeforeLower . end ( ) ; + + it ) {
{
auto it = monstersBeforeLower . begin ( ) ;
while ( it ! = monstersBeforeLower . end ( ) ) {
Monster & m = * * it ;
if ( m . pos . y < tile - > group - > GetCollisionRange ( ) . middle ( ) . y ) {
m . Draw ( ) ;
it = monstersBeforeLower . erase ( it ) ;
if ( it = = monstersBeforeLower . end ( ) ) break ;
if ( it ! = monstersBeforeLower . begin ( ) ) - - it ;
continue ;
}
break ;
}
for ( auto it = bulletsLower . begin ( ) ; it ! = bulletsLower . end ( ) ; + + it ) {
}
{
auto it = bulletsLower . begin ( ) ;
while ( it ! = bulletsLower . end ( ) ) {
const Bullet & b = * * it ;
if ( b . pos . y < tile - > group - > GetCollisionRange ( ) . middle ( ) . y ) {
b . Draw ( ) ;
it = bulletsLower . erase ( it ) ;
if ( it = = bulletsLower . end ( ) ) break ;
if ( it ! = bulletsLower . begin ( ) ) - - it ;
continue ;
}
break ;
}
for ( auto it = backgroundEffectsLower . begin ( ) ; it ! = backgroundEffectsLower . end ( ) ; + + it ) {
}
{
auto it = backgroundEffectsLower . begin ( ) ;
while ( it ! = backgroundEffectsLower . end ( ) ) {
const Effect & e = * * it ;
if ( e . pos . y < tile - > group - > GetCollisionRange ( ) . middle ( ) . y ) {
e . Draw ( ) ;
it = backgroundEffectsLower . erase ( it ) ;
if ( it = = backgroundEffectsLower . end ( ) ) break ;
if ( it ! = backgroundEffectsLower . begin ( ) ) - - it ;
continue ;
}
break ;
}
for ( auto it = dropsBeforeLower . begin ( ) ; it ! = dropsBeforeLower . end ( ) ; + + it ) {
}
{
auto it = dropsBeforeLower . begin ( ) ;
while ( it ! = dropsBeforeLower . end ( ) ) {
const ItemDrop & drop = ItemDrop : : drops [ * it ] ;
if ( drop . pos . y < tile - > group - > GetCollisionRange ( ) . middle ( ) . y ) {
drop . Draw ( ) ;
it = dropsBeforeLower . erase ( it ) ;
if ( it = = dropsBeforeLower . end ( ) ) break ;
if ( it ! = dropsBeforeLower . begin ( ) ) - - it ;
continue ;
}
break ;
}
}
if ( ! player - > rendered & & ! player - > upperLevel & & player - > GetPos ( ) . y < tile - > group - > GetCollisionRange ( ) . middle ( ) . y ) {
player - > rendered = true ;
if ( player - > GetZ ( ) > 0 ) {
@ -1321,39 +1435,45 @@ void AiL::RenderWorld(float fElapsedTime){
}
RenderPlayer ( player - > GetPos ( ) , { 1 , 1 } ) ;
}
for ( auto it = monstersAfterLower . begin ( ) ; it ! = monstersAfterLower . end ( ) ; + + it ) {
{
auto it = monstersAfterLower . begin ( ) ;
while ( it ! = monstersAfterLower . end ( ) ) {
Monster & m = * * it ;
if ( m . pos . y < tile - > group - > GetCollisionRange ( ) . middle ( ) . y ) {
m . Draw ( ) ;
it = monstersAfterLower . erase ( it ) ;
if ( it = = monstersAfterLower . end ( ) ) break ;
if ( it ! = monstersAfterLower . begin ( ) ) - - it ;
continue ;
}
break ;
}
for ( auto it = dropsAfterLower . begin ( ) ; it ! = dropsAfterLower . end ( ) ; + + it ) {
}
{
auto it = dropsAfterLower . begin ( ) ;
while ( it ! = dropsAfterLower . end ( ) ) {
const ItemDrop & drop = ItemDrop : : drops [ * it ] ;
if ( drop . pos . y < tile - > group - > GetCollisionRange ( ) . middle ( ) . y ) {
drop . Draw ( ) ;
it = dropsAfterLower . erase ( it ) ;
if ( it = = dropsAfterLower . end ( ) ) break ;
if ( it ! = dropsAfterLower . begin ( ) ) - - it ;
continue ;
}
break ;
}
for ( auto it = foregroundEffectsLower . begin ( ) ; it ! = foregroundEffectsLower . end ( ) ; + + it ) {
}
{
auto it = foregroundEffectsLower . begin ( ) ;
while ( it ! = foregroundEffectsLower . end ( ) ) {
const Effect & e = * * it ;
if ( e . pos . y < tile - > group - > GetCollisionRange ( ) . middle ( ) . y ) {
e . Draw ( ) ;
it = foregroundEffectsLower . erase ( it ) ;
if ( it = = foregroundEffectsLower . end ( ) ) break ;
if ( it ! = foregroundEffectsLower . begin ( ) ) - - it ;
continue ;
}
break ;
}
}
# pragma endregion
RenderTile ( * tile , { 255 , 255 , 255 , uint8_t ( 255 - tile - > tileOpacity / TileGroup : : FADE_TIME * TileGroup : : FADE_AMT ) } ) ;
float distToPlayer = geom2d : : line < float > ( player - > GetPos ( ) , tile - > pos + vf2d { 12 , 12 } ) . length ( ) ;
@ -1522,53 +1642,168 @@ void AiL::RenderWorld(float fElapsedTime){
m . strategyDraw ( this , m , MONSTER_DATA [ m . GetName ( ) ] . GetAIStrategy ( ) ) ;
}
# pragma region Rendering before Tile Depth Rendering
if ( tilesWithCollision . size ( ) > 0 ) {
const float topTileY = ( * tilesWithCollision . begin ( ) ) - > group - > GetCollisionRange ( ) . middle ( ) . y ;
# pragma region Depth Ordered Rendering
{
auto it = monstersBeforeUpper . begin ( ) ;
while ( it ! = monstersBeforeUpper . end ( ) ) {
Monster & m = * * it ;
if ( m . pos . y < topTileY ) {
m . Draw ( ) ;
it = monstersBeforeUpper . erase ( it ) ;
if ( it = = monstersBeforeUpper . end ( ) ) break ;
continue ;
}
break ;
}
}
{
auto it = bulletsUpper . begin ( ) ;
while ( it ! = bulletsUpper . end ( ) ) {
const Bullet & b = * * it ;
if ( b . pos . y < topTileY ) {
b . Draw ( ) ;
it = bulletsUpper . erase ( it ) ;
if ( it = = bulletsUpper . end ( ) ) break ;
continue ;
}
break ;
}
}
{
auto it = backgroundEffectsUpper . begin ( ) ;
while ( it ! = backgroundEffectsUpper . end ( ) ) {
const Effect & e = * * it ;
if ( e . pos . y < topTileY ) {
e . Draw ( ) ;
it = backgroundEffectsUpper . erase ( it ) ;
if ( it = = backgroundEffectsUpper . end ( ) ) break ;
continue ;
}
break ;
}
}
{
auto it = dropsBeforeUpper . begin ( ) ;
while ( it ! = dropsBeforeUpper . end ( ) ) {
const ItemDrop & drop = ItemDrop : : drops [ * it ] ;
if ( drop . pos . y < topTileY ) {
drop . Draw ( ) ;
it = dropsBeforeUpper . erase ( it ) ;
if ( it = = dropsBeforeUpper . end ( ) ) break ;
continue ;
}
break ;
}
}
if ( ! player - > rendered & & ! player - > upperLevel & & player - > GetPos ( ) . y < topTileY ) {
player - > rendered = true ;
if ( player - > GetZ ( ) > 0 ) {
vf2d shadowScale = vf2d { 8 * player - > GetSizeMult ( ) / 3.f , 1 } / std : : max ( 1.f , player - > GetZ ( ) / 24 ) ;
view . DrawDecal ( player - > GetPos ( ) - vf2d { 3 , 3 } * shadowScale / 2 + vf2d { 0 , 6 * player - > GetSizeMult ( ) } , GFX [ " circle.png " ] . Decal ( ) , shadowScale , BLACK ) ;
}
RenderPlayer ( player - > GetPos ( ) , { 1 , 1 } ) ;
}
{
auto it = monstersAfterUpper . begin ( ) ;
while ( it ! = monstersAfterUpper . end ( ) ) {
Monster & m = * * it ;
if ( m . pos . y < topTileY ) {
m . Draw ( ) ;
it = monstersAfterUpper . erase ( it ) ;
if ( it = = monstersAfterUpper . end ( ) ) break ;
continue ;
}
break ;
}
}
{
auto it = dropsAfterUpper . begin ( ) ;
while ( it ! = dropsAfterUpper . end ( ) ) {
const ItemDrop & drop = ItemDrop : : drops [ * it ] ;
if ( drop . pos . y < topTileY ) {
drop . Draw ( ) ;
it = dropsAfterUpper . erase ( it ) ;
if ( it = = dropsAfterUpper . end ( ) ) break ;
continue ;
}
break ;
}
}
{
auto it = foregroundEffectsUpper . begin ( ) ;
while ( it ! = foregroundEffectsUpper . end ( ) ) {
const Effect & e = * * it ;
if ( e . pos . y < topTileY ) {
e . Draw ( ) ;
it = foregroundEffectsUpper . erase ( it ) ;
if ( it = = foregroundEffectsUpper . end ( ) ) break ;
if ( it ! = foregroundEffectsUpper . begin ( ) ) - - it ;
continue ;
}
break ;
}
}
# pragma endregion
}
# pragma endregion
# pragma region Upper Foreground Rendering w / Depth
for ( TileRenderData * tile : tilesWithCollision ) {
# pragma region Depth Ordered Upper Rendering
for ( auto it = monstersBeforeUpper . begin ( ) ; it ! = monstersBeforeUpper . end ( ) ; + + it ) {
{
auto it = monstersBeforeUpper . begin ( ) ;
while ( it ! = monstersBeforeUpper . end ( ) ) {
Monster & m = * * it ;
if ( m . pos . y < tile - > group - > GetCollisionRange ( ) . middle ( ) . y ) {
m . Draw ( ) ;
it = monstersBeforeUpper . erase ( it ) ;
if ( it = = monstersBeforeUpper . end ( ) ) break ;
if ( it ! = monstersBeforeUpper . begin ( ) ) - - it ;
continue ;
}
break ;
}
for ( auto it = bulletsUpper . begin ( ) ; it ! = bulletsUpper . end ( ) ; + + it ) {
}
{
auto it = bulletsUpper . begin ( ) ;
while ( it ! = bulletsUpper . end ( ) ) {
const Bullet & b = * * it ;
if ( b . pos . y < tile - > group - > GetCollisionRange ( ) . middle ( ) . y ) {
b . Draw ( ) ;
it = bulletsUpper . erase ( it ) ;
if ( it = = bulletsUpper . end ( ) ) break ;
if ( it ! = bulletsUpper . begin ( ) ) - - it ;
continue ;
}
break ;
}
for ( auto it = backgroundEffectsUpper . begin ( ) ; it ! = backgroundEffectsUpper . end ( ) ; + + it ) {
}
{
auto it = backgroundEffectsUpper . begin ( ) ;
while ( it ! = backgroundEffectsUpper . end ( ) ) {
const Effect & e = * * it ;
if ( e . pos . y < tile - > group - > GetCollisionRange ( ) . middle ( ) . y ) {
e . Draw ( ) ;
it = backgroundEffectsUpper . erase ( it ) ;
if ( it = = backgroundEffectsUpper . end ( ) ) break ;
if ( it ! = backgroundEffectsUpper . begin ( ) ) - - it ;
continue ;
}
break ;
}
for ( auto it = dropsBeforeUpper . begin ( ) ; it ! = dropsBeforeUpper . end ( ) ; + + it ) {
}
{
auto it = dropsBeforeUpper . begin ( ) ;
while ( it ! = dropsBeforeUpper . end ( ) ) {
const ItemDrop & drop = ItemDrop : : drops [ * it ] ;
if ( drop . pos . y < tile - > group - > GetCollisionRange ( ) . middle ( ) . y ) {
drop . Draw ( ) ;
it = dropsBeforeUpper . erase ( it ) ;
if ( it = = dropsBeforeUpper . end ( ) ) break ;
if ( it ! = dropsBeforeUpper . begin ( ) ) - - it ;
continue ;
}
break ;
}
}
if ( ! player - > rendered & & player - > upperLevel & & player - > GetPos ( ) . y < tile - > group - > GetCollisionRange ( ) . middle ( ) . y ) {
player - > rendered = true ;
if ( player - > GetZ ( ) > 0 ) {
@ -1577,39 +1812,45 @@ void AiL::RenderWorld(float fElapsedTime){
}
RenderPlayer ( player - > GetPos ( ) , { 1 , 1 } ) ;
}
for ( auto it = monstersAfterUpper . begin ( ) ; it ! = monstersAfterUpper . end ( ) ; + + it ) {
{
auto it = monstersAfterUpper . begin ( ) ;
while ( it ! = monstersAfterUpper . end ( ) ) {
Monster & m = * * it ;
if ( m . pos . y < tile - > group - > GetCollisionRange ( ) . middle ( ) . y ) {
m . Draw ( ) ;
it = monstersAfterUpper . erase ( it ) ;
if ( it = = monstersAfterUpper . end ( ) ) break ;
if ( it ! = monstersAfterUpper . begin ( ) ) - - it ;
continue ;
}
break ;
}
for ( auto it = dropsAfterUpper . begin ( ) ; it ! = dropsAfterUpper . end ( ) ; + + it ) {
}
{
auto it = dropsAfterUpper . begin ( ) ;
while ( it ! = dropsAfterUpper . end ( ) ) {
const ItemDrop & drop = ItemDrop : : drops [ * it ] ;
if ( drop . pos . y < tile - > group - > GetCollisionRange ( ) . middle ( ) . y ) {
drop . Draw ( ) ;
it = dropsAfterUpper . erase ( it ) ;
if ( it = = dropsAfterUpper . end ( ) ) break ;
if ( it ! = dropsAfterUpper . begin ( ) ) - - it ;
continue ;
}
break ;
}
for ( auto it = foregroundEffectsUpper . begin ( ) ; it ! = foregroundEffectsUpper . end ( ) ; + + it ) {
}
{
auto it = foregroundEffectsUpper . begin ( ) ;
while ( it ! = foregroundEffectsUpper . end ( ) ) {
const Effect & e = * * it ;
if ( e . pos . y < tile - > group - > GetCollisionRange ( ) . middle ( ) . y ) {
e . Draw ( ) ;
it = foregroundEffectsUpper . erase ( it ) ;
if ( it = = foregroundEffectsUpper . end ( ) ) break ;
if ( it ! = foregroundEffectsUpper . begin ( ) ) - - it ;
continue ;
}
break ;
}
}
# pragma endregion
RenderTile ( * tile , { 255 , 255 , 255 , uint8_t ( 255 - tile - > tileOpacity / TileGroup : : FADE_TIME * TileGroup : : FADE_AMT ) } ) ;
float distToPlayer = geom2d : : line < float > ( player - > GetPos ( ) , tile - > pos + vf2d { 12 , 12 } ) . length ( ) ;
@ -2451,7 +2692,7 @@ void AiL::_PrepareLevel(MapName map,MusicChange changeMusic){
for ( NPCData data : game - > MAP_DATA [ game - > GetCurrentLevel ( ) ] . npcs ) {
if ( Unlock : : IsUnlocked ( data . unlockCondition ) ) {
MONSTER_LIST . push_back ( std : : make_unique < Monster > ( data . spawnPos , MONSTER_DATA [ data . name ] ) ) ;
MONSTER_LIST . back ( ) - > iframe_timer = INFINITE ;
MONSTER_LIST . back ( ) - > SetIframes ( INFINITE ) ;
MONSTER_LIST . back ( ) - > npcData = data ;
}
}