3
3
using Content . Server . Body . Systems ;
4
4
using Content . Server . Construction ;
5
5
using Content . Server . Construction . Components ;
6
+ using Content . Server . SS220 . LockPick . Components ;
6
7
using Content . Server . Storage . Components ;
7
8
using Content . Shared . Destructible ;
8
9
using Content . Shared . Explosion ;
9
10
using Content . Shared . Foldable ;
10
11
using Content . Shared . Interaction ;
11
12
using Content . Shared . Lock ;
12
13
using Content . Shared . Movement . Events ;
14
+ using Content . Shared . Popups ;
15
+ using Content . Shared . SS220 . LockPick ;
13
16
using Content . Shared . Storage . Components ;
14
17
using Content . Shared . Storage . EntitySystems ;
15
18
using Content . Shared . Tools . Systems ;
16
19
using Content . Shared . Verbs ;
17
20
using Robust . Server . GameObjects ;
21
+ using Robust . Shared . Audio . Systems ;
18
22
using Robust . Shared . Containers ;
19
23
using Robust . Shared . GameStates ;
20
24
using Robust . Shared . Map ;
25
+ using Robust . Shared . Random ;
21
26
22
27
namespace Content . Server . Storage . EntitySystems ;
23
28
@@ -27,6 +32,10 @@ public sealed class EntityStorageSystem : SharedEntityStorageSystem
27
32
[ Dependency ] private readonly AtmosphereSystem _atmos = default ! ;
28
33
[ Dependency ] private readonly IMapManager _map = default ! ;
29
34
[ Dependency ] private readonly MapSystem _mapSystem = default ! ;
35
+ [ Dependency ] private readonly IRobustRandom _random = default ! ;
36
+ [ Dependency ] private readonly SharedPopupSystem _popups = default ! ;
37
+ [ Dependency ] private readonly LockSystem _lockSystem = default ! ;
38
+ [ Dependency ] private readonly SharedAudioSystem _audio = default ! ;
30
39
31
40
public override void Initialize ( )
32
41
{
@@ -51,6 +60,8 @@ public override void Initialize()
51
60
SubscribeLocalEvent < EntityStorageComponent , WeldableAttemptEvent > ( OnWeldableAttempt ) ;
52
61
SubscribeLocalEvent < EntityStorageComponent , BeforeExplodeEvent > ( OnExploded ) ;
53
62
63
+ SubscribeLocalEvent < EntityStorageComponent , LockPickEvent > ( OnLockPick ) ;
64
+
54
65
SubscribeLocalEvent < InsideEntityStorageComponent , InhaleLocationEvent > ( OnInsideInhale ) ;
55
66
SubscribeLocalEvent < InsideEntityStorageComponent , ExhaleLocationEvent > ( OnInsideExhale ) ;
56
67
SubscribeLocalEvent < InsideEntityStorageComponent , AtmosExposedGetAirEvent > ( OnInsideExposed ) ;
@@ -107,6 +118,32 @@ private void OnExploded(Entity<EntityStorageComponent> ent, ref BeforeExplodeEve
107
118
args . Contents . AddRange ( ent . Comp . Contents . ContainedEntities ) ;
108
119
}
109
120
121
+ //ss220 lockpick add start
122
+ private void OnLockPick ( Entity < EntityStorageComponent > ent , ref LockPickEvent args )
123
+ {
124
+ if ( args . Cancelled )
125
+ return ;
126
+
127
+ if ( ! TryComp < TargetLockPickComponent > ( ent . Owner , out var targetLockPickComponent ) )
128
+ return ;
129
+
130
+ if ( ! TryComp < LockpickComponent > ( args . Target , out var lockpickComponent ) )
131
+ return ;
132
+
133
+ if ( ! _random . Prob ( targetLockPickComponent . ChanceToLockPick ) )
134
+ {
135
+ _popups . PopupEntity ( Loc . GetString ( "lockpick-failed" ) , args . User , args . User ) ;
136
+ return ;
137
+ }
138
+
139
+ _lockSystem . Unlock ( ent . Owner , args . User ) ;
140
+ OpenStorage ( ent . Owner ) ;
141
+
142
+ _audio . PlayPvs ( lockpickComponent . LockPickSound , ent . Owner ) ;
143
+ _popups . PopupEntity ( Loc . GetString ( "lockpick-successful" ) , args . User , args . User ) ;
144
+ }
145
+ //ss220 lockpick add end
146
+
110
147
protected override void TakeGas ( EntityUid uid , SharedEntityStorageComponent component )
111
148
{
112
149
if ( ! component . Airtight )
0 commit comments