Elin Decompiled Documentation EA 23.343.5 Nightly
Loading...
Searching...
No Matches
TileLookup< T > Class Template Reference

Public Member Functions

 TileLookup (Dictionary< int, T > rowsById)
 
void Build ()
 

Properties

this[int id] [get]
 

Private Member Functions

Resolve (int id)
 

Private Attributes

readonly Dictionary< int, T > _map
 
T[] _builtin = Array.Empty<T>()
 
_fallback
 
HashSet< int > _missing
 

Static Private Attributes

const int DefaultRange = 1024
 

Detailed Description

Type Constraints
T :SourceData.BaseRow 

Definition at line 6 of file TileLookup.cs.

Constructor & Destructor Documentation

◆ TileLookup()

TileLookup< T >.TileLookup ( Dictionary< int, T >  rowsById)
inline

Definition at line 35 of file TileLookup.cs.

36 {
37 _map = rowsById;
38 }
readonly Dictionary< int, T > _map
Definition: TileLookup.cs:10

References TileLookup< T >._map.

Member Function Documentation

◆ Build()

void TileLookup< T >.Build ( )
inline

Definition at line 40 of file TileLookup.cs.

41 {
42 _missing = null;
43 _fallback = _map.TryGetValue(0);
44 int maxId = -1;
45 foreach (int item in _map.Keys.Where((int id) => id > maxId && id < 1024))
46 {
47 maxId = item;
48 }
49 _builtin = ((maxId < 0) ? Array.Empty<T>() : new T[maxId + 1]);
50 foreach (KeyValuePair<int, T> item2 in _map.Where((KeyValuePair<int, T> kv) => kv.Key <= maxId))
51 {
52 _builtin[item2.Key] = item2.Value;
53 }
54 }
HashSet< int > _missing
Definition: TileLookup.cs:16
T[] _builtin
Definition: TileLookup.cs:12

References TileLookup< T >._builtin, TileLookup< T >._fallback, TileLookup< T >._map, TileLookup< T >._missing, and item.

◆ Resolve()

T TileLookup< T >.Resolve ( int  id)
inlineprivate

Definition at line 56 of file TileLookup.cs.

57 {
58 if (_map.TryGetValue(id, out var value))
59 {
60 return value;
61 }
62 if (_missing == null)
63 {
64 _missing = new HashSet<int>();
65 }
66 if (_missing.Add(id))
67 {
68 Debug.LogWarning($"#source missing tile row: {typeof(T).DeclaringType?.Name}#{id}");
69 }
70 return _fallback ?? _map.TryGetValue(0);
71 }

References $, TileLookup< T >._fallback, TileLookup< T >._map, TileLookup< T >._missing, and Debug.

Member Data Documentation

◆ _builtin

T [] TileLookup< T >._builtin = Array.Empty<T>()
private

Definition at line 12 of file TileLookup.cs.

Referenced by TileLookup< T >.Build().

◆ _fallback

T TileLookup< T >._fallback
private

Definition at line 14 of file TileLookup.cs.

Referenced by TileLookup< T >.Build(), and TileLookup< T >.Resolve().

◆ _map

readonly Dictionary<int, T> TileLookup< T >._map
private

◆ _missing

HashSet<int> TileLookup< T >._missing
private

Definition at line 16 of file TileLookup.cs.

Referenced by TileLookup< T >.Build(), and TileLookup< T >.Resolve().

◆ DefaultRange

const int TileLookup< T >.DefaultRange = 1024
staticprivate

Definition at line 8 of file TileLookup.cs.

Property Documentation

◆ this[int id]

T TileLookup< T >.this[int id]
get

Definition at line 18 of file TileLookup.cs.

19 {
20 get
21 {
22 T[] builtin = _builtin;
23 if ((uint)id < (uint)builtin.Length)
24 {
25 T val = builtin[id];
26 if (val != null)
27 {
28 return val;
29 }
30 }
31 return Resolve(id);
32 }
33 }
T Resolve(int id)
Definition: TileLookup.cs:56

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