11 public override int LeftHand
21 public override int RightHand
30 public override bool CanManualCancel()
32 return this.layer && this.layer.CanCancelAI;
36 public override void OnStart()
38 if (this.crafter.Icon != Emo.none)
40 this.owner.ShowEmo(this.crafter.Icon, 0f,
true);
45 public override void OnSuccess()
51 public override void OnCancel()
63 foreach (
Thing thing
in this.ings)
65 if (thing !=
null && thing.ExistsOnMap)
67 thing.isHidden =
false;
68 EClass.pc.Pick(thing,
true,
true);
71 if (this.crafter.AutoTurnOff &&
this.crafter.owner.isOn)
73 this.crafter.Toggle(
false,
false);
75 if (!this.crafter.idSoundBG.IsEmpty())
77 EClass.Sound.Stop(this.crafter.idSoundBG, 0f);
81 this.layer.OnEndCraft();
86 public override IEnumerable<
AIAct.Status> Run()
91 CS$<>8__locals1.<>4__this =
this;
92 if (this.crafter.owner.isDestroyed || !
this.layer)
94 yield
return base.Success(
null);
96 if (!this.crafter.idSoundBG.IsEmpty())
98 SE.Play(this.crafter.idSoundBG);
100 List<Thing> targets = this.layer.GetTargets();
101 CS$<>8__locals1.blessed = BlessedState.Normal;
103 for (
int i = 0; i < targets.Count; i = num + 1)
105 Thing t = targets[i];
106 if (!this.<Run>g__IsIngValid|14_0(t, i))
110 this.layer.ClearButtons();
114 this.layer.RefreshCurrentGrid();
116 yield
return base.Success(
null);
120 if (!this.crafter.IsFuelEnough(
this.num, targets,
true))
122 Msg.Say(
"notEnoughFuel");
123 this.layer.RefreshCurrentGrid();
124 yield
return base.Success(
null);
126 this.ings =
new List<Thing>();
127 for (
int j = 0; j < targets.Count; j++)
129 Thing thing = targets[j].Split(this.layer.GetReqIngredient(j));
130 this.ings.Add(thing);
131 if (thing.blessedState <= BlessedState.Cursed && CS$<>8__locals1.blessed > thing.blessedState)
133 CS$<>8__locals1.blessed = thing.blessedState;
135 if (thing.blessedState > BlessedState.Normal && CS$<>8__locals1.blessed == BlessedState.Normal)
137 CS$<>8__locals1.blessed = thing.blessedState;
139 if (this.crafter.IsConsumeIng)
141 Card card =
EClass._zone.AddCard(thing, this.crafter.owner.ExistsOnMap ?
this.crafter.owner.pos :
this.owner.pos);
142 if (this.crafter.animeType ==
TraitCrafter.AnimeType.Microwave)
144 card.isHidden =
true;
152 CS$<>8__locals1.requireOn = (this.crafter.IsRequireFuel || this.crafter.ToggleType > ToggleType.None);
153 if (CS$<>8__locals1.requireOn && !
this.crafter.owner.isOn)
155 this.crafter.Toggle(
true,
false);
157 CS$<>8__locals1.costSP = this.crafter.GetCostSp(
this);
158 CS$<>8__locals1.duration = this.crafter.GetDuration(
this, CS$<>8__locals1.costSP);
161 canProgress = delegate()
163 if (CS$<>8__locals1.requireOn && !CS$<>8__locals1.<>4__this.crafter.owner.isOn)
167 foreach (
Thing thing2
in CS$<>8__locals1.<>4__this.ings)
169 if (thing2.isDestroyed || (CS$<>8__locals1.<>4__this.crafter.IsConsumeIng && !thing2.ExistsOnMap))
177 for (
int k = 0; k < owner.numDragGrid; k++)
179 if (owner.buttons[k].Card ==
null)
184 if (owner.numDragGrid == 2 && CS$<>8__locals1.<>4__this.ings[0] == CS$<>8__locals1.<>4__this.ings[1] && CS$<>8__locals1.<>4__this.ings[0].Num == 1)
189 return !CS$<>8__locals1.<>4__this.crafter.owner.isDestroyed;
193 if (this.crafter.owner.ExistsOnMap && !
this.owner.pos.Equals(
this.crafter.owner.pos))
195 this.owner.LookAt(this.crafter.owner);
197 this.owner.PlaySound(this.crafter.idSoundProgress, 1f,
true);
198 if (this.crafter.owner.ExistsOnMap)
200 TraitCrafter.AnimeType animeType = this.crafter.animeType;
203 this.crafter.owner.renderer.PlayAnime(this.crafter.IdAnimeProgress,
default(Vector3),
false);
206 foreach (
Thing thing2
in this.ings)
208 thing2.renderer.PlayAnime(this.crafter.IdAnimeProgress,
default(Vector3),
false);
211 onProgressComplete = delegate()
213 if (CS$<>8__locals1.<>4__this.crafter.StopSoundProgress)
215 EClass.Sound.Stop(CS$<>8__locals1.<>4__this.crafter.idSoundProgress, 0f);
217 CS$<>8__locals1.<>4__this.owner.PlaySound(CS$<>8__locals1.<>4__this.crafter.idSoundComplete, 1f,
true);
219 TraitCrafter traitCrafter = CS$<>8__locals1.<>4__this.crafter;
220 Recipe recipe = CS$<>8__locals1.<>4__this.recipe;
221 Element orCreateElement = elements.GetOrCreateElement(traitCrafter.IDReqEle(((recipe !=
null) ? recipe.source :
null) ??
null));
222 if (CS$<>8__locals1.<>4__this.recipe !=
null)
224 for (
int k = 0; k < CS$<>8__locals1.<>4__this.num; k++)
226 CS$<>8__locals1.<>4__this.recipe.Craft(CS$<>8__locals1.blessed, k == 0, CS$<>8__locals1.<>4__this.ings,
false);
228 EClass.Sound.Play(
"craft");
229 Point from = CS$<>8__locals1.<>4__this.crafter.owner.ExistsOnMap ? CS$<>8__locals1.<>4__this.crafter.owner.pos : CS$<>8__locals1.<>4__this.owner.pos;
230 Effect.Get(
"smoke").Play(from, 0f,
null,
null);
231 Effect.Get(
"mine").Play(from, 0f,
null,
null).SetParticleColor(CS$<>8__locals1.<>4__this.recipe.GetColorMaterial().GetColor()).Emit(10 +
EClass.rnd(10));
232 CS$<>8__locals1.<>4__this.owner.renderer.PlayAnime(AnimeID.JumpSmall,
default(Vector3),
false);
236 Thing thing2 = CS$<>8__locals1.<>4__this.crafter.Craft(CS$<>8__locals1.<>4__this);
239 if (thing2.category.ignoreBless == 0)
241 thing2.SetBlessedState(CS$<>8__locals1.blessed);
243 thing2.PlaySoundDrop(
false);
245 thing2.Identify(
false, IDTSource.Identify);
246 CS$<>8__locals1.<>4__this.owner.Pick(thing2,
true,
true);
249 for (
int l = 0; l < CS$<>8__locals1.<>4__this.ings.Count; l++)
251 if (CS$<>8__locals1.<>4__this.crafter.ShouldConsumeIng(CS$<>8__locals1.<>4__this.crafter.GetSource(CS$<>8__locals1.<>4__this), l))
253 CS$<>8__locals1.<>4__this.ings[l].Destroy();
256 foreach (
Thing thing3
in CS$<>8__locals1.<>4__this.ings)
258 if (thing3.ExistsOnMap)
260 CS$<>8__locals1.<>4__this.owner.Pick(thing3,
true,
true);
263 if (CS$<>8__locals1.<>4__this.crafter.IsRequireFuel)
265 CS$<>8__locals1.<>4__this.crafter.owner.ModCharge(-CS$<>8__locals1.<>4__this.crafter.FuelCost * CS$<>8__locals1.<>4__this.num,
false);
266 if (CS$<>8__locals1.<>4__this.crafter.owner.c_charges <= 0)
268 CS$<>8__locals1.<>4__this.crafter.owner.c_charges = 0;
269 CS$<>8__locals1.<>4__this.crafter.Toggle(
false,
false);
272 for (
int m = 0; m < CS$<>8__locals1.<>4__this.num; m++)
275 CS$<>8__locals1.<>4__this.owner.elements.ModExp(orCreateElement.id, CS$<>8__locals1.costSP * 12 * (100 + CS$<>8__locals1.duration * 2) / 100,
false);
276 CS$<>8__locals1.<>4__this.owner.stamina.Mod(-CS$<>8__locals1.costSP);
277 if (CS$<>8__locals1.<>4__this.owner ==
null || CS$<>8__locals1.<>4__this.owner.isDead)
283 }.SetDuration(CS$<>8__locals1.duration, 5);
284 this.owner.SetTempHand(-1, -1);
285 if (
EClass.debug.godCraft)
287 progress.SetDuration(1, 1);
289 yield
return base.Do(progress,
null);
290 if (progress.status ==
AIAct.Status.Fail)
292 yield
return this.Cancel();
294 if (this.crafter.CloseOnComplete)
296 yield
return this.Cancel();
298 if (!this.crafter.IsConsumeIng)
302 if (!this.layer || !this.layer.RepeatAI)
306 CS$<>8__locals1 =
null;
310 this.layer.ClearButtons();
317 private bool <Run>g__IsIngValid|14_0(
Thing t,
int i)
319 if (t ==
null || t.isDestroyed)
323 Card rootCard = t.GetRootCard();
324 return (rootCard ==
null || !rootCard.isChara || rootCard.IsPC) && (this.crafter.IsFactory || this.crafter.IsCraftIngredient(t, i));
340 public List<Thing> ings =
new List<Thing>();