Elin Modding Docs Doc
Loading...
Searching...
No Matches
TaskCraft.cs
1using System;
2using System.Collections.Generic;
3using Newtonsoft.Json;
4
5// Token: 0x02000265 RID: 613
6public class TaskCraft : Task
7{
8 // Token: 0x1700049C RID: 1180
9 // (get) Token: 0x06001136 RID: 4406 RVA: 0x00077710 File Offset: 0x00075910
10 public Point CraftPos
11 {
12 get
13 {
14 if (this.factory == null || !this.factory.ExistsOnMap)
15 {
16 return EClass.pc.pos;
17 }
18 return this.factory.pos;
19 }
20 }
21
22 // Token: 0x1700049D RID: 1181
23 // (get) Token: 0x06001137 RID: 4407 RVA: 0x0007773D File Offset: 0x0007593D
24 public override int MaxRestart
25 {
26 get
27 {
28 return 99999999;
29 }
30 }
31
32 // Token: 0x06001138 RID: 4408 RVA: 0x00077744 File Offset: 0x00075944
33 public override bool CanManualCancel()
34 {
35 return true;
36 }
37
38 // Token: 0x06001139 RID: 4409 RVA: 0x00077748 File Offset: 0x00075948
39 public void ResetReq()
40 {
41 this.reqs = new int[this.recipe.ingredients.Count];
42 for (int i = 0; i < this.recipe.ingredients.Count; i++)
43 {
44 this.reqs[i] = this.recipe.ingredients[i].req;
45 }
46 }
47
48 // Token: 0x0600113A RID: 4410 RVA: 0x000777A9 File Offset: 0x000759A9
49 public override bool CanProgress()
50 {
51 return true;
52 }
53
54 // Token: 0x0600113B RID: 4411 RVA: 0x000777AC File Offset: 0x000759AC
55 public override bool _CanPerformTask(Chara chara, int radius)
56 {
57 return true;
58 }
59
60 // Token: 0x0600113C RID: 4412 RVA: 0x000777AF File Offset: 0x000759AF
61 public override void OnCreateProgress(Progress_Custom p)
62 {
63 p.maxProgress = 5;
64 }
65
66 // Token: 0x0600113D RID: 4413 RVA: 0x000777B8 File Offset: 0x000759B8
67 public override void OnBeforeProgress()
68 {
69 }
70
71 // Token: 0x0600113E RID: 4414 RVA: 0x000777BC File Offset: 0x000759BC
72 public override void OnProgress()
73 {
74 Element orCreateElement = this.owner.elements.GetOrCreateElement(this.recipe.source.GetReqSkill());
75 this.owner.PlaySound(this.recipe.GetMainMaterial().GetSoundCraft(this.recipe.renderRow), 1f, true);
76 this.owner.elements.ModExp(orCreateElement.id, 20, false);
77 }
78
79 // Token: 0x0600113F RID: 4415 RVA: 0x00077830 File Offset: 0x00075A30
80 public override IEnumerable<AIAct.Status> Run()
81 {
82 this.OnBeforeProgress();
83 if (!this.CanProgress())
84 {
85 yield return this.Cancel();
86 }
87 yield return base.DoProgress();
88 this.ResetReq();
89 if (this.repeat)
90 {
91 yield return base.Restart();
92 }
93 if (this.layer)
94 {
95 this.layer.OnCompleteCraft();
96 }
97 if (LayerCraftFloat.Instance)
98 {
99 LayerCraftFloat.Instance.OnCompleteCraft();
100 }
101 yield break;
102 }
103
104 // Token: 0x06001140 RID: 4416 RVA: 0x00077840 File Offset: 0x00075A40
105 public bool IsIngredientsValid(bool destoryResources = false, int numCraft = 1)
106 {
107 bool flag = true;
108 for (int i = 0; i < this.recipe.ingredients.Count; i++)
109 {
110 Thing thing = this.recipe.ingredients[i].thing;
111 if (thing == null || thing.isDestroyed || thing.Num < this.reqs[i] * numCraft)
112 {
113 flag = false;
114 break;
115 }
116 if (destoryResources)
117 {
118 this.resources.Add(thing.Split(this.reqs[i]));
119 }
120 }
121 if (!flag)
122 {
123 return false;
124 }
125 if (destoryResources)
126 {
127 foreach (Thing thing2 in this.resources)
128 {
129 thing2.Destroy();
130 }
131 this.resources.Clear();
132 }
133 return true;
134 }
135
136 // Token: 0x06001141 RID: 4417 RVA: 0x00077918 File Offset: 0x00075B18
137 public override void OnProgressComplete()
138 {
139 if (this.owner == null)
140 {
141 return;
142 }
143 Element orCreateElement = this.owner.elements.GetOrCreateElement(this.recipe.source.GetReqSkill());
144 for (int i = 0; i < this.num; i++)
145 {
146 this.ResetReq();
147 if (!this.IsIngredientsValid(true, 1))
148 {
149 Msg.Say("invalidCraftResource");
150 return;
151 }
152 this.recipe.Craft(this.blessed, i == 0, null, false);
153 this.owner.elements.ModExp(orCreateElement.id, 200, false);
154 this.resources.Clear();
155 }
156 EClass.Sound.Play("craft");
157 Effect.Get("smoke").Play(this.CraftPos, 0f, null, null);
158 Effect.Get("mine").Play(this.CraftPos, 0f, null, null).SetParticleColor(this.recipe.GetColorMaterial().GetColor()).Emit(10 + EClass.rnd(10));
159 EClass.pc.stamina.Mod(-this.costSP);
160 }
161
162 // Token: 0x06001142 RID: 4418 RVA: 0x00077A40 File Offset: 0x00075C40
163 public void PutOutResources()
164 {
165 foreach (Thing t in this.resources)
166 {
167 EClass._zone.AddCard(t, this.CraftPos);
168 }
169 this.resources.Clear();
170 }
171
172 // Token: 0x04000DE6 RID: 3558
173 [JsonProperty]
174 public Thing factory;
175
176 // Token: 0x04000DE7 RID: 3559
177 [JsonProperty]
178 public Recipe recipe;
179
180 // Token: 0x04000DE8 RID: 3560
181 [JsonProperty]
182 public int num;
183
184 // Token: 0x04000DE9 RID: 3561
185 [JsonProperty]
186 public int costSP;
187
188 // Token: 0x04000DEA RID: 3562
189 [JsonProperty]
190 public List<Thing> resources = new List<Thing>();
191
192 // Token: 0x04000DEB RID: 3563
193 [JsonProperty]
194 public int[] reqs;
195
196 // Token: 0x04000DEC RID: 3564
197 [JsonProperty]
198 public bool repeat;
199
200 // Token: 0x04000DED RID: 3565
201 [JsonProperty]
202 public bool floatMode;
203
204 // Token: 0x04000DEE RID: 3566
205 public BlessedState blessed;
206
207 // Token: 0x04000DEF RID: 3567
208 public LayerCraft layer;
209}
Definition AIAct.cs:7
Definition Chara.cs:12
Definition Msg.cs:7
Definition Point.cs:11
Definition Task.cs:6
Definition Thing.cs:10