Elin Decompiled Documentation EA 23.102 Nightly
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Pages
GenBounds Class Reference
Inheritance diagram for GenBounds:
EClass BaseMapGen GenRoom MapGen MapGenDungen MapGenRegion GenRoomBig GenRoomMonsterHouse

Public Member Functions

void SetFloor (BiomeProfile.Tile t, int x, int z)
 
void SetBlock (BiomeProfile.Tile t, int x, int z, int idMat=-1)
 
void SetFloor (int x, int z, int idMat, int idFloor, int direction=0)
 
void SetBlock (int x, int z, int idMat, int idBlock, int direction=0)
 
bool IsEmpty ()
 
List< PointListEmptyPoint ()
 
GenBounds GetBounds (int w, int h, bool ignoreBlock)
 
GenBounds GetBounds (Map map, Zone zone, int x, int y, int width, int height, int dw, int dh, bool ignoreBlock)
 
PartialMap TryAddMapPiece (MapPiece.Type type=MapPiece.Type.Any, float ruin=-1f, string tags=null, Action< PartialMap, GenBounds > onCreate=null)
 

Static Public Member Functions

static GenBounds Create (Zone z)
 
- 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

Map map
 
Zone zone
 
int Size
 
int x
 
int y
 
int width
 
int height
 
int marginPartial
 
Func< Cell, bool > FuncCheckEmpty
 

Private Member Functions

bool IsSub (BiomeProfile.Tile g, int x, int y)
 

Additional Inherited Members

- Static Public Attributes inherited from EClass
static Core core
 
- 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 GenBounds.cs.

Member Function Documentation

◆ Create()

static GenBounds GenBounds.Create ( Zone  z)
inlinestatic

Definition at line 123 of file GenBounds.cs.

124 {
125 MapBounds bounds = z.map.bounds;
126 return new GenBounds
127 {
128 zone = z,
129 map = z.map,
130 x = bounds.x,
131 y = bounds.z,
132 width = bounds.Width,
133 height = bounds.Height
134 };
135 }
int height
Definition: GenBounds.cs:19
int width
Definition: GenBounds.cs:17
Zone zone
Definition: GenBounds.cs:9
Map map
Definition: GenBounds.cs:7
int Width
Definition: MapBounds.cs:26
int x
Definition: MapBounds.cs:8
MapBounds bounds
Definition: Map.cs:52
Map map
Definition: Zone.cs:60

References Map.bounds, height, map, Zone.map, width, MapBounds.Width, x, MapBounds.x, y, MapBounds.z, and zone.

Referenced by ZoneEventHarvest.OnVisit(), and ZoneEventMusic.OnVisit().

◆ GetBounds() [1/2]

GenBounds GenBounds.GetBounds ( int  w,
int  h,
bool  ignoreBlock 
)
inline

Definition at line 137 of file GenBounds.cs.

138 {
139 return GetBounds(map, zone, x, y, width, height, w, h, ignoreBlock);
140 }
GenBounds GetBounds(int w, int h, bool ignoreBlock)
Definition: GenBounds.cs:137

References GetBounds(), height, map, width, x, y, and zone.

Referenced by GetBounds(), and TryAddMapPiece().

◆ GetBounds() [2/2]

GenBounds GenBounds.GetBounds ( Map  map,
Zone  zone,
int  x,
int  y,
int  width,
int  height,
int  dw,
int  dh,
bool  ignoreBlock 
)
inline

Definition at line 142 of file GenBounds.cs.

143 {
144 if (dw >= width || dh >= height)
145 {
146 return null;
147 }
148 GenBounds genBounds = new GenBounds
149 {
150 x = x,
151 y = y,
152 width = dw,
153 height = dh,
154 map = map,
155 zone = zone,
158 };
159 for (int i = 0; i < 200; i++)
160 {
161 if (ignoreBlock)
162 {
163 genBounds.x = EClass.rnd(width - dw) + x - dw / 2;
164 genBounds.y = EClass.rnd(height - dh) + y - dh / 2;
165 if (genBounds.x > 0 && genBounds.y > 0)
166 {
167 return genBounds;
168 }
169 }
170 else
171 {
172 genBounds.x = EClass.rnd(width - dw) + x;
173 genBounds.y = EClass.rnd(height - dh) + y;
174 if (genBounds.IsEmpty())
175 {
176 return genBounds;
177 }
178 }
179 }
180 return null;
181 }
Definition: EClass.cs:5
static int rnd(int a)
Definition: EClass.cs:50
Func< Cell, bool > FuncCheckEmpty
Definition: GenBounds.cs:23
bool IsEmpty()
Definition: GenBounds.cs:66
int marginPartial
Definition: GenBounds.cs:21

References FuncCheckEmpty, height, IsEmpty(), map, marginPartial, EClass.rnd(), width, x, y, and zone.

◆ IsEmpty()

bool GenBounds.IsEmpty ( )
inline

Definition at line 66 of file GenBounds.cs.

67 {
68 for (int i = y - marginPartial; i < y + height + marginPartial; i++)
69 {
70 if (i < 0 || i >= EClass._map.Size)
71 {
72 return false;
73 }
74 for (int j = x - marginPartial; j < x + width + marginPartial; j++)
75 {
76 if (j < 0 || j >= EClass._map.Size)
77 {
78 return false;
79 }
80 Cell cell = map.cells[j, i];
81 if (FuncCheckEmpty != null && !FuncCheckEmpty(cell))
82 {
83 return false;
84 }
85 if (cell.blocked || cell.HasBlock || cell.Installed != null)
86 {
87 return false;
88 }
89 }
90 }
91 return true;
92 }
Definition: Cell.cs:7
bool HasBlock
Definition: Cell.cs:643
Thing Installed
Definition: Cell.cs:975
static Map _map
Definition: EClass.cs:18
int Size
Definition: MapBounds.cs:20
Cell[,] cells
Definition: Map.cs:85

References EClass._map, Algorithms.WeightCell.blocked, Map.cells, FuncCheckEmpty, Cell.HasBlock, height, Cell.Installed, map, marginPartial, MapBounds.Size, width, x, and y.

Referenced by GetBounds().

◆ IsSub()

bool GenBounds.IsSub ( BiomeProfile::Tile  g,
int  x,
int  y 
)
inlineprivate

Definition at line 25 of file GenBounds.cs.

26 {
27 return g.subType switch
28 {
29 BiomeProfile.BaseTile.SubType.Rnd5 => EClass.rnd(5) == 0,
30 BiomeProfile.BaseTile.SubType.Rnd10 => EClass.rnd(10) == 0,
31 BiomeProfile.BaseTile.SubType.Rnd20 => EClass.rnd(20) == 0,
32 BiomeProfile.BaseTile.SubType.Pattern => (x + y % 2) % 2 == 0,
33 _ => false,
34 };
35 }

References EClass.rnd(), x, and y.

Referenced by SetBlock(), and SetFloor().

◆ ListEmptyPoint()

List< Point > GenBounds.ListEmptyPoint ( )
inline

Definition at line 94 of file GenBounds.cs.

95 {
96 List<Point> list = new List<Point>();
97 for (int i = y; i < y + height; i++)
98 {
99 if (i < 0 || i >= EClass._map.Size)
100 {
101 continue;
102 }
103 for (int j = x; j < x + width; j++)
104 {
105 if (j < 0 || j >= EClass._map.Size)
106 {
107 continue;
108 }
109 Cell cell = map.cells[j, i];
110 if (!cell.blocked && !cell.HasBlock && (cell.Installed == null || !cell.Installed.trait.IsBlockPath))
111 {
112 Point point = new Point(j, i);
113 if (!point.HasChara)
114 {
115 list.Add(point);
116 }
117 }
118 }
119 }
120 return list;
121 }
Trait trait
Definition: Card.cs:49
Definition: Point.cs:9
bool HasChara
Definition: Point.cs:226
virtual bool IsBlockPath
Definition: Trait.cs:52

References EClass._map, Algorithms.WeightCell.blocked, Map.cells, Cell.HasBlock, Point.HasChara, height, Cell.Installed, Trait.IsBlockPath, map, MapBounds.Size, Card.trait, width, x, and y.

Referenced by ZoneEventHarvest.OnVisit(), and ZoneEventMusic.OnVisit().

◆ SetBlock() [1/2]

void GenBounds.SetBlock ( BiomeProfile::Tile  t,
int  x,
int  z,
int  idMat = -1 
)
inline

Definition at line 43 of file GenBounds.cs.

44 {
45 bool flag = IsSub(t, x, z);
46 SetBlock(x, z, (idMat != -1) ? idMat : (flag ? t.matSub : t.mat), flag ? t.idSub : t.id);
47 }
void SetBlock(BiomeProfile.Tile t, int x, int z, int idMat=-1)
Definition: GenBounds.cs:43
bool IsSub(BiomeProfile.Tile g, int x, int y)
Definition: GenBounds.cs:25

References IsSub(), SetBlock(), and x.

Referenced by MapGen.MakeNeighbor(), MapGen.MakeNeighbor_old(), MapGen.MakeRoad(), MapGen.OnGenerateTerrain(), MapGenDungen.OnGenerateTerrain(), SetBlock(), and MapGen.TryMakeRiver().

◆ SetBlock() [2/2]

void GenBounds.SetBlock ( int  x,
int  z,
int  idMat,
int  idBlock,
int  direction = 0 
)
inline

Definition at line 57 of file GenBounds.cs.

58 {
59 Cell cell = map.cells[x, z];
60 cell._blockMat = (byte)idMat;
61 cell._block = (byte)idBlock;
62 cell.blockDir = direction;
63 cell.effect = null;
64 }

References Map.cells, map, and x.

◆ SetFloor() [1/2]

void GenBounds.SetFloor ( BiomeProfile::Tile  t,
int  x,
int  z 
)
inline

Definition at line 37 of file GenBounds.cs.

38 {
39 bool flag = IsSub(t, x, z);
40 SetFloor(x, z, flag ? t.matSub : t.mat, flag ? t.idSub : t.id, EClass.rnd(EClass.rnd(8) + 1));
41 }
void SetFloor(BiomeProfile.Tile t, int x, int z)
Definition: GenBounds.cs:37

References IsSub(), EClass.rnd(), SetFloor(), and x.

Referenced by MapGen.MakeNeighbor(), MapGen.MakeNeighbor_old(), MapGen.MakeRoad(), MapGen.OnGenerateTerrain(), MapGenDungen.OnGenerateTerrain(), MapGenRegion.OnGenerateTerrain(), SetFloor(), and MapGen.TryMakeRiver().

◆ SetFloor() [2/2]

void GenBounds.SetFloor ( int  x,
int  z,
int  idMat,
int  idFloor,
int  direction = 0 
)
inline

Definition at line 49 of file GenBounds.cs.

50 {
51 Cell cell = map.cells[x, z];
52 cell._floorMat = (byte)idMat;
53 cell._floor = (byte)idFloor;
54 cell.floorDir = direction;
55 }

References Map.cells, map, and x.

◆ TryAddMapPiece()

PartialMap GenBounds.TryAddMapPiece ( MapPiece::Type  type = MapPiece::Type::Any,
float  ruin = -1f,
string  tags = null,
Action< PartialMap, GenBounds onCreate = null 
)
inline

Definition at line 183 of file GenBounds.cs.

184 {
185 if (ruin == -1f)
186 {
187 ruin = zone.RuinChance;
188 }
189 PartialMap partialMap = MapPiece.Instance.GetMap(type, tags.IsEmpty(zone.biome.tags), ruin);
190 if (partialMap == null)
191 {
192 Debug.Log("TryAddMap Piece: no map");
193 return null;
194 }
195 bool flag = partialMap.dir == 1 || partialMap.dir == 3;
196 GenBounds bounds = GetBounds(flag ? partialMap.h : partialMap.w, flag ? partialMap.w : partialMap.h, partialMap.ignoreBlock);
197 if (bounds == null)
198 {
199 return null;
200 }
201 partialMap.Apply(new Point(bounds.x, bounds.y), PartialMap.ApplyMode.Apply);
202 onCreate?.Invoke(partialMap, bounds);
203 Debug.Log(partialMap.path);
204 return partialMap;
205 }
static MapPiece Instance
Definition: MapPiece.cs:45
PartialMap GetMap(Type type, string tag, float ruin)
Definition: MapPiece.cs:49
string path
Definition: PartialMap.cs:68
void Apply(Point _point, ApplyMode mode)
Definition: PartialMap.cs:112
bool ignoreBlock
Definition: PartialMap.cs:58
BiomeProfile biome
Definition: Zone.cs:126
virtual float RuinChance
Definition: Zone.cs:310

References PartialMap.Apply(), Zone.biome, Debug, GetBounds(), MapPiece.GetMap(), PartialMap.h, PartialMap.ignoreBlock, MapPiece.Instance, PartialMap.path, Zone.RuinChance, BiomeProfile.tags, PartialMap.w, x, y, and zone.

Referenced by Zone_CaveMonster.OnGenerateRooms(), ZoneEventHarvest.OnVisit(), ZoneEventMusic.OnVisit(), and GenRoom.Populate().

Member Data Documentation

◆ FuncCheckEmpty

Func<Cell, bool> GenBounds.FuncCheckEmpty

Definition at line 23 of file GenBounds.cs.

Referenced by GetBounds(), and IsEmpty().

◆ height

int GenBounds.height

◆ map

◆ marginPartial

int GenBounds.marginPartial

Definition at line 21 of file GenBounds.cs.

Referenced by GetBounds(), and IsEmpty().

◆ Size

◆ width

int GenBounds.width

◆ x

◆ y

int GenBounds.y

◆ zone


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