1
- using GeometryDashAPI . Attributes ;
1
+ using System ;
2
+ using GeometryDashAPI . Attributes ;
2
3
using GeometryDashAPI . Levels . Enums ;
3
- using GeometryDashAPI . Levels . GameObjects . Default ;
4
4
5
5
namespace GeometryDashAPI . Levels . GameObjects . Specific
6
6
{
7
+ /// <summary>
8
+ /// Represents the id of the speed block.<br/><br/>
9
+ /// Not to be confused with <see cref="SpeedType"/>.<br/>
10
+ /// Because it is responsible for a specific speed, instead of a specific block id
11
+ /// </summary>
7
12
public enum SpeedBlockId
8
13
{
9
14
Orange = 200 ,
@@ -14,26 +19,59 @@ public enum SpeedBlockId
14
19
}
15
20
16
21
[ GameBlock ( 200 , 201 , 202 , 203 , 1334 ) ]
17
- public class SpeedBlock : Block
22
+ public class SpeedBlock : Portal
18
23
{
19
24
[ GameProperty ( "24" , ( short ) Layer . B2 ) ] protected override short zLayer { get ; set ; } = ( short ) Layer . B2 ;
20
25
[ GameProperty ( "25" , - 6 ) ] public override int ZOrder { get ; set ; } = - 6 ;
21
26
22
- [ GameProperty ( "13" , true , true ) ]
23
- public bool Using { get ; set ; } = true ;
24
-
25
27
public SpeedBlockId BlockType
26
28
{
27
29
get => ( SpeedBlockId ) Id ;
28
30
set => Id = ( int ) value ;
29
31
}
30
32
33
+ public SpeedType SpeedType
34
+ {
35
+ get => FromBlockIdToSpeedType ( BlockType ) ;
36
+ set => BlockType = FromSpeedTypeToBlockId ( value ) ;
37
+ }
38
+
31
39
public SpeedBlock ( ) : base ( 201 )
32
40
{
33
41
}
34
42
35
43
public SpeedBlock ( SpeedBlockId type ) : base ( ( int ) type )
36
44
{
37
45
}
46
+
47
+ public SpeedBlock ( SpeedType type ) : base ( ( int ) FromSpeedTypeToBlockId ( type ) )
48
+ {
49
+ }
50
+
51
+ public static SpeedType FromBlockIdToSpeedType ( SpeedBlockId id )
52
+ {
53
+ return id switch
54
+ {
55
+ SpeedBlockId . Orange => SpeedType . Half ,
56
+ SpeedBlockId . Default => SpeedType . Default ,
57
+ SpeedBlockId . Green => SpeedType . X2 ,
58
+ SpeedBlockId . Purple => SpeedType . X3 ,
59
+ SpeedBlockId . Red => SpeedType . X4 ,
60
+ _ => throw new ArgumentOutOfRangeException ( nameof ( id ) , id , null )
61
+ } ;
62
+ }
63
+
64
+ public static SpeedBlockId FromSpeedTypeToBlockId ( SpeedType speedType )
65
+ {
66
+ return speedType switch
67
+ {
68
+ SpeedType . Half => SpeedBlockId . Orange ,
69
+ SpeedType . Default => SpeedBlockId . Default ,
70
+ SpeedType . X2 => SpeedBlockId . Green ,
71
+ SpeedType . X3 => SpeedBlockId . Purple ,
72
+ SpeedType . X4 => SpeedBlockId . Red ,
73
+ _ => throw new ArgumentOutOfRangeException ( nameof ( speedType ) , speedType , null )
74
+ } ;
75
+ }
38
76
}
39
77
}
0 commit comments