Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
Fov Class Reference
Inheritance diagram for Fov:
EClass

Classes

struct  LevelPoint
 

Public Member Functions

void SetVisible (int x, int y)
 
void ClearVisible ()
 
List< PointListPoints ()
 
void Perform (int _x, int _z, int _range, float power=1f)
 

Static Public Member Functions

static float DistanceFloat (int x1, int y1, int x2, int y2)
 
static int Distance (int x1, int y1, int x2, int y2)
 
- Static Public Member Functions inherited from EClass
static int rnd (int a)
 
static int curve (int a, int start, int step, int rate=75)
 
static int rndHalf (int a)
 
static float rndf (float a)
 
static int rndSqrt (int a)
 
static void Wait (float a, Card c)
 
static void Wait (float a, Point p)
 
static int Bigger (int a, int b)
 
static int Smaller (int a, int b)
 

Public Attributes

byte r
 
byte g
 
byte b
 
bool isPC
 
bool limitGradient
 
Dictionary< int, byte > lastPoints = new Dictionary<int, byte>()
 

Static Public Attributes

static float nonGradientMod
 
static List< CellnewPoints = new List<Cell>()
 
static Map map
 
static LevelPoint origin = default(LevelPoint)
 
static int range
 
static float _power
 
- Static Public Attributes inherited from EClass
static Core core
 

Private Member Functions

float GetVisDistance (int x1, int y1, int x2, int y2)
 
void TraceLine (int x2, int y2)
 

Static Private Attributes

static int x
 
static int y
 

Additional Inherited Members

- Properties inherited from EClass
static Game game [get]
 
static bool AdvMode [get]
 
static Player player [get]
 
static Chara pc [get]
 
static UI ui [get]
 
static Map _map [get]
 
static Zone _zone [get]
 
static FactionBranch Branch [get]
 
static FactionBranch BranchOrHomeBranch [get]
 
static Faction Home [get]
 
static Faction Wilds [get]
 
static Scene scene [get]
 
static BaseGameScreen screen [get]
 
static GameSetting setting [get]
 
static GameData gamedata [get]
 
static ColorProfile Colors [get]
 
static World world [get]
 
static SourceManager sources [get]
 
static SourceManager editorSources [get]
 
static SoundManager Sound [get]
 
static CoreDebug debug [get]
 

Detailed Description

Definition at line 5 of file Fov.cs.

Member Function Documentation

◆ ClearVisible()

void Fov.ClearVisible ( )
inline

Definition at line 96 of file Fov.cs.

97 {
98 foreach (KeyValuePair<int, byte> lastPoint in lastPoints)
99 {
100 Cell cell = map.GetCell(lastPoint.Key);
101 byte value = lastPoint.Value;
102 cell.light -= value;
103 cell.lightR -= (ushort)(value * r / 2);
104 cell.lightG -= (ushort)(value * g / 2);
105 cell.lightB -= (ushort)(value * b / 2);
106 if (isPC)
107 {
108 cell.pcSync = false;
109 }
110 }
111 lastPoints.Clear();
112 }
Definition: Cell.cs:7
bool isPC
Definition: Fov.cs:32
byte b
Definition: Fov.cs:30
byte g
Definition: Fov.cs:28
Dictionary< int, byte > lastPoints
Definition: Fov.cs:36
static Map map
Definition: Fov.cs:18
byte r
Definition: Fov.cs:26
Cell GetCell(int index)
Definition: Map.cs:881

References b, g, Map.GetCell(), isPC, lastPoints, map, and r.

Referenced by Perform().

◆ Distance()

static int Fov.Distance ( int  x1,
int  y1,
int  x2,
int  y2 
)
inlinestatic

Definition at line 134 of file Fov.cs.

135 {
136 return (int)Mathf.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
137 }

Referenced by Spatial.Dist(), and Point.Distance().

◆ DistanceFloat()

static float Fov.DistanceFloat ( int  x1,
int  y1,
int  x2,
int  y2 
)
inlinestatic

Definition at line 129 of file Fov.cs.

130 {
131 return Mathf.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
132 }

Referenced by TileMapElona.DrawTile().

◆ GetVisDistance()

float Fov.GetVisDistance ( int  x1,
int  y1,
int  x2,
int  y2 
)
inlineprivate

Definition at line 124 of file Fov.cs.

125 {
126 return Mathf.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
127 }

Referenced by Perform(), SetVisible(), and TraceLine().

◆ ListPoints()

List< Point > Fov.ListPoints ( )
inline

Definition at line 114 of file Fov.cs.

115 {
116 List<Point> list = new List<Point>();
117 foreach (KeyValuePair<int, byte> lastPoint in lastPoints)
118 {
119 list.Add(new Point(lastPoint.Key));
120 }
121 return list;
122 }
Definition: Point.cs:9

References lastPoints.

Referenced by AI_Fish.Run().

◆ Perform()

void Fov.Perform ( int  _x,
int  _z,
int  _range,
float  power = 1f 
)
inline

Definition at line 139 of file Fov.cs.

140 {
141 range = _range;
142 ClearVisible();
143 if (range == 0)
144 {
145 return;
146 }
147 _power = power;
148 origin.X = _x;
149 origin.Y = _z;
151 int num = origin.X - range;
152 if (num < 0)
153 {
154 num = 0;
155 }
156 int num2 = origin.Y - range;
157 if (num2 < 0)
158 {
159 num2 = 0;
160 }
161 int num3 = origin.X + range + 1;
162 if (num3 >= EClass._map.Size)
163 {
164 num3 = EClass._map.Size;
165 }
166 int num4 = origin.Y + range + 1;
167 if (num4 >= EClass._map.Size)
168 {
169 num4 = EClass._map.Size;
170 }
171 for (int i = num; i < num3; i++)
172 {
173 TraceLine(i, num2);
174 TraceLine(i, num4 - 1);
175 }
176 for (int j = num2 + 1; j < num4 - 1; j++)
177 {
178 TraceLine(num, j);
179 TraceLine(num3 - 1, j);
180 }
181 if (range >= 6)
182 {
183 int max = EClass._map.Size - 1;
184 int x = (origin.X + 4).ClampMax(max);
185 int y = (origin.Y + 1).ClampMax(max);
186 int x2 = (origin.X - 4).ClampMin(0);
187 int y2 = (origin.Y - 1).ClampMin(0);
188 int x3 = (origin.X + 1).ClampMax(max);
189 int y3 = (origin.Y + 4).ClampMax(max);
190 int x4 = (origin.X - 1).ClampMin(0);
191 int y4 = (origin.Y - 4).ClampMin(0);
192 TraceLine(x, y);
193 TraceLine(x, y2);
194 TraceLine(x2, y);
195 TraceLine(x2, y2);
196 TraceLine(x3, y3);
197 TraceLine(x3, y4);
198 TraceLine(x4, y3);
199 TraceLine(x4, y4);
200 }
201 foreach (KeyValuePair<int, byte> lastPoint in lastPoints)
202 {
203 Cell cell = map.GetCell(lastPoint.Key);
204 byte value = lastPoint.Value;
205 cell.light += value;
206 cell.lightR += (ushort)(value * r / 2);
207 cell.lightG += (ushort)(value * g / 2);
208 cell.lightB += (ushort)(value * b / 2);
209 if (isPC && (value > 0 || GetVisDistance(origin.X, origin.Y, cell.x, cell.z) < 2f) && !cell.isSeen && (!cell.HasWall || EClass._zone.UseFog || cell.room == EClass.pc.Cell.room || cell.hasDoor))
210 {
211 EClass._map.SetSeen(cell.x, cell.z);
212 newPoints.Add(cell);
213 }
214 }
215 if (isPC && newPoints.Count > 0)
216 {
218 }
219 }
Cell Cell
Definition: Card.cs:1931
Room room
Definition: Cell.cs:102
bool HasWall
Definition: Cell.cs:833
byte z
Definition: Cell.cs:58
bool isSeen
Definition: Cell.cs:282
byte x
Definition: Cell.cs:56
bool hasDoor
Definition: Cell.cs:258
Definition: EClass.cs:5
static Zone _zone
Definition: EClass.cs:20
static Map _map
Definition: EClass.cs:18
static Chara pc
Definition: EClass.cs:14
static List< Cell > newPoints
Definition: Fov.cs:16
void SetVisible(int x, int y)
Definition: Fov.cs:42
static int y
Definition: Fov.cs:40
static LevelPoint origin
Definition: Fov.cs:20
void ClearVisible()
Definition: Fov.cs:96
float GetVisDistance(int x1, int y1, int x2, int y2)
Definition: Fov.cs:124
void TraceLine(int x2, int y2)
Definition: Fov.cs:221
static float _power
Definition: Fov.cs:24
static int range
Definition: Fov.cs:22
static int x
Definition: Fov.cs:38
int Size
Definition: MapBounds.cs:20
void SetSeen(int x, int z, bool seen=true, bool refresh=true)
Definition: Map.cs:886
static void UpdateMap(List< Cell > newPoints)
virtual bool UseFog
Definition: Zone.cs:384
int X
Definition: Fov.cs:9
int Y
Definition: Fov.cs:11

References EClass._map, _power, EClass._zone, b, Card.Cell, ClearVisible(), g, Map.GetCell(), GetVisDistance(), Cell.hasDoor, Cell.HasWall, isPC, Cell.isSeen, lastPoints, map, newPoints, origin, EClass.pc, r, range, Cell.room, Map.SetSeen(), SetVisible(), MapBounds.Size, TraceLine(), WidgetMinimap.UpdateMap(), Zone.UseFog, Cell.x, Fov.LevelPoint.X, x, Fov.LevelPoint.Y, y, and Cell.z.

Referenced by Card.CalculateFOV(), and Card.ClearFOV().

◆ SetVisible()

void Fov.SetVisible ( int  x,
int  y 
)
inline

Definition at line 42 of file Fov.cs.

43 {
44 Cell cell = map.cells[x, y];
45 if (cell.light > 100 && !isPC)
46 {
47 return;
48 }
49 int key = x + y * map.Size;
50 if (isPC && !cell.outOfBounds)
51 {
52 cell.pcSync = true;
53 }
54 if (_power < 0.1f)
55 {
56 lastPoints[key] = 0;
57 return;
58 }
59 float num = GetVisDistance(x, y, origin.X, origin.Y);
60 float power = _power;
61 if (limitGradient)
62 {
63 power *= nonGradientMod;
64 if (num >= (float)range)
65 {
66 power *= EClass.scene.profile.global.edgeLight;
67 }
68 }
69 else
70 {
71 if (num <= 1f)
72 {
73 num = 1f;
74 }
75 power *= (float)(range + 1) - num;
76 }
77 if (power < 1f)
78 {
79 power = 1f;
80 }
81 else if (power > 20f)
82 {
83 power = 20f;
84 }
85 if (cell.outOfBounds)
86 {
87 if (isPC && (power > 0f || GetVisDistance(origin.X, origin.Y, x, y) < 4f))
88 {
89 cell.isSeen = true;
90 }
91 power = 0f;
92 }
93 lastPoints[key] = (byte)power;
94 }
byte light
Definition: Cell.cs:60
bool outOfBounds
Definition: Cell.cs:414
static Scene scene
Definition: EClass.cs:30
bool limitGradient
Definition: Fov.cs:34
static float nonGradientMod
Definition: Fov.cs:14
Cell[,] cells
Definition: Map.cs:85
SceneGlobalProfile global
Definition: SceneProfile.cs:6
SceneProfile profile
Definition: Scene.cs:73

References _power, Map.cells, GetVisDistance(), SceneProfile.global, isPC, lastPoints, Cell.light, limitGradient, map, nonGradientMod, origin, Cell.outOfBounds, Scene.profile, range, EClass.scene, MapBounds.Size, Fov.LevelPoint.X, x, Fov.LevelPoint.Y, and y.

Referenced by Perform(), and TraceLine().

◆ TraceLine()

void Fov.TraceLine ( int  x2,
int  y2 
)
inlineprivate

Definition at line 221 of file Fov.cs.

222 {
223 int value = x2 - origin.X;
224 int value2 = y2 - origin.Y;
225 int num = Math.Abs(value);
226 int num2 = Math.Abs(value2);
227 int num3 = Math.Sign(value);
228 int num4 = Math.Sign(value2) << 16;
229 int num5 = (origin.Y << 16) + origin.X;
230 if (num < num2)
231 {
232 int num6 = num;
233 num = num2;
234 num2 = num6;
235 int num7 = num3;
236 num3 = num4;
237 num4 = num7;
238 }
239 int num8 = num2 * 2;
240 int num9 = -num;
241 int num10 = num * 2;
242 while (--num >= 0)
243 {
244 num5 += num3;
245 num9 += num8;
246 if (num9 > 0)
247 {
248 num9 -= num10;
249 num5 += num4;
250 }
251 x = num5 & 0xFFFF;
252 y = num5 >> 16;
253 int num11 = (int)GetVisDistance(origin.X, origin.Y, x, y);
254 if (range < 0 || num11 <= range)
255 {
256 SetVisible(x, y);
257 if (map.cells[x, y].blockSight)
258 {
259 break;
260 }
261 continue;
262 }
263 break;
264 }
265 }
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
Definition: UIBook.cs:627
bool blockSight
Definition: Cell.cs:318

References Cell.blockSight, Map.cells, GetVisDistance(), if(), map, origin, range, SetVisible(), Fov.LevelPoint.X, x, Fov.LevelPoint.Y, and y.

Referenced by Perform().

Member Data Documentation

◆ _power

float Fov._power
static

Definition at line 24 of file Fov.cs.

Referenced by Perform(), and SetVisible().

◆ b

byte Fov.b

Definition at line 30 of file Fov.cs.

Referenced by ClearVisible(), Card.CreateFov(), and Perform().

◆ g

byte Fov.g

Definition at line 28 of file Fov.cs.

Referenced by ClearVisible(), Card.CreateFov(), and Perform().

◆ isPC

bool Fov.isPC

Definition at line 32 of file Fov.cs.

Referenced by ClearVisible(), Perform(), and SetVisible().

◆ lastPoints

Dictionary<int, byte> Fov.lastPoints = new Dictionary<int, byte>()

◆ limitGradient

bool Fov.limitGradient

Definition at line 34 of file Fov.cs.

Referenced by SetVisible().

◆ map

Map Fov.map
static

Definition at line 18 of file Fov.cs.

Referenced by ClearVisible(), Perform(), SetVisible(), and TraceLine().

◆ newPoints

List<Cell> Fov.newPoints = new List<Cell>()
static

Definition at line 16 of file Fov.cs.

Referenced by Perform().

◆ nonGradientMod

float Fov.nonGradientMod
static

Definition at line 14 of file Fov.cs.

Referenced by SetVisible().

◆ origin

LevelPoint Fov.origin = default(LevelPoint)
static

Definition at line 20 of file Fov.cs.

Referenced by Perform(), SetVisible(), and TraceLine().

◆ r

byte Fov.r

Definition at line 26 of file Fov.cs.

Referenced by ClearVisible(), Card.CreateFov(), and Perform().

◆ range

int Fov.range
static

Definition at line 22 of file Fov.cs.

Referenced by Perform(), SetVisible(), and TraceLine().

◆ x

int Fov.x
staticprivate

Definition at line 38 of file Fov.cs.

Referenced by Perform(), SetVisible(), and TraceLine().

◆ y

int Fov.y
staticprivate

Definition at line 40 of file Fov.cs.

Referenced by Perform(), SetVisible(), and TraceLine().


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