14 if (this.factory ==
null || !this.factory.ExistsOnMap)
18 return this.factory.pos;
24 public override int MaxRestart
33 public override bool CanManualCancel()
39 public void ResetReq()
41 this.reqs =
new int[this.recipe.ingredients.Count];
42 for (
int i = 0; i < this.recipe.ingredients.Count; i++)
44 this.reqs[i] = this.recipe.ingredients[i].req;
49 public override bool CanProgress()
55 public override bool _CanPerformTask(
Chara chara,
int radius)
67 public override void OnBeforeProgress()
72 public override void OnProgress()
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);
80 public override IEnumerable<
AIAct.Status> Run()
82 this.OnBeforeProgress();
83 if (!this.CanProgress())
85 yield
return this.Cancel();
87 yield
return base.DoProgress();
91 yield
return base.Restart();
95 this.layer.OnCompleteCraft();
105 public bool IsIngredientsValid(
bool destoryResources =
false,
int numCraft = 1)
108 for (
int i = 0; i < this.recipe.ingredients.Count; i++)
110 Thing thing = this.recipe.ingredients[i].thing;
111 if (thing ==
null || thing.isDestroyed || thing.Num <
this.reqs[i] * numCraft)
116 if (destoryResources)
118 this.resources.Add(thing.Split(
this.reqs[i]));
125 if (destoryResources)
127 foreach (
Thing thing2
in this.resources)
131 this.resources.Clear();
137 public override void OnProgressComplete()
139 if (this.owner ==
null)
143 Element orCreateElement = this.owner.elements.GetOrCreateElement(this.recipe.source.GetReqSkill());
144 for (
int i = 0; i < this.num; i++)
147 if (!this.IsIngredientsValid(
true, 1))
149 Msg.Say(
"invalidCraftResource");
152 this.recipe.Craft(this.blessed, i == 0,
null,
false);
153 this.owner.elements.ModExp(orCreateElement.id, 200,
false);
154 this.resources.Clear();
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);
163 public void PutOutResources()
165 foreach (
Thing t
in this.resources)
167 EClass._zone.AddCard(t, this.CraftPos);
169 this.resources.Clear();
174 public Thing factory;
190 public List<Thing> resources =
new List<Thing>();
202 public bool floatMode;
205 public BlessedState blessed;