1+ using LabApi . Features . Wrappers ;
2+ using SER . ArgumentSystem . Arguments ;
3+ using SER . ArgumentSystem . BaseArguments ;
4+ using SER . ArgumentSystem . Structures ;
5+ using SER . Helpers . Exceptions ;
6+ using SER . MethodSystem . BaseMethods ;
7+ using SER . ValueSystem ;
8+
9+ namespace SER . MethodSystem . Methods . PickupMethods ;
10+
11+ public class PickupInfoMethod : ReturningMethod
12+ {
13+ public override string Description => "Returns information about a pickup." ;
14+
15+ public override Type [ ] ReturnTypes =>
16+ [
17+ typeof ( PlayerValue ) ,
18+ typeof ( BoolValue ) ,
19+ typeof ( TextValue ) ,
20+ typeof ( ReferenceValue < Room > ) ,
21+ typeof ( NumberValue )
22+ ] ;
23+
24+ public override Argument [ ] ExpectedArguments { get ; } =
25+ [
26+ new ReferenceArgument < Pickup > ( "pickup" ) ,
27+ new OptionsArgument ( "property" ,
28+ "isDestroyed" ,
29+ "hasSpawned" ,
30+ Option . Enum < ItemType > ( ) ,
31+ "lastOwner" ,
32+ "isInUse" ,
33+ Option . Enum < ItemCategory > ( ) ,
34+ Option . Reference < Room > ( "room" ) ,
35+ "positionX" ,
36+ "positionY" ,
37+ "positionZ"
38+ )
39+ ] ;
40+
41+ public override void Execute ( )
42+ {
43+ var pickup = Args . GetReference < Pickup > ( "pickup" ) ;
44+
45+ ReturnValue = Args . GetOption ( "property" ) switch
46+ {
47+ "isdestroyed" => new BoolValue ( pickup . IsDestroyed ) ,
48+ "hasspawned" => new BoolValue ( pickup . IsSpawned ) ,
49+ "itemtype" => new TextValue ( pickup . Type . ToString ( ) ) ,
50+ "lastowner" => new PlayerValue ( pickup . LastOwner is not null
51+ ? [ pickup . LastOwner ]
52+ : Array . Empty < Player > ( ) ) ,
53+ "isinuse" => new BoolValue ( pickup . IsInUse ) ,
54+ "itemcategory" => new TextValue ( pickup . Category . ToString ( ) ) ,
55+ "room" => new ReferenceValue ( pickup . Room ) ,
56+ "positionx" => new NumberValue ( ( decimal ) pickup . Position . x ) ,
57+ "positiony" => new NumberValue ( ( decimal ) pickup . Position . y ) ,
58+ "positionz" => new NumberValue ( ( decimal ) pickup . Position . z ) ,
59+ _ => throw new AndrzejFuckedUpException ( "out of range" )
60+ } ;
61+ }
62+ }
0 commit comments