1
0
forked from 0ad/0ad
0ad/source/simulation/LOSManager.h
Matei 0ed2815c8b Added initial version of LOS, and updated minimap to show both LOS and water.
LOS issues still outstanding:
- LOS looks ugly because of quad tesselation into 2 triangles
- Quad tesselation is unspecified by OpenGL (in fact using GL_QUADS on
LOS quads seemed to give different tesselations than it did for the
underlying terrain quads, but terrain rendering also used GL_QUADS).
This should be fixed once we decide on the quad tesselation issue.
- Units with traits.vision.permanent set are visible through FOW even if
you havent seen them before; this should only be true when you have seen
them before. But it gets even more complicated - if a permanent unit
seen through FOW dies or gets upgraded or something, perhaps you should
remember the old version. I'm not completely sure how to do this
(probably involves cloning its actor somehow).

This was SVN commit r2876.
2005-10-09 03:43:03 +00:00

64 lines
1.9 KiB
C++

// LOSManager.h
//
// Matei Zaharia matei@sprint.ca / matei@wildfiregames.com
//
// Maintains and updates line of sight data (including Shroud of Darkness
// and Fog of War).
//
// Usage: Doesn't do anything useful right now.
#ifndef LOS_MANAGER_INCLUDED
#define LOS_MANAGER_INCLUDED
#include "Singleton.h"
#include "Game.h"
#include "World.h"
#include "Player.h"
class CUnit;
class CPlayer;
enum ELOSStatus
{
LOS_VISIBLE = 2, // tile is currently in LOS of one of the player's units
LOS_EXPLORED = 1, // tile was explored before but is now in Fog of War
LOS_UNEXPLORED = 0 // tile is unexplored and therefore in Shroud of Darkness
};
enum EUnitLOSStatus
{
UNIT_VISIBLE = 2, // unit is in LOS of one of the player's units
UNIT_REMEMBERED = 1, // unit was seen before and is permanent but is no longer in LOS
UNIT_HIDDEN = 0 // unit is either not permanent or was never seen before
};
class CLOSManager : public Singleton<CLOSManager>
{
int** m_Explored; // (m_Explored[x][z] & (1<<p) says whether player p has explored tile (x,z),
// i.e. has removed Shroud of Darkness from it.
int** m_Visible; // (m_Visible[x][z] & (1<<p)) says whether player p currently sees tile (x,z).
// NOTE: This will have to be changed to a 3D array where each element stores the number of units
// of a certain player that can see a certain tile if we want to use incremental LOS.
public:
bool m_MapRevealed; // Set to true to ignore LOS
CLOSManager();
~CLOSManager();
void Initialize();
void Update();
// Get LOS status for a tile (in tile coordinates)
ELOSStatus GetStatus(int tx, int tz, CPlayer* player);
// Get LOS status for a point (in game coordinates)
ELOSStatus GetStatus(float fx, float fz, CPlayer* player);
// Returns whether a given entity is visible to the given player
EUnitLOSStatus GetUnitStatus(CUnit* unit, CPlayer* player);
};
#endif