1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
using System;
using Hazel;
using UnityEngine;
public class DeconSystem : MonoBehaviour, ISystemType
{
private const byte HeadUpCmd = 1;
private const byte HeadDownCmd = 2;
private const byte HeadUpInsideCmd = 3;
private const byte HeadDownInsideCmd = 4;
public ManualDoor UpperDoor;
public ManualDoor LowerDoor;
public float DoorOpenTime = 5f;
public float DeconTime = 5f;
private DeconSystem.States curState;
private float timer;
public TextRenderer FloorText;
[Flags]
private enum States : byte
{
Idle = 0,
Enter = 1,
Closed = 2,
Exit = 4,
HeadingUp = 8
}
public bool Detoriorate(float dt)
{
int num = Mathf.CeilToInt(this.timer);
this.timer = Mathf.Max(0f, this.timer - dt);
int num2 = Mathf.CeilToInt(this.timer);
if (num != num2)
{
if (num2 == 0)
{
if (this.curState.HasFlag(DeconSystem.States.Enter))
{
this.curState = ((this.curState & ~DeconSystem.States.Enter) | DeconSystem.States.Closed);
this.timer = this.DeconTime;
}
else if (this.curState.HasFlag(DeconSystem.States.Closed))
{
this.curState = ((this.curState & ~DeconSystem.States.Closed) | DeconSystem.States.Exit);
this.timer = this.DoorOpenTime;
}
else if (this.curState.HasFlag(DeconSystem.States.Exit))
{
this.curState = DeconSystem.States.Idle;
}
}
this.UpdateDoorsViaState();
return true;
}
return false;
}
public void OpenDoor(bool upper)
{
if (this.curState == DeconSystem.States.Idle)
{
ShipStatus.Instance.RpcRepairSystem(SystemTypes.Decontamination, upper ? 2 : 1);
}
}
public void OpenFromInside(bool upper)
{
if (this.curState == DeconSystem.States.Idle)
{
ShipStatus.Instance.RpcRepairSystem(SystemTypes.Decontamination, upper ? 3 : 4);
}
}
public void RepairDamage(PlayerControl player, byte amount)
{
if (this.curState != DeconSystem.States.Idle)
{
return;
}
switch (amount)
{
case 1:
this.curState = (DeconSystem.States.Enter | DeconSystem.States.HeadingUp);
this.timer = this.DoorOpenTime;
break;
case 2:
this.curState = DeconSystem.States.Enter;
this.timer = this.DoorOpenTime;
break;
case 3:
this.curState = (DeconSystem.States.Exit | DeconSystem.States.HeadingUp);
this.timer = this.DoorOpenTime;
break;
case 4:
this.curState = DeconSystem.States.Exit;
this.timer = this.DoorOpenTime;
break;
}
this.UpdateDoorsViaState();
}
public void Serialize(MessageWriter writer, bool initialState)
{
writer.Write((byte)Mathf.CeilToInt(this.timer));
writer.Write((byte)this.curState);
}
public void Deserialize(MessageReader reader, bool initialState)
{
this.timer = (float)reader.ReadByte();
this.curState = (DeconSystem.States)reader.ReadByte();
this.UpdateDoorsViaState();
}
private void UpdateDoorsViaState()
{
int num = Mathf.CeilToInt(this.timer);
if (num > 0)
{
this.FloorText.Text = string.Join("\n", new object[]
{
num,
num,
num,
num
});
}
else
{
this.FloorText.Text = string.Empty;
}
if (this.curState.HasFlag(DeconSystem.States.Enter))
{
bool flag = this.curState.HasFlag(DeconSystem.States.HeadingUp);
this.LowerDoor.SetDoorway(flag);
this.UpperDoor.SetDoorway(!flag);
return;
}
if (this.curState.HasFlag(DeconSystem.States.Closed) || this.curState == DeconSystem.States.Idle)
{
this.LowerDoor.SetDoorway(false);
this.UpperDoor.SetDoorway(false);
return;
}
if (this.curState.HasFlag(DeconSystem.States.Exit))
{
bool flag2 = this.curState.HasFlag(DeconSystem.States.HeadingUp);
this.LowerDoor.SetDoorway(!flag2);
this.UpperDoor.SetDoorway(flag2);
}
}
}
|