Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
AI_HaulResource.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using UnityEngine;
3
5{
6 public Recipe recipe;
7
8 public Thing target;
9
10 public List<Thing> resources;
11
12 public int[] reqs;
13
14 public override IEnumerable<Status> Run()
15 {
16 bool flag;
17 do
18 {
19 flag = true;
20 for (int i = 0; i < recipe.ingredients.Count; i++)
21 {
23 if (reqs[i] <= 0)
24 {
25 continue;
26 }
27 if (ing.thing == null)
28 {
29 ing.RefreshThing();
30 }
31 if (ing.thing == null || ing.thing.isDestroyed)
32 {
33 ing.thing = null;
34 yield return Cancel();
35 }
36 if (!HoldingResource(ing))
37 {
38 yield return DoGrab(ing.thing, reqs[i]);
39 }
40 if (target == null)
41 {
42 while (true)
43 {
44 Point objPos = null;
45 Point blockPos = null;
46 pos.ForeachMultiSize(recipe.W, recipe.H, delegate(Point p, bool main)
47 {
49 {
50 objPos = p.Copy();
51 }
53 {
54 blockPos = p.Copy();
55 }
56 });
57 if (blockPos != null)
58 {
59 yield return Do(new TaskMine
60 {
61 pos = blockPos
62 });
63 continue;
64 }
65 if (objPos == null)
66 {
67 break;
68 }
69 yield return Do(new TaskCut
70 {
71 pos = objPos
72 });
73 }
75 }
76 else
77 {
78 yield return DoGoto(target);
79 }
80 if (reqs[i] > 0 && HoldingResource(ing))
81 {
82 int num = Mathf.Min(reqs[i], owner.held.Num);
83 reqs[i] -= num;
85 owner.PlaySound("build_resource");
86 }
87 flag = false;
88 break;
89 }
90 }
91 while (!flag);
92 }
93
95 {
96 if (owner != null && owner.held != null && owner.held.id == ing.id && (ing.mat == -1 || owner.held.material.id == ing.mat))
97 {
98 if (ing.refVal != -1)
99 {
100 return owner.held.refVal == ing.refVal;
101 }
102 return true;
103 }
104 return false;
105 }
106}
if(item3.idFile==idFirstFile &&item3.id==idFirstTopic)
Definition: UIBook.cs:627
Status DoGrab(Card card, int num=-1, bool pickHeld=false, Func< Status > _onChildFail=null)
Definition: AIAct.cs:492
Status Do(AIAct _seq, Func< Status > _onChildFail=null)
Definition: AIAct.cs:416
new Chara owner
Definition: AIAct.cs:14
Status DoGoto(Point pos, int dist=0, bool ignoreConnection=false, Func< Status > _onChildFail=null)
Definition: AIAct.cs:432
List< Thing > resources
override IEnumerable< Status > Run()
bool HoldingResource(Recipe.Ingredient ing)
void Add(Act a, string s="")
Definition: ActPlan.cs:11
bool isDestroyed
Definition: Card.cs:71
string id
Definition: Card.cs:31
SourceMaterial.Row material
Definition: Card.cs:1927
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5404
int Num
Definition: Card.cs:154
Card held
Definition: Chara.cs:67
Card SplitHeld(int a)
Definition: Chara.cs:4196
Definition: Point.cs:9
void ForeachMultiSize(int w, int h, Action< Point, bool > action)
Definition: Point.cs:1349
bool HasMinableBlock
Definition: Point.cs:144
bool HasObj
Definition: Point.cs:137
bool HasBlock
Definition: Point.cs:141
Thing RefreshThing()
Definition: Recipe.cs:59
Definition: Recipe.cs:7
virtual TileType tileType
Definition: Recipe.cs:198
List< Ingredient > ingredients
Definition: Recipe.cs:164
virtual int H
Definition: Recipe.cs:252
virtual int W
Definition: Recipe.cs:240
Point pos
Definition: TaskPoint.cs:11
virtual bool destIgnoreConnection
Definition: TaskPoint.cs:19
virtual int destDist
Definition: TaskPoint.cs:17
override Status Cancel()
Definition: Task.cs:54
Definition: Thing.cs:8
virtual bool CanBuiltOnBlock
Definition: TileType.cs:191
virtual bool AllowObj
Definition: TileType.cs:217