1
- using System . Numerics ;
1
+ using System . Numerics ;
2
2
using Content . Shared . Actions ;
3
3
using Content . Shared . Body . Components ;
4
4
using Content . Shared . Body . Systems ;
7
7
using Content . Shared . Doors . Systems ;
8
8
using Content . Shared . Hands . Components ;
9
9
using Content . Shared . Hands . EntitySystems ;
10
+ using Content . Shared . Humanoid ;
10
11
using Content . Shared . Interaction ;
11
12
using Content . Shared . Inventory ;
12
13
using Content . Shared . Lock ;
13
14
using Content . Shared . Magic . Components ;
14
15
using Content . Shared . Magic . Events ;
15
16
using Content . Shared . Maps ;
17
+ using Content . Shared . Mind ;
18
+ using Content . Shared . Mind . Components ;
19
+ using Content . Shared . Mobs . Components ;
20
+ using Content . Shared . Mobs . Systems ;
16
21
using Content . Shared . Physics ;
17
22
using Content . Shared . Popups ;
18
23
using Content . Shared . Speech . Muting ;
19
24
using Content . Shared . Storage ;
20
25
using Content . Shared . Tag ;
21
26
using Content . Shared . Weapons . Ranged . Components ;
22
27
using Content . Shared . Weapons . Ranged . Systems ;
28
+ using Robust . Shared . Audio . Systems ;
23
29
using Robust . Shared . Map ;
24
30
using Robust . Shared . Map . Components ;
25
31
using Robust . Shared . Network ;
@@ -53,6 +59,9 @@ public abstract class SharedMagicSystem : EntitySystem
53
59
[ Dependency ] private readonly LockSystem _lock = default ! ;
54
60
[ Dependency ] private readonly SharedHandsSystem _hands = default ! ;
55
61
[ Dependency ] private readonly TagSystem _tag = default ! ;
62
+ [ Dependency ] private readonly MobStateSystem _mobState = default ! ;
63
+ [ Dependency ] private readonly SharedAudioSystem _audio = default ! ;
64
+ [ Dependency ] private readonly SharedMindSystem _mind = default ! ;
56
65
57
66
public override void Initialize ( )
58
67
{
@@ -67,6 +76,7 @@ public override void Initialize()
67
76
SubscribeLocalEvent < SmiteSpellEvent > ( OnSmiteSpell ) ;
68
77
SubscribeLocalEvent < KnockSpellEvent > ( OnKnockSpell ) ;
69
78
SubscribeLocalEvent < ChargeSpellEvent > ( OnChargeSpell ) ;
79
+ SubscribeLocalEvent < RandomGlobalSpawnSpellEvent > ( OnRandomGlobalSpawnSpell ) ;
70
80
71
81
// Spell wishlist
72
82
// A wishlish of spells that I'd like to implement or planning on implementing in a future PR
@@ -501,6 +511,37 @@ private void OnChargeSpell(ChargeSpellEvent ev)
501
511
_gunSystem . UpdateBasicEntityAmmoCount ( wand . Value , basicAmmoComp . Count . Value + ev . Charge , basicAmmoComp ) ;
502
512
}
503
513
// End Charge Spells
514
+ #endregion
515
+ #region Global Spells
516
+
517
+ private void OnRandomGlobalSpawnSpell ( RandomGlobalSpawnSpellEvent ev )
518
+ {
519
+ if ( ! _net . IsServer || ev . Handled || ! PassesSpellPrerequisites ( ev . Action , ev . Performer ) || ev . Spawns is not { } spawns )
520
+ return ;
521
+
522
+ ev . Handled = true ;
523
+ Speak ( ev ) ;
524
+
525
+ var allHumans = _mind . GetAliveHumans ( ) ;
526
+
527
+ foreach ( var human in allHumans )
528
+ {
529
+ if ( ! human . Comp . OwnedEntity . HasValue )
530
+ continue ;
531
+
532
+ var ent = human . Comp . OwnedEntity . Value ;
533
+
534
+ var mapCoords = _transform . GetMapCoordinates ( ent ) ;
535
+ foreach ( var spawn in EntitySpawnCollection . GetSpawns ( spawns , _random ) )
536
+ {
537
+ var spawned = Spawn ( spawn , mapCoords ) ;
538
+ _hands . PickupOrDrop ( ent , spawned ) ;
539
+ }
540
+ }
541
+
542
+ _audio . PlayGlobal ( ev . Sound , ev . Performer ) ;
543
+ }
544
+
504
545
#endregion
505
546
// End Spells
506
547
#endregion
0 commit comments