2023-11-20 23:25:36 -06:00
# pragma region License
2023-11-14 18:11:32 -06:00
/*
License ( OLC - 3 )
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
2024-01-02 00:46:32 -06:00
Copyright 2024 Joshua Sigona < sigonasr2 @ gmail . com >
2023-11-14 18:11:32 -06:00
Redistribution and use in source and binary forms , with or without modification ,
are permitted provided that the following conditions are met :
1. Redistributions or derivations of source code must retain the above copyright
notice , this list of conditions and the following disclaimer .
2. Redistributions or derivative works in binary form must reproduce the above
copyright notice . This list of conditions and the following disclaimer must be
reproduced in the documentation and / or other materials provided with the distribution .
3. Neither the name of the copyright holder nor the names of its contributors may
be used to endorse or promote products derived from this software without specific
prior written permission .
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS " AS IS " AND ANY
EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT ,
INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT LIMITED
TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , DATA , OR PROFITS ; OR
BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY , WHETHER IN
CONTRACT , STRICT LIABILITY , OR TORT ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE .
2023-11-29 00:50:00 -06:00
Portions of this software are copyright © 2023 The FreeType
Project ( www . freetype . org ) . Please see LICENSE_FT . txt for more information .
All rights reserved .
2023-11-14 18:11:32 -06:00
*/
2023-11-20 23:25:36 -06:00
# pragma endregion
2023-06-21 14:30:14 -07:00
# pragma once
2023-06-22 23:28:16 -07:00
# include "olcUTIL_Geometry2D.h"
2023-09-15 01:02:10 -05:00
# include <set>
2023-11-11 17:31:53 -06:00
# include "TMXParser.h"
2023-06-22 22:09:11 -07:00
2023-06-23 20:42:55 -07:00
struct XMLTag ;
2024-01-09 04:50:01 -06:00
using MapName = std : : string ;
2023-11-11 17:31:53 -06:00
class MapHelper {
public :
static Map & MapFromString ( std : : string mapName ) ;
} ;
2023-06-23 20:42:55 -07:00
struct TileCollisionData {
2024-01-11 01:26:58 -06:00
geom2d : : rect < float > collision ;
2023-06-23 20:42:55 -07:00
} ;
2023-06-22 22:09:11 -07:00
struct TilesetData {
2023-09-06 23:07:15 -05:00
Renderable * tileset = nullptr ;
2023-11-27 02:38:12 -06:00
int tilewidth = 0 , tileheight = 0 ;
2024-01-10 03:11:03 -06:00
bool isTerrain = false ;
2023-06-22 22:09:11 -07:00
std : : map < int , XMLTag > foregroundTiles ;
2023-07-06 14:24:43 -05:00
std : : map < int , XMLTag > upperForegroundTiles ;
2024-01-11 01:26:58 -06:00
std : : map < float , TileCollisionData > collision ;
2023-07-06 15:07:44 -05:00
std : : map < int , XMLTag > staircaseTiles ;
2023-09-13 18:57:46 -05:00
std : : map < int , std : : vector < int > > animationData ;
2023-09-15 01:02:10 -05:00
std : : set < int > reflectiveData ;
2023-09-13 18:57:46 -05:00
} ;
struct TilesheetData {
TilesetData * tileset ;
int firstgid ;
2023-12-22 21:01:10 -06:00
bool operator = = ( const TilesheetData & rhs ) {
return tileset = = rhs . tileset & & firstgid = = rhs . firstgid ;
}
2023-06-22 22:09:11 -07:00
} ;
struct TileRenderData {
2023-09-13 18:57:46 -05:00
TilesheetData tileSheet ;
2024-01-11 01:26:58 -06:00
vf2d pos ;
2023-06-22 22:09:11 -07:00
vi2d tileSheetPos ;
2023-09-13 18:57:46 -05:00
int tileID ;
2023-09-12 03:09:21 -05:00
int layerID ;
2023-09-24 04:01:04 -05:00
float tileOpacity ;
2023-12-22 21:01:10 -06:00
bool operator = = ( const TileRenderData & rhs ) {
return tileSheet = = rhs . tileSheet & & pos = = rhs . pos & & tileSheetPos = = rhs . tileSheetPos
& & tileID = = rhs . tileID & & layerID = = rhs . layerID ;
}
2023-06-22 23:28:16 -07:00
} ;
struct TileGroup {
private :
geom2d : : rect < int > range ;
std : : vector < TileRenderData > tiles ;
2023-07-10 18:48:57 -05:00
int minX = 0 , minY = 0 , maxX = 0 , maxY = 0 ;
2023-06-22 23:28:16 -07:00
public :
2023-07-11 15:33:50 +00:00
static float FADE_TIME ;
//0-255. 255 indicates fully invisible.
static uint8_t FADE_AMT ;
2023-06-22 23:28:16 -07:00
geom2d : : rect < int > GetRange ( ) ;
2023-07-11 15:33:50 +00:00
//The fade range is the bounds in which this tile group will be considered "in range" of a player, one tile in each direction further than its actual range.
geom2d : : rect < int > GetFadeRange ( ) ;
2023-06-22 23:28:16 -07:00
std : : vector < TileRenderData > & GetTiles ( ) ;
void InsertTile ( TileRenderData tile ) ;
bool playerBehind = false ;
2023-07-11 15:33:50 +00:00
float fadeFactor = 0.f ;
2023-06-21 14:30:14 -07:00
} ;