1- using JetBrains . Annotations ;
1+ using InventorySystem . Items . Pickups ;
2+ using JetBrains . Annotations ;
23using LabApi . Features . Wrappers ;
34using SER . ArgumentSystem . Arguments ;
45using SER . ArgumentSystem . BaseArguments ;
6+ using SER . Helpers . Exceptions ;
57using SER . MethodSystem . BaseMethods ;
8+ using SER . MethodSystem . MethodDescriptors ;
69
710namespace SER . MethodSystem . Methods . ProjectileMethods ;
811
912[ UsedImplicitly ]
10- public class SpawnProjectileMethod : SynchronousMethod
13+ public class SpawnProjectileMethod : ReferenceReturningMethod < Pickup > , ICanError
1114{
1215 public override string Description => "Spawns a live projectile at a given position." ;
1316
17+ public string [ ] ErrorReasons =>
18+ [
19+ "Failed to spawn projectile with provided arguments."
20+ ] ;
21+
1422 public override Argument [ ] ExpectedArguments { get ; } =
1523 [
1624 new EnumArgument < ProjectileType > ( "projectile type" ) ,
@@ -43,7 +51,7 @@ public override void Execute()
4351 var owner = Args . GetPlayer ( "owner" ) ;
4452 var timeUntilDetonation = Args . GetFloat ( "time until detonation" ) ;
4553
46- TimedGrenadeProjectile . SpawnActive (
54+ var pickupBase = TimedGrenadeProjectile . SpawnActive (
4755 new (
4856 positionX ,
4957 positionY ,
@@ -52,7 +60,14 @@ public override void Execute()
5260 projectileType ,
5361 owner ,
5462 timeUntilDetonation
55- ) ;
63+ ) ? . Base ;
64+
65+ if ( Pickup . Get ( pickupBase ) is not { } pickup )
66+ {
67+ throw new ScriptRuntimeError ( ErrorReasons [ 0 ] ) ;
68+ }
69+
70+ ReturnValue = pickup ;
5671 }
5772
5873 public enum ProjectileType
0 commit comments