Elin Decompiled Documentation EA 23.343 Nightly
Loading...
Searching...
No Matches
AM_Picker.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3
5{
6 public struct Result
7 {
9
11
12 public Thing thing;
13
14 public bool IsValid => source != null;
15
16 public string category => source.recipeCat;
17
18 public string GetText()
19 {
20 return source.Name + (EClass.debug.showExtra ? (":" + source.id) : "") + "(" + mat.GetName() + (EClass.debug.showExtra ? (":" + mat.id) : "") + ")" + (EClass.player.recipes.IsKnown(source.id) ? "" : (Environment.NewLine + "noRecipe".lang()));
21 }
22 }
23
24 public override bool IsBuildMode => true;
25
27
29
31
32 public bool CanActivate
33 {
34 get
35 {
36 if (!base.IsActive)
37 {
39 {
40 if (EClass.Branch != null)
41 {
42 return EClass.Branch.elements.Has(4005);
43 }
44 return false;
45 }
46 return true;
47 }
48 return false;
49 }
50 }
51
52 public override void OnUpdateCursor()
53 {
55 }
56
57 public override HitResult HitTest(Point point, Point start)
58 {
59 if (!Test(point).IsValid)
60 {
61 return HitResult.Default;
62 }
63 return HitResult.Valid;
64 }
65
66 public override void OnProcessTiles(Point point, int dir)
67 {
68 Test(point, select: true);
69 }
70
71 public override void OnRenderTile(Point point, HitResult result, int dir)
72 {
73 if (point.cell.HasWallOrFence && (result == HitResult.Valid || result == HitResult.Invalid))
74 {
76 }
77 else
78 {
79 base.OnRenderTile(point, result, dir);
80 }
81 }
82
83 public Result TestBlock(Point point)
84 {
85 return new Result
86 {
87 mat = point.matBlock,
88 source = TryGetRecipe(point.sourceBlock.RecipeID)
89 };
90 }
91
92 public Result TestObj(Point point)
93 {
94 return new Result
95 {
96 mat = point.cell.matObj,
97 source = TryGetRecipe(point.sourceObj.RecipeID)
98 };
99 }
100
101 public Result TestFloor(Point point)
102 {
103 Result result = default(Result);
104 if (point.cell._bridge == 0)
105 {
106 result.mat = point.matFloor;
107 result.source = TryGetRecipe(point.sourceFloor.RecipeID);
108 }
109 else
110 {
111 result.mat = point.cell.matBridge;
112 result.source = TryGetRecipe(point.cell.sourceBridge.RecipeID + "-b");
113 }
114 return result;
115 }
116
118 {
119 Result result = default(Result);
120 if (t.trait.IsGround)
121 {
122 return result;
123 }
124 result.mat = t.material;
125 result.source = TryGetRecipe(t.sourceCard.RecipeID);
126 result.thing = t;
127 return result;
128 }
129
130 public Result Test(Point point, bool select = false)
131 {
132 List<Card> list = point.ListCards(includeMasked: true);
133 for (int num = list.Count - 1; num >= 0; num--)
134 {
135 Card card = list[num];
136 if (card.isThing)
137 {
138 Result result = TestThing(card.Thing);
139 if (result.IsValid)
140 {
141 if (select)
142 {
143 Select(result);
144 }
145 if (card.trait is TraitHouseBoard houseBoard)
146 {
147 ActionMode.Build.houseBoard = houseBoard;
148 }
149 return result;
150 }
151 }
152 }
153 if (point.HasBlock)
154 {
155 Result result2 = TestBlock(point);
156 if (result2.IsValid)
157 {
158 if (select)
159 {
160 Select(result2);
161 }
162 return result2;
163 }
164 }
165 if (EClass.debug.godBuild && point.HasObj)
166 {
167 Result result3 = TestObj(point);
168 if (result3.IsValid)
169 {
170 if (select)
171 {
172 Select(result3);
173 }
174 return result3;
175 }
176 }
177 if (point.HasFloor)
178 {
179 Result result4 = TestFloor(point);
180 if (result4.IsValid)
181 {
182 if (select)
183 {
184 Select(result4);
185 }
186 return result4;
187 }
188 }
189 return default(Result);
190 }
191
192 public RecipeSource TryGetRecipe(string id)
193 {
194 return EClass.player.recipes.GetSource(id);
195 }
196
197 public new bool Select(Result r)
198 {
199 ActionMode.ignoreSound = true;
200 BM.Select(r);
201 return true;
202 }
203}
HitResult
Definition: HitResult.cs:2
override void OnProcessTiles(Point point, int dir)
Definition: AM_Picker.cs:66
override HitResult HitTest(Point point, Point start)
Definition: AM_Picker.cs:57
Result Test(Point point, bool select=false)
Definition: AM_Picker.cs:130
RecipeSource TryGetRecipe(string id)
Definition: AM_Picker.cs:192
override BaseTileSelector.HitType hitType
Definition: AM_Picker.cs:26
Result TestFloor(Point point)
Definition: AM_Picker.cs:101
override BaseTileSelector.SelectType selectType
Definition: AM_Picker.cs:28
override void OnRenderTile(Point point, HitResult result, int dir)
Definition: AM_Picker.cs:71
override bool IsBuildMode
Definition: AM_Picker.cs:24
Result TestBlock(Point point)
Definition: AM_Picker.cs:83
Result TestThing(Thing t)
Definition: AM_Picker.cs:117
BuildMenu BM
Definition: AM_Picker.cs:30
override void OnUpdateCursor()
Definition: AM_Picker.cs:52
Result TestObj(Point point)
Definition: AM_Picker.cs:92
new bool Select(Result r)
Definition: AM_Picker.cs:197
bool CanActivate
Definition: AM_Picker.cs:33
static AM_Select Select
Definition: ActionMode.cs:59
void SetCursorOnMap(CursorInfo cursor)
Definition: ActionMode.cs:565
ScreenGuide guide
BaseTileSelector tileSelector
void Select(AM_Picker.Result r)
Definition: BuildMenu.cs:416
static BuildMenu Instance
Definition: BuildMenu.cs:77
Definition: Card.cs:11
SourceMaterial.Row material
Definition: Card.cs:2103
Trait trait
Definition: Card.cs:54
bool HasWallOrFence
Definition: Cell.cs:851
byte _bridge
Definition: Cell.cs:60
SourceMaterial.Row matObj
Definition: Cell.cs:1058
SourceMaterial.Row matBridge
Definition: Cell.cs:1056
SourceFloor.Row sourceBridge
Definition: Cell.cs:1078
BlockColors blockColors
bool godBuild
Definition: CoreDebug.cs:320
BaseGameScreen screen
Definition: Core.cs:67
static CursorInfo Picker
Definition: CursorSystem.cs:72
Definition: EClass.cs:6
static ColorProfile Colors
Definition: EClass.cs:39
static Core core
Definition: EClass.cs:7
static FactionBranch Branch
Definition: EClass.cs:23
static BaseGameScreen screen
Definition: EClass.cs:33
static Player player
Definition: EClass.cs:13
static CoreDebug debug
Definition: EClass.cs:49
bool Has(int ele)
ElementContainerZone elements
RecipeManager recipes
Definition: Player.cs:1167
Definition: Point.cs:9
SourceMaterial.Row matBlock
Definition: Point.cs:55
SourceMaterial.Row matFloor
Definition: Point.cs:57
SourceBlock.Row sourceBlock
Definition: Point.cs:63
List< Card > ListCards(bool includeMasked=false)
Definition: Point.cs:1057
SourceObj.Row sourceObj
Definition: Point.cs:69
SourceFloor.Row sourceFloor
Definition: Point.cs:65
bool HasObj
Definition: Point.cs:137
bool HasFloor
Definition: Point.cs:219
bool HasBlock
Definition: Point.cs:141
Cell cell
Definition: Point.cs:51
bool IsKnown(string id)
RecipeSource GetSource(string id)
string recipeCat
Definition: RecipeSource.cs:37
virtual string RecipeID
Definition: RenderRow.cs:105
void DrawWall(Point point, int color, bool useMarkerPass=false, float offsetZ=0f)
Definition: ScreenGuide.cs:42
Definition: Thing.cs:8
override CardRow sourceCard
Definition: Thing.cs:47
virtual bool IsGround
Definition: Trait.cs:68
string category
Definition: AM_Picker.cs:16
SourceMaterial.Row mat
Definition: AM_Picker.cs:10
string GetText()
Definition: AM_Picker.cs:18
RecipeSource source
Definition: AM_Picker.cs:8