Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
AI_Haul.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2
3public class AI_Haul : AIAct
4{
5 public Thing dest;
6
7 public static List<Thing> _list = new List<Thing>();
8
9 public override IEnumerable<Status> Run()
10 {
11 if (dest.ExistsOnMap)
12 {
13 yield return DoGoto(dest.pos, 1);
14 }
15 if (!dest.ExistsOnMap)
16 {
17 yield return Success();
18 }
20 {
21 owner.Say("haul", owner, dest);
22 if (dest.id == "731")
23 {
24 owner.Talk("clean");
25 }
26 else
27 {
28 owner.Talk("haul");
29 }
30 }
31 yield return Success();
32 }
33
34 public static Thing GetThingToClean(Chara c = null)
35 {
36 _list.Clear();
37 foreach (Thing thing in EClass._map.things)
38 {
39 if (thing.placeState == PlaceState.roaming && !thing.isMasked && (thing.id == "731" || thing.id == "_egg" || thing.id == "egg_fertilized" || thing.id == "milk"))
40 {
41 _list.Add(thing);
42 }
43 }
44 if (_list.Count == 0)
45 {
46 return null;
47 }
48 if (c != null)
49 {
50 Thing result = null;
51 int num = 9999;
52 {
53 foreach (Thing item in _list)
54 {
55 int num2 = c.pos.Distance(item.pos);
56 if (num2 < num && EClass._zone.TryAddThingInSharedContainer(item, null, add: false))
57 {
58 num = num2;
59 result = item;
60 }
61 }
62 return result;
63 }
64 }
65 _list.Shuffle();
66 foreach (Thing item2 in _list)
67 {
68 if (EClass._zone.TryAddThingInSharedContainer(item2, null, add: false))
69 {
70 return item2;
71 }
72 }
73 return null;
74 }
75
76 public static AI_Haul TryGetAI(Chara c)
77 {
78 Thing thingToClean = GetThingToClean(c);
79 if (thingToClean != null)
80 {
81 return new AI_Haul
82 {
83 dest = thingToClean
84 };
85 }
86 return null;
87 }
88}
PlaceState
Definition: PlaceState.cs:2
Definition: AIAct.cs:6
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
static AI_Haul TryGetAI(Chara c)
Definition: AI_Haul.cs:76
static List< Thing > _list
Definition: AI_Haul.cs:7
override IEnumerable< Status > Run()
Definition: AI_Haul.cs:9
static Thing GetThingToClean(Chara c=null)
Definition: AI_Haul.cs:34
Thing dest
Definition: AI_Haul.cs:5
void Add(Act a, string s="")
Definition: ActPlan.cs:11
bool isMasked
Definition: Card.cs:562
string id
Definition: Card.cs:31
void Talk(string idTopic, string ref1=null, string ref2=null, bool forceSync=false)
Definition: Card.cs:5949
bool ExistsOnMap
Definition: Card.cs:1961
PlaceState placeState
Definition: Card.cs:79
Point pos
Definition: Card.cs:55
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6046
Definition: Chara.cs:10
Definition: EClass.cs:5
static Zone _zone
Definition: EClass.cs:20
static Map _map
Definition: EClass.cs:18
List< Thing > things
Definition: Map.cs:49
int Distance(Point p)
Definition: Point.cs:953
Definition: Thing.cs:8
bool TryAddThingInSharedContainer(Thing t, List< Thing > containers=null, bool add=true, bool msg=false, Chara chara=null, bool sharedOnly=true)
Definition: Zone.cs:2036