Elin Decompiled Documentation EA 23.321 Nightly Patch 1
Loading...
Searching...
No Matches
TaskDig.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2
3public class TaskDig : BaseTaskHarvest
4{
5 public enum Mode
6 {
8 Ramp,
10 }
11
12 public Mode mode;
13
14 public int ramp = 3;
15
16 public override HarvestType harvestType => HarvestType.Floor;
17
18 public override int RightHand => 1101;
19
20 public override bool IsHostileAct => true;
21
22 public override bool LocalAct => false;
23
24 public override int destDist
25 {
26 get
27 {
29 {
31 {
32 return 1;
33 }
34 return 0;
35 }
36 return 1;
37 }
38 }
39
40 public override bool destIgnoreConnection => true;
41
43
44 public override string GetIdRecipe(Point p)
45 {
46 if (!p.HasBridge)
47 {
48 return p.sourceFloor.RecipeID;
49 }
50 return p.sourceBridge.RecipeID;
51 }
52
53 public override string GetTextSmall(Card c)
54 {
55 if (!pos.cell.HasBridge)
56 {
57 return pos.cell.GetFloorName();
58 }
59 return pos.cell.GetBridgeName();
60 }
61
62 public override void OnCreateProgress(Progress_Custom p)
63 {
65 p.textHint = pos.cell.GetFloorName();
66 p.maxProgress = maxProgress;
67 p.onProgressBegin = delegate
68 {
69 if (base.IsTooHard)
70 {
72 p.Cancel();
73 }
74 else if (owner.Tool != null)
75 {
76 owner.Say("dig_start", owner, owner.Tool);
77 }
78 };
79 p.onProgress = delegate
80 {
81 SourceMaterial.Row row = (pos.cell.HasBridge ? pos.cell.matBridge : pos.cell.matFloor);
83 row.PlayHitEffect(pos);
84 row.AddBlood(pos);
85 owner.elements.ModExp(230, 5f);
87 if (EClass._zone.IsCrime(owner, this))
88 {
90 }
91 };
92 }
93
94 public override HitResult GetHitResult()
95 {
96 if (EClass._zone.IsRegion && GetTreasureMap(pos) != null)
97 {
98 return HitResult.Valid;
99 }
100 if (mode == Mode.RemoveFloor)
101 {
103 {
104 if (pos.matFloor.category == "soil")
105 {
106 return HitResult.Valid;
107 }
108 return HitResult.Default;
109 }
110 if (EClass._zone.IsSkyLevel && (pos.IsSky || pos.Installed != null || pos.Charas.Count >= 2 || (pos.HasChara && (pos.FirstChara != EClass.pc || EClass.game.IsSurvival))))
111 {
112 return HitResult.Invalid;
113 }
115 {
116 return HitResult.Invalid;
117 }
118 if (!pos.HasBridge && !EClass._zone.IsSkyLevel && pos.sourceFloor.id == 40)
119 {
120 return HitResult.Invalid;
121 }
122 return HitResult.Valid;
123 }
124 if (pos.HasBridge)
125 {
126 if (pos.HasObj)
127 {
128 return HitResult.Warning;
129 }
130 return HitResult.Valid;
131 }
132 return HitResult.Default;
133 }
134
136 {
138 {
139 TraitScrollMapTreasure traitScrollMapTreasure = item.trait as TraitScrollMapTreasure;
140 if (p.Equals(traitScrollMapTreasure.GetDest(fix: true)))
141 {
142 return item;
143 }
144 }
145 return null;
146 }
147
148 public override void OnProgressComplete()
149 {
150 int num = owner.Tool?.Evalue(770) ?? 0;
151 num = ((num <= 0) ? 1 : (2 + num / 10));
152 if (num > 1)
153 {
154 List<Point> list = EClass._map.ListPointsInSquare(pos, num - 1);
155 list.Sort((Point a, Point b) => a.Distance(pos) - b.Distance(pos));
156 {
157 foreach (Point item in list)
158 {
159 if (owner == null || owner.isDead)
160 {
161 break;
162 }
163 Dig(item);
164 }
165 return;
166 }
167 }
168 Dig(pos);
169 void Dig(Point p)
170 {
171 if (GetHitResult(p) != HitResult.Invalid)
172 {
173 string idRecipe = GetIdRecipe(p);
174 int num2 = (p.HasBridge ? p.matBridge.hardness : p.matFloor.hardness);
175 TaskDig taskDig = new TaskDig();
176 taskDig.owner = owner;
177 taskDig.pos = p;
178 taskDig.SetTarget(owner, owner.Tool);
179 if (!taskDig.IsTooHard)
180 {
182 {
183 Thing map = GetTreasureMap(p);
184 if (map != null || EClass.debug.enable)
185 {
186 if (map == null)
187 {
188 map = ThingGen.Create("map_treasure", -1, EClass.pc.LV);
189 }
190 SE.Play("ding_skill");
191 Msg.Say("digTreasure");
192 Rand.UseSeed(map.refVal, delegate
193 {
194 Thing thing = ThingGen.CreateTreasure("chest_treasure", map.LV);
195 EClass._zone.AddCard(thing, p);
196 ThingGen.TryLickChest(thing);
197 });
198 map.Destroy();
199 EClass.player.willAutoSave = true;
200 return;
201 }
202 }
203 switch (mode)
204 {
205 case Mode.Default:
206 EClass._map.SetBridge(p.x, p.z, 0, 0, 0, 0, 0);
207 break;
208 case Mode.RemoveFloor:
210 p.Animate(AnimeID.Dig, animeBlock: true);
211 if (!owner.IsAgent)
212 {
213 owner.elements.ModExp(230, 20 + num2 / 2);
214 }
215 break;
216 case Mode.Ramp:
218 break;
219 }
220 if (EClass._zone.IsCrime(owner, this))
221 {
223 }
224 if (EClass.rnd(2) == 0)
225 {
226 owner.stamina.Mod(-1);
227 }
228 if (owner != null)
229 {
230 if (owner.IsPC)
231 {
233 }
235 {
237 }
238 }
239 }
240 }
241 }
242 }
243}
AnimeID
Definition: AnimeID.cs:2
HitResult
Definition: HitResult.cs:2
virtual Status Cancel()
Definition: AIAct.cs:305
new Chara owner
Definition: AIAct.cs:14
void SetTarget(Chara c, Thing _tool=null)
virtual void NextFrame()
Definition: Card.cs:11
bool IsAgent
Definition: Card.cs:2303
ElementContainerCard elements
Definition: Card.cs:42
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:6578
Thing Tool
Definition: Card.cs:2480
Point pos
Definition: Card.cs:60
int refVal
Definition: Card.cs:209
Trait trait
Definition: Card.cs:54
void Destroy()
Definition: Card.cs:5284
ThingContainer things
Definition: Card.cs:39
int Evalue(int ele)
Definition: Card.cs:2704
CardRenderer renderer
Definition: Card.cs:64
int LV
Definition: Card.cs:389
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:7256
bool HasBridge
Definition: Cell.cs:679
string GetBridgeName()
Definition: Cell.cs:1635
string GetFloorName()
Definition: Cell.cs:1630
SourceMaterial.Row matFloor
Definition: Cell.cs:1040
override bool IsAliveInCurrentZone
Definition: Chara.cs:567
override bool IsPC
Definition: Chara.cs:630
Stats stamina
Definition: Chara.cs:1181
void FallFromZone()
Definition: Chara.cs:3691
bool isDead
Definition: Chara.cs:393
bool enable
Definition: CoreDebug.cs:301
static CursorInfo Dig
Definition: CursorSystem.cs:66
Definition: EClass.cs:6
static Game game
Definition: EClass.cs:9
static Zone _zone
Definition: EClass.cs:21
static Map _map
Definition: EClass.cs:19
static int rnd(long a)
Definition: EClass.cs:59
static Player player
Definition: EClass.cs:13
static Chara pc
Definition: EClass.cs:15
static CoreDebug debug
Definition: EClass.cs:49
void ModExp(int ele, float a, bool chain=false)
bool IsSurvival
Definition: Game.cs:276
void SetBridge(int x, int z, int height=0, int idMat=0, int idBridge=0, int dir=0, byte idPillar=0)
Definition: Map.cs:993
void MineFloor(Point point, Chara c=null, bool recoverBlock=false, bool removePlatform=true)
Definition: Map.cs:1797
List< Point > ListPointsInSquare(Point center, int radius, bool mustBeWalkable=true, bool los=true)
Definition: Map.cs:2336
Definition: Msg.cs:5
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
RecipeManager recipes
Definition: Player.cs:1164
void ModKarma(int a)
Definition: Player.cs:2610
Definition: Point.cs:9
Thing Installed
Definition: Point.cs:327
SourceMaterial.Row matFloor
Definition: Point.cs:57
bool HasBridge
Definition: Point.cs:221
bool IsSky
Definition: Point.cs:224
bool IsWater
Definition: Point.cs:129
int x
Definition: Point.cs:36
int z
Definition: Point.cs:39
List< Chara > Charas
Definition: Point.cs:340
bool TryWitnessCrime(Chara criminal, Chara target=null, int radius=4, Func< Chara, bool > funcWitness=null)
Definition: Point.cs:878
SourceFloor.Row sourceFloor
Definition: Point.cs:65
bool HasObj
Definition: Point.cs:137
int Distance(Point p)
Definition: Point.cs:995
Chara FirstChara
Definition: Point.cs:288
bool HasBlock
Definition: Point.cs:141
bool IsInBounds
Definition: Point.cs:104
Cell cell
Definition: Point.cs:51
void Animate(AnimeID id, bool animeBlock=false)
Definition: Point.cs:1308
SourceFloor.Row sourceBridge
Definition: Point.cs:67
bool HasChara
Definition: Point.cs:238
Definition: Rand.cs:4
static void UseSeed(int seed, Action action)
Definition: Rand.cs:24
void ComeUpWithRecipe(string idRecipe, int chanceForRandomRecipe=0)
string GetSoundImpact(RenderRow c=null)
void AddBlood(Point p, int a=1)
void PlayHitEffect(Point p, int emit=2)
virtual bool IsRegion
Definition: Spatial.cs:515
virtual void Mod(int a)
Definition: Stats.cs:135
override void OnCreateProgress(Progress_Custom p)
Definition: TaskDig.cs:62
override void OnProgressComplete()
Definition: TaskDig.cs:148
Thing GetTreasureMap(Point p)
Definition: TaskDig.cs:135
override bool destIgnoreConnection
Definition: TaskDig.cs:40
int ramp
Definition: TaskDig.cs:14
override bool LocalAct
Definition: TaskDig.cs:22
override HarvestType harvestType
Definition: TaskDig.cs:16
Mode
Definition: TaskDig.cs:6
override string GetTextSmall(Card c)
Definition: TaskDig.cs:53
override string GetIdRecipe(Point p)
Definition: TaskDig.cs:44
Mode mode
Definition: TaskDig.cs:12
override CursorInfo CursorIcon
Definition: TaskDig.cs:42
override bool IsHostileAct
Definition: TaskDig.cs:20
override int destDist
Definition: TaskDig.cs:25
override HitResult GetHitResult()
Definition: TaskDig.cs:94
override int RightHand
Definition: TaskDig.cs:18
Point pos
Definition: TaskPoint.cs:11
List< Thing > List(Func< Thing, bool > func, bool onlyAccessible=false)
static Thing Create(string id, int idMat=-1, int lv=-1)
Definition: ThingGen.cs:53
Definition: Thing.cs:8
Point GetDest(bool fix=false)
virtual bool IsSkyLevel
Definition: Zone.cs:271
bool IsPCFaction
Definition: Zone.cs:477
bool IsCrime(Chara c, Act act)
Definition: Zone.cs:3714