Skip to content

Commit 190ad56

Browse files
update error handling
1 parent 7a35143 commit 190ad56

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

Code/MethodSystem/Methods/PickupMethods/DeletePickupMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public override void Execute()
2929
var obj = Args.GetReference<Pickup>("pickup/projectile reference");
3030

3131
if (!NetworkServer.spawned.ContainsValue(obj.NetworkIdentity))
32-
throw new ScriptRuntimeError(ErrorReasons[0]);
32+
throw new ScriptRuntimeError(this, ErrorReasons[0]);
3333

3434
obj.Destroy();
3535
}

Code/MethodSystem/Methods/PickupMethods/SpawnPickupPlayerMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ public override void Execute()
2525
var obj = Args.GetReference<Pickup>("pickup/projectile reference");
2626
var plr = Args.GetPlayer("player to spawn pickup on");
2727

28-
SpawnPickupPosMethod.SpawnPickup(obj, plr.Position);
28+
SpawnPickupPosMethod.SpawnPickup(obj, plr.Position, this);
2929
}
3030
}

Code/MethodSystem/Methods/PickupMethods/SpawnPickupPosMethod.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,22 @@ public override void Execute()
3737
Args.GetFloat("y position"),
3838
Args.GetFloat("z position"));
3939

40-
SpawnPickup(obj, pos);
40+
SpawnPickup(obj, pos, this);
4141
}
4242

4343
// this is here just to make the ErrorReasons universal across all the pickup-spawning methods
44-
public static SpawnPickupPosMethod Singleton => field is null ? field = new SpawnPickupPosMethod() : field;
44+
public static SpawnPickupPosMethod Singleton
45+
{
46+
get => field is null ? field = new SpawnPickupPosMethod() : field;
47+
} = null!;
4548

46-
public static void SpawnPickup(Pickup obj, Vector3 pos)
49+
public static void SpawnPickup(Pickup obj, Vector3 pos, Method caller)
4750
{
4851
obj.Position = pos;
4952
obj.Rotation = Quaternion.identity;
5053
obj.GameObject.SetActive(true);
5154
if (NetworkServer.spawned.ContainsValue(obj.NetworkIdentity))
52-
throw new ScriptRuntimeError(Singleton.ErrorReasons[0]);
55+
throw new ScriptRuntimeError(caller, Singleton.ErrorReasons[0]);
5356
NetworkServer.Spawn(obj.GameObject);
5457
if (obj is Projectile projectile)
5558
projectile.Base.ServerActivate();

Code/MethodSystem/Methods/PickupMethods/SpawnPickupRoomMethod.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ public override void Execute()
4141
Args.GetFloat("relative y"),
4242
Args.GetFloat("relative z")));
4343

44-
SpawnPickupPosMethod.SpawnPickup(obj, pos);
44+
SpawnPickupPosMethod.SpawnPickup(obj, pos, this);
4545
}
4646
}

0 commit comments

Comments
 (0)