Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
TraitGenerator.cs
Go to the documentation of this file.
1using UnityEngine;
2
3public class TraitGenerator : Trait
4{
5 public virtual bool Waterproof => false;
6
7 public override bool IsOn
8 {
9 get
10 {
11 if (!owner.isBroken)
12 {
14 }
15 return false;
16 }
17 }
18
19 public override int Electricity
20 {
21 get
22 {
23 if (IsOn)
24 {
25 return base.Electricity;
26 }
27 return 0;
28 }
29 }
30
31 public override bool UseAltTiles => Electricity > 0;
32
33 public override void OnSimulateHour(VirtualDate date)
34 {
35 if (date.IsRealTime && owner.IsInstalled)
36 {
38 {
39 ModHP(-10);
40 }
41 else
42 {
43 ModHP(10);
44 }
45 if (!owner.isBroken && EClass._zone.electricity < 0 && 100 >= EClass.rnd(150))
46 {
47 ShortOut();
48 }
49 }
50 }
51
52 public void ModHP(int a)
53 {
54 owner.hp = Mathf.Clamp(owner.hp + a, 1, 100);
55 if (!owner.isBroken && owner.hp < 50)
56 {
57 ShortOut();
58 }
59 else if (owner.isBroken && owner.hp >= 50)
60 {
61 Recover();
62 }
63 }
64
65 public void Recover()
66 {
67 owner.hp = 80;
68 owner.isBroken = false;
69 owner.PlaySound("electricity_on");
70 owner.Say("electricity_recover", owner);
72 }
73
74 public void ShortOut()
75 {
76 owner.hp -= 20 + EClass.rnd(30);
77 owner.isBroken = true;
78 owner.PlaySound("electricity_off");
79 owner.Say("electricity_short", owner);
81 }
82
83 public override void SetName(ref string s)
84 {
85 if (owner.isBroken)
86 {
87 s = "gen_broken".lang(s);
88 }
89 }
90}
bool isBroken
Definition: Card.cs:706
SoundSource PlaySound(string id, float v=1f, bool spatial=true)
Definition: Card.cs:5404
int hp
Definition: Card.cs:226
bool IsInstalled
Definition: Card.cs:2241
Cell Cell
Definition: Card.cs:1931
void Say(string lang, string ref1=null, string ref2=null)
Definition: Card.cs:6046
bool IsTopWater
Definition: Cell.cs:700
bool HasRoof
Definition: Cell.cs:648
Definition: EClass.cs:5
static int rnd(int a)
Definition: EClass.cs:50
static Zone _zone
Definition: EClass.cs:20
static World world
Definition: EClass.cs:40
static Map _map
Definition: EClass.cs:18
bool IsIndoor
Definition: Map.cs:131
bool isBreakerDown
Definition: Map.cs:110
int electricity
Definition: Spatial.cs:250
override bool UseAltTiles
virtual bool Waterproof
void ModHP(int a)
override int Electricity
override void OnSimulateHour(VirtualDate date)
override void SetName(ref string s)
override bool IsOn
Definition: Trait.cs:7
Card owner
Definition: Trait.cs:26
bool IsRealTime
Definition: VirtualDate.cs:7
bool IsHazard
Definition: Weather.cs:93
Weather weather
Definition: World.cs:12
void RefreshElectricity()
Definition: Zone.cs:2636