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

Classes

class  Item
 
class  MapPath
 

Public Types

enum  Type {
  Any , Deco , Treasure , Trap ,
  Concert , Farm
}
 

Public Member Functions

PartialMap GetMap (Type type, string tag, float ruin)
 
void Init ()
 
void Reset ()
 

Public Attributes

List< Itemitems
 

Static Public Attributes

static bool initialized
 
static Dictionary< string, PartialMapCacheMap = new Dictionary<string, PartialMap>()
 

Properties

static MapPiece Instance [get]
 
static bool IsEditor [get]
 

Static Private Attributes

static MapPiece _Instance
 

Additional Inherited Members

- Static Public Member Functions inherited from EScriptable
static int rnd (int a)
 

Detailed Description

Definition at line 6 of file MapPiece.cs.

Member Enumeration Documentation

◆ Type

Enumerator
Any 
Deco 
Treasure 
Trap 
Concert 
Farm 

Definition at line 15 of file MapPiece.cs.

Member Function Documentation

◆ GetMap()

PartialMap MapPiece.GetMap ( Type  type,
string  tag,
float  ruin 
)
inline

Definition at line 49 of file MapPiece.cs.

50 {
51 Init();
52 Item item = items.RandomItemWeighted((Item a) => (a.chance != 0f || !(type.ToString() == a.id)) ? (a.chance * (float)((type == Type.Any || type.ToString() == a.id) ? 1 : 0)) : 1f);
53 if (item.paths.Count == 0)
54 {
55 Debug.Log("no path");
56 return null;
57 }
58 string[] array = (tag.IsEmpty() ? null : tag.Split(','));
59 List<MapPath> list = new List<MapPath>();
60 foreach (MapPath path2 in item.paths)
61 {
62 if (path2.tag.IsEmpty() || (array != null && array.Contains(tag)))
63 {
64 list.Add(path2);
65 }
66 }
67 if (list.Count == 0)
68 {
69 return null;
70 }
71 string path = list.RandomItem().path;
72 Debug.Log("Loading PartialMap:" + path);
73 PartialMap partialMap = CacheMap.TryGetValue(path);
74 if (partialMap == null)
75 {
76 partialMap = PartialMap.Load(path);
77 CacheMap.Add(path, partialMap);
78 }
79 if (partialMap.allowRotate)
80 {
81 partialMap.dir = EScriptable.rnd(4);
82 }
83 partialMap.procedural = true;
84 partialMap.ruinChance = ruin;
85 return partialMap;
86 }
static int rnd(int a)
Definition: EScriptable.cs:5
static Dictionary< string, PartialMap > CacheMap
Definition: MapPiece.cs:43
void Init()
Definition: MapPiece.cs:88
List< Item > items
Definition: MapPiece.cs:41
bool allowRotate
Definition: PartialMap.cs:55
static PartialMap Load(string path=null)
Definition: PartialMap.cs:448

References PartialMap.allowRotate, CacheMap, MapPiece.Item.chance, Debug, MapPiece.Item.id, Init(), item, items, PartialMap.Load(), EScriptable.rnd(), and MapPiece.MapPath.tag.

Referenced by GenBounds.TryAddMapPiece().

◆ Init()

void MapPiece.Init ( )
inline

Definition at line 88 of file MapPiece.cs.

89 {
90 if (initialized)
91 {
92 return;
93 }
94 foreach (Item item in items)
95 {
96 item.paths.Clear();
97 string[] files = Directory.GetFiles(CorePath.MapPieceSave + item.id, "*", SearchOption.AllDirectories);
98 foreach (string text in files)
99 {
100 if (text.EndsWith("mp"))
101 {
102 DirectoryInfo directory = new FileInfo(text).Directory;
103 string tag = ((directory.Parent.Name != item.id) ? "" : directory.Name);
104 item.paths.Add(new MapPath
105 {
106 path = text,
107 tag = tag
108 });
109 }
110 }
111 }
112 initialized = true;
113 }
static string MapPieceSave
Definition: CorePath.cs:200
static bool initialized
Definition: MapPiece.cs:39

References initialized, item, items, and CorePath.MapPieceSave.

Referenced by GetMap().

◆ Reset()

void MapPiece.Reset ( )
inline

Definition at line 115 of file MapPiece.cs.

116 {
117 initialized = false;
118 }

References initialized.

Member Data Documentation

◆ _Instance

MapPiece MapPiece._Instance
staticprivate

Definition at line 37 of file MapPiece.cs.

◆ CacheMap

Dictionary<string, PartialMap> MapPiece.CacheMap = new Dictionary<string, PartialMap>()
static

Definition at line 43 of file MapPiece.cs.

Referenced by PartialMapMenu.Activate(), and GetMap().

◆ initialized

bool MapPiece.initialized
static

Definition at line 39 of file MapPiece.cs.

Referenced by Init(), and Reset().

◆ items

List<Item> MapPiece.items

Definition at line 41 of file MapPiece.cs.

Referenced by GetMap(), and Init().

Property Documentation

◆ Instance

MapPiece MapPiece.Instance
staticget

Definition at line 45 of file MapPiece.cs.

Referenced by GenBounds.TryAddMapPiece().

◆ IsEditor

bool MapPiece.IsEditor
staticget

Definition at line 47 of file MapPiece.cs.

Referenced by UIScreenshot.Activate(), AM_Copy.OnAfterProcessTiles(), and AM_Copy.OnSave().


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