AOS Fog of War
Loading...
Searching...
No Matches
FischlWorks_FogWar.csFogWar Class Reference

The non-static high-level monobehaviour interface of the AOS Fog of War module. More...

Inheritance diagram for FischlWorks_FogWar.csFogWar:

Classes

class  FogRevealer
 
class  LevelColumn
 
class  LevelData
 

Public Member Functions

int AddFogRevealer (FogRevealer fogRevealer)
 Adds a new FogRevealer instance to the list and returns its index.
 
bool CheckLevelGridRange (Vector2Int levelCoordinates)
 Checks if the given level coordinates are within level dimension range.
 
bool CheckVisibility (Vector3 worldCoordinates, int additionalRadius)
 Checks if the given pair of world coordinates and additionalRadius is visible by FogRevealers.
 
bool CheckWorldGridRange (Vector3 worldCoordinates)
 Checks if the given world coordinates are within level dimension range.
 
Vector2Int GetUnitVector (Vector3 worldCoordinates)
 Converts "pure" world coordinates into unit world coordinates.
 
int GetUnitX (float xValue)
 Converts world coordinate to unit world coordinates.
 
int GetUnitY (float yValue)
 Converts world coordinate to unit world coordinates.
 
Vector3 GetWorldVector (Vector2Int worldCoordinates)
 Converts level coordinates into world coordinates.
 
float GetWorldX (int xValue)
 Converts level coordinate to corresponding unit world coordinates.
 
float GetWorldY (int yValue)
 Converts level coordinate to corresponding unit world coordinates.
 
void RemoveFogRevealer (int revealerIndex)
 Removes a FogRevealer instance from the list with index.
 
void ReplaceFogRevealerList (List< FogRevealer > fogRevealers)
 Replaces the FogRevealer list with the given one.
 
Vector2Int WorldToLevel (Vector3 worldCoordinates)
 Converts unit (divided by unitScale, then rounded) world coordinates to level coordinates.
 

Properties

List< FogRevealer_FogRevealers [get]
 
Transform _LevelMidPoint [get]
 
float _UnitScale [get]
 
LevelData levelData = new LevelData() [get]
 
Shadowcaster shadowcaster = new Shadowcaster() [get]
 

Detailed Description

The non-static high-level monobehaviour interface of the AOS Fog of War module.

This class holds serialized data for various configuration properties,
and is resposible for scanning / saving / loading the LevelData object.
The class handles the update frequency of the fog, plus some shader businesses.
Various public interfaces related to FogRevealer's FOV are also available.

Member Function Documentation

◆ AddFogRevealer()

int FischlWorks_FogWar.csFogWar.AddFogRevealer ( FogRevealer  fogRevealer)
inline

Adds a new FogRevealer instance to the list and returns its index.

601 {
602 fogRevealers.Add(fogRevealer);
603
604 return fogRevealers.Count - 1;
605 }

◆ CheckLevelGridRange()

bool FischlWorks_FogWar.csFogWar.CheckLevelGridRange ( Vector2Int  levelCoordinates)
inline

Checks if the given level coordinates are within level dimension range.

634 {
635 bool result =
636 levelCoordinates.x >= 0 &&
637 levelCoordinates.x < levelData.levelDimensionX &&
638 levelCoordinates.y >= 0 &&
639 levelCoordinates.y < levelData.levelDimensionY;
640
641 if (result == false && LogOutOfRange == true)
642 {
643 Debug.LogFormat("Level coordinates \"{0}\" is out of grid range", levelCoordinates);
644 }
645
646 return result;
647 }
int levelDimensionY
Definition: csFogWar.cs:78
LevelData levelData
Definition: csFogWar.cs:264

Referenced by FischlWorks_FogWar.csFogWar.CheckVisibility(), and FischlWorks_FogWar.csFogWar.CheckWorldGridRange().

◆ CheckVisibility()

bool FischlWorks_FogWar.csFogWar.CheckVisibility ( Vector3  worldCoordinates,
int  additionalRadius 
)
inline

Checks if the given pair of world coordinates and additionalRadius is visible by FogRevealers.

663 {
664 Vector2Int levelCoordinates = WorldToLevel(worldCoordinates);
665
666 if (additionalRadius == 0)
667 {
668 return shadowcaster.fogField[levelCoordinates.x][levelCoordinates.y] ==
669 Shadowcaster.LevelColumn.ETileVisibility.Revealed;
670 }
671
672 int scanResult = 0;
673
674 for (int xIterator = -1; xIterator < additionalRadius + 1; xIterator++)
675 {
676 for (int yIterator = -1; yIterator < additionalRadius + 1; yIterator++)
677 {
678 if (CheckLevelGridRange(new Vector2Int(
679 levelCoordinates.x + xIterator,
680 levelCoordinates.y + yIterator)) == false)
681 {
682 scanResult = 0;
683
684 break;
685 }
686
687 scanResult += Convert.ToInt32(
688 shadowcaster.fogField[levelCoordinates.x + xIterator][levelCoordinates.y + yIterator] ==
689 Shadowcaster.LevelColumn.ETileVisibility.Revealed);
690 }
691 }
692
693 if (scanResult > 0)
694 {
695 return true;
696 }
697
698 return false;
699 }
FogField fogField
Definition: Shadowcaster.cs:290
bool CheckLevelGridRange(Vector2Int levelCoordinates)
Checks if the given level coordinates are within level dimension range.
Definition: csFogWar.cs:633
Shadowcaster shadowcaster
Definition: csFogWar.cs:262
Vector2Int WorldToLevel(Vector3 worldCoordinates)
Converts unit (divided by unitScale, then rounded) world coordinates to level coordinates.
Definition: csFogWar.cs:704

◆ CheckWorldGridRange()

bool FischlWorks_FogWar.csFogWar.CheckWorldGridRange ( Vector3  worldCoordinates)
inline

Checks if the given world coordinates are within level dimension range.

653 {
654 Vector2Int levelCoordinates = WorldToLevel(worldCoordinates);
655
656 return CheckLevelGridRange(levelCoordinates);
657 }

◆ GetUnitVector()

Vector2Int FischlWorks_FogWar.csFogWar.GetUnitVector ( Vector3  worldCoordinates)
inline

Converts "pure" world coordinates into unit world coordinates.

728 {
729 return new Vector2Int(GetUnitX(worldCoordinates.x), GetUnitY(worldCoordinates.z));
730 }
int GetUnitX(float xValue)
Converts world coordinate to unit world coordinates.
Definition: csFogWar.cs:748
int GetUnitY(float yValue)
Converts world coordinate to unit world coordinates.
Definition: csFogWar.cs:769

Referenced by FischlWorks_FogWar.csFogWar.WorldToLevel().

◆ GetUnitX()

int FischlWorks_FogWar.csFogWar.GetUnitX ( float  xValue)
inline

Converts world coordinate to unit world coordinates.

749 {
750 return Mathf.RoundToInt((xValue - levelMidPoint.position.x) / unitScale);
751 }

Referenced by FischlWorks_FogWar.csFogWar.FogRevealer.GetCurrentLevelCoordinates(), and FischlWorks_FogWar.csFogWar.GetUnitVector().

◆ GetUnitY()

int FischlWorks_FogWar.csFogWar.GetUnitY ( float  yValue)
inline

Converts world coordinate to unit world coordinates.

770 {
771 return Mathf.RoundToInt((yValue - levelMidPoint.position.z) / unitScale);
772 }

Referenced by FischlWorks_FogWar.csFogWar.FogRevealer.GetCurrentLevelCoordinates(), and FischlWorks_FogWar.csFogWar.GetUnitVector().

◆ GetWorldVector()

Vector3 FischlWorks_FogWar.csFogWar.GetWorldVector ( Vector2Int  worldCoordinates)
inline

Converts level coordinates into world coordinates.

717 {
718 return new Vector3(
719 GetWorldX(worldCoordinates.x + (levelDimensionX / 2)),
720 0,
721 GetWorldY(worldCoordinates.y + (levelDimensionY / 2)));
722 }
float GetWorldX(int xValue)
Converts level coordinate to corresponding unit world coordinates.
Definition: csFogWar.cs:735
float GetWorldY(int yValue)
Converts level coordinate to corresponding unit world coordinates.
Definition: csFogWar.cs:756

◆ GetWorldX()

float FischlWorks_FogWar.csFogWar.GetWorldX ( int  xValue)
inline

Converts level coordinate to corresponding unit world coordinates.

736 {
737 if (levelData.levelDimensionX % 2 == 0)
738 {
739 return (levelMidPoint.position.x - ((levelDimensionX / 2.0f) - xValue) * unitScale);
740 }
741
742 return (levelMidPoint.position.x - ((levelDimensionX / 2.0f) - (xValue + 0.5f)) * unitScale);
743 }
int levelDimensionX
Definition: csFogWar.cs:77

Referenced by FischlWorks_FogWar.csFogWar.GetWorldVector().

◆ GetWorldY()

float FischlWorks_FogWar.csFogWar.GetWorldY ( int  yValue)
inline

Converts level coordinate to corresponding unit world coordinates.

757 {
758 if (levelData.levelDimensionY % 2 == 0)
759 {
760 return (levelMidPoint.position.z - ((levelDimensionY / 2.0f) - yValue) * unitScale);
761 }
762
763 return (levelMidPoint.position.z - ((levelDimensionY / 2.0f) - (yValue + 0.5f)) * unitScale);
764 }

Referenced by FischlWorks_FogWar.csFogWar.GetWorldVector().

◆ RemoveFogRevealer()

void FischlWorks_FogWar.csFogWar.RemoveFogRevealer ( int  revealerIndex)
inline

Removes a FogRevealer instance from the list with index.

611 {
612 if (fogRevealers.Count > revealerIndex && revealerIndex > -1)
613 {
614 fogRevealers.RemoveAt(revealerIndex);
615 }
616 else
617 {
618 Debug.LogFormat("Given index of {0} exceeds the revealers' container range", revealerIndex);
619 }
620 }

◆ ReplaceFogRevealerList()

void FischlWorks_FogWar.csFogWar.ReplaceFogRevealerList ( List< FogRevealer fogRevealers)
inline

Replaces the FogRevealer list with the given one.

626 {
627 this.fogRevealers = fogRevealers;
628 }

◆ WorldToLevel()

Vector2Int FischlWorks_FogWar.csFogWar.WorldToLevel ( Vector3  worldCoordinates)
inline

Converts unit (divided by unitScale, then rounded) world coordinates to level coordinates.

705 {
706 Vector2Int unitWorldCoordinates = GetUnitVector(worldCoordinates);
707
708 return new Vector2Int(
709 unitWorldCoordinates.x + (levelDimensionX / 2),
710 unitWorldCoordinates.y + (levelDimensionY / 2));
711 }
Vector2Int GetUnitVector(Vector3 worldCoordinates)
Converts "pure" world coordinates into unit world coordinates.
Definition: csFogWar.cs:727

Referenced by FischlWorks_FogWar.csFogWar.CheckVisibility(), and FischlWorks_FogWar.csFogWar.CheckWorldGridRange().

Property Documentation

◆ _FogRevealers

List<FogRevealer> FischlWorks_FogWar.csFogWar._FogRevealers
get

◆ _LevelMidPoint

Transform FischlWorks_FogWar.csFogWar._LevelMidPoint
get

◆ _UnitScale

float FischlWorks_FogWar.csFogWar._UnitScale
get

◆ levelData

◆ shadowcaster

Shadowcaster FischlWorks_FogWar.csFogWar.shadowcaster = new Shadowcaster()
get
262{ get; private set; } = new Shadowcaster();

Referenced by FischlWorks_FogWar.csFogWar.CheckVisibility().


The documentation for this class was generated from the following file: