Elin Modding Docs Doc
Loading...
Searching...
No Matches
AI_HaulResource.cs
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
5// Token: 0x02000262 RID: 610
7{
8 // Token: 0x06001130 RID: 4400 RVA: 0x000775BB File Offset: 0x000757BB
9 public override IEnumerable<AIAct.Status> Run()
10 {
11 bool flag;
12 do
13 {
14 flag = true;
15 int num2;
16 for (int i = 0; i < this.recipe.ingredients.Count; i = num2 + 1)
17 {
18 Recipe.Ingredient ing = this.recipe.ingredients[i];
19 if (this.reqs[i] > 0)
20 {
21 if (ing.thing == null)
22 {
23 ing.RefreshThing();
24 }
25 if (ing.thing == null || ing.thing.isDestroyed)
26 {
27 ing.thing = null;
28 yield return this.Cancel();
29 }
30 if (!this.HoldingResource(ing))
31 {
32 yield return base.DoGrab(ing.thing, this.reqs[i], false, null);
33 }
34 if (this.target == null)
35 {
36 for (;;)
37 {
38 Point objPos = null;
39 Point blockPos = null;
40 this.pos.ForeachMultiSize(this.recipe.W, this.recipe.H, delegate(Point p, bool main)
41 {
42 if (p.HasObj && !p.HasMinableBlock && !this.recipe.tileType.AllowObj)
43 {
44 objPos = p.Copy();
45 }
46 if (p.HasBlock && !this.recipe.tileType.CanBuiltOnBlock)
47 {
48 blockPos = p.Copy();
49 }
50 });
51 if (blockPos != null)
52 {
53 yield return base.Do(new TaskMine
54 {
55 pos = blockPos
56 }, null);
57 }
58 else
59 {
60 if (objPos == null)
61 {
62 break;
63 }
64 yield return base.Do(new TaskCut
65 {
66 pos = objPos
67 }, null);
68 }
69 }
70 yield return base.DoGoto(this.pos, this.destDist, this.destIgnoreConnection, null);
71 }
72 else
73 {
74 yield return base.DoGoto(this.target, null);
75 }
76 if (this.reqs[i] > 0 && this.HoldingResource(ing))
77 {
78 int num = Mathf.Min(this.reqs[i], this.owner.held.Num);
79 this.reqs[i] -= num;
80 this.resources.Add(this.owner.SplitHeld(num) as Thing);
81 this.owner.PlaySound("build_resource", 1f, true);
82 }
83 flag = false;
84 break;
85 }
86 num2 = i;
87 }
88 }
89 while (!flag);
90 yield break;
91 }
92
93 // Token: 0x06001131 RID: 4401 RVA: 0x000775CC File Offset: 0x000757CC
94 public bool HoldingResource(Recipe.Ingredient ing)
95 {
96 return this.owner != null && this.owner.held != null && this.owner.held.id == ing.id && (ing.mat == -1 || this.owner.held.material.id == ing.mat) && (ing.refVal == -1 || this.owner.held.refVal == ing.refVal);
97 }
98
99 // Token: 0x04000DE2 RID: 3554
100 public Recipe recipe;
101
102 // Token: 0x04000DE3 RID: 3555
103 public Thing target;
104
105 // Token: 0x04000DE4 RID: 3556
106 public List<Thing> resources;
107
108 // Token: 0x04000DE5 RID: 3557
109 public int[] reqs;
110}
Definition AIAct.cs:7
Definition Point.cs:11
Definition Thing.cs:10