Elin Modding Docs Doc
Loading...
Searching...
No Matches
TraitGenerator.cs
1using System;
2using UnityEngine;
3
4// Token: 0x020003E4 RID: 996
5public class TraitGenerator : Trait
6{
7 // Token: 0x17000902 RID: 2306
8 // (get) Token: 0x06001D11 RID: 7441 RVA: 0x000AAC0F File Offset: 0x000A8E0F
9 public virtual bool Waterproof
10 {
11 get
12 {
13 return false;
14 }
15 }
16
17 // Token: 0x17000903 RID: 2307
18 // (get) Token: 0x06001D12 RID: 7442 RVA: 0x000AAC12 File Offset: 0x000A8E12
19 public override bool IsOn
20 {
21 get
22 {
23 return !this.owner.isBroken && !EClass._map.isBreakerDown;
24 }
25 }
26
27 // Token: 0x17000904 RID: 2308
28 // (get) Token: 0x06001D13 RID: 7443 RVA: 0x000AAC30 File Offset: 0x000A8E30
29 public override int Electricity
30 {
31 get
32 {
33 if (this.IsOn)
34 {
35 return base.Electricity;
36 }
37 return 0;
38 }
39 }
40
41 // Token: 0x17000905 RID: 2309
42 // (get) Token: 0x06001D14 RID: 7444 RVA: 0x000AAC42 File Offset: 0x000A8E42
43 public override bool UseAltTiles
44 {
45 get
46 {
47 return this.Electricity > 0;
48 }
49 }
50
51 // Token: 0x06001D15 RID: 7445 RVA: 0x000AAC50 File Offset: 0x000A8E50
52 public override void OnSimulateHour(VirtualDate date)
53 {
54 if (!date.IsRealTime || !this.owner.IsInstalled)
55 {
56 return;
57 }
58 if (!this.Waterproof && (this.owner.Cell.IsTopWater || (!this.owner.Cell.HasRoof && !EClass._map.IsIndoor && EClass.world.weather.IsHazard)))
59 {
60 this.ModHP(-10);
61 }
62 else
63 {
64 this.ModHP(10);
65 }
66 int num = this.Electricity * 5 / 10;
67 if (!this.owner.isBroken && EClass._zone.electricity < num && (num - EClass._zone.electricity) * 100 / num >= EClass.rnd(150))
68 {
69 this.ShortOut();
70 }
71 }
72
73 // Token: 0x06001D16 RID: 7446 RVA: 0x000AAD20 File Offset: 0x000A8F20
74 public void ModHP(int a)
75 {
76 this.owner.hp = Mathf.Clamp(this.owner.hp + a, 1, 100);
77 if (!this.owner.isBroken && this.owner.hp < 50)
78 {
79 this.ShortOut();
80 return;
81 }
82 if (this.owner.isBroken && this.owner.hp >= 50)
83 {
84 this.Recover();
85 }
86 }
87
88 // Token: 0x06001D17 RID: 7447 RVA: 0x000AAD94 File Offset: 0x000A8F94
89 public void Recover()
90 {
91 this.owner.hp = 80;
92 this.owner.isBroken = false;
93 this.owner.PlaySound("electricity_on", 1f, true);
94 this.owner.Say("electricity_recover", this.owner, null, null);
95 EClass._zone.RefreshElectricity();
96 }
97
98 // Token: 0x06001D18 RID: 7448 RVA: 0x000AADF4 File Offset: 0x000A8FF4
99 public void ShortOut()
100 {
101 this.owner.hp -= 20 + EClass.rnd(30);
102 this.owner.isBroken = true;
103 this.owner.PlaySound("electricity_off", 1f, true);
104 this.owner.Say("electricity_short", this.owner, null, null);
105 EClass._zone.RefreshElectricity();
106 }
107}
Definition Trait.cs:9