Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
TraitGeneratorWheel.cs
Go to the documentation of this file.
2{
3 public override bool HaveUpdate => true;
4
5 public override bool Waterproof => true;
6
7 public override ToggleType ToggleType => ToggleType.Custom;
8
9 public override bool IsOn
10 {
11 get
12 {
13 if (!owner.isOn)
14 {
15 return !EClass._zone.IsPCFaction;
16 }
17 return true;
18 }
19 }
20
21 public override bool CanUse(Chara c)
22 {
24 {
25 return !owner.pos.HasChara;
26 }
27 return false;
28 }
29
30 public override bool OnUse(Chara c)
31 {
32 LayerPeople.CreateSelect("", "", delegate(UIList l)
33 {
34 foreach (Chara member in EClass.Branch.members)
35 {
36 if (member.IsAliveInCurrentZone && !member.IsPCParty && member.memberType == FactionMemberType.Default)
37 {
38 l.Add(member);
39 }
40 }
41 }, delegate(Chara c)
42 {
43 c.Teleport(owner.pos, silent: false, force: true);
44 c.RemoveCondition<ConSleep>();
45 c.noMove = true;
46 c.orgPos = new Point(owner.pos);
47 c.PlaySound("ride");
48 });
49 return true;
50 }
51
52 public override void OnStepped(Chara c)
53 {
54 if (!IsOn && ShouldWork())
55 {
56 owner.isOn = true;
57 EClass._zone.dirtyElectricity = true;
58 owner.Say("generator_start", owner);
59 owner.PlaySound("electricity_on");
60 Refresh(c);
61 }
62 }
63
64 public override void OnSteppedOut(Chara c)
65 {
66 Refresh(c);
67 }
68
69 public override void Update()
70 {
71 if (owner.isOn && EClass._zone.IsPCFaction && !ShouldWork())
72 {
73 owner.isOn = false;
74 EClass._zone.dirtyElectricity = true;
75 owner.Say("generator_stop", owner);
76 owner.PlaySound("electricity_off");
77 }
78 }
79
80 public void Refresh(Chara c)
81 {
83 {
85 }
86 }
87
88 public bool ShouldWork()
89 {
90 if (!owner.pos.HasChara)
91 {
92 return false;
93 }
94 int num = 0;
95 foreach (Thing thing in owner.pos.Things)
96 {
97 if (thing.IsInstalled && thing.trait is TraitGeneratorWheel)
98 {
99 num++;
100 }
101 }
102 if (num != 1)
103 {
104 return false;
105 }
107 {
108 return true;
109 }
110 foreach (Chara chara in owner.pos.Charas)
111 {
112 if (chara.IsPCFaction && chara.memberType == FactionMemberType.Default)
113 {
114 return true;
115 }
116 }
117 return false;
118 }
119}
FactionMemberType
ToggleType
Definition: ToggleType.cs:2
list. Refresh()
void Teleport(Point point, bool silent=false, bool force=false)
Definition: Card.cs:5153
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5404
Point pos
Definition: Card.cs:55
Trait trait
Definition: Card.cs:49
bool IsInstalled
Definition: Card.cs:2241
bool isOn
Definition: Card.cs:514
Definition: Chara.cs:10
void RefreshWorkElements(ElementContainer parent=null)
Definition: Chara.cs:8175
override bool IsPCFaction
Definition: Chara.cs:656
FactionMemberType memberType
Definition: Chara.cs:46
FactionBranch homeBranch
Definition: Chara.cs:889
Definition: EClass.cs:5
static Zone _zone
Definition: EClass.cs:20
static FactionBranch Branch
Definition: EClass.cs:22
List< Chara > members
static LayerPeople CreateSelect(string langHeader, string langHint, Action< UIList > onList, Action< Chara > onClick, Func< Chara, string > _onShowSubText=null)
Definition: LayerPeople.cs:176
Definition: Point.cs:9
List< Thing > Things
Definition: Point.cs:314
List< Chara > Charas
Definition: Point.cs:316
bool HasChara
Definition: Point.cs:226
Definition: Thing.cs:8
override bool CanUse(Chara c)
override void Update()
override void OnStepped(Chara c)
override bool OnUse(Chara c)
override void OnSteppedOut(Chara c)
override bool Waterproof
override bool HaveUpdate
Card owner
Definition: Trait.cs:26
Definition: UIList.cs:9
FactionBranch branch
Definition: Zone.cs:34
ElementContainerZone elements
Definition: Zone.cs:43
bool IsPCFaction
Definition: Zone.cs:464