File tree Expand file tree Collapse file tree 1 file changed +8
-10
lines changed
pacman-ui-lib/src/main/java/de/amr/pacmanfx/uilib/assets Expand file tree Collapse file tree 1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -30,30 +30,28 @@ public SpriteMap(Class<SID> spriteIdClass) {
30
30
data = new EnumMap <>(spriteIdClass );
31
31
}
32
32
33
- public RectShort sprite (SID id ) {
33
+ private SpriteData get (SID id ) {
34
34
requireNonNull (id );
35
35
if (!data .containsKey (id )) {
36
36
throw new IllegalArgumentException ("Unknown sprite ID '%s'" .formatted (id ));
37
37
}
38
- Object value = data .get (id );
38
+ SpriteData value = data .get (id );
39
39
if (value == null ) {
40
40
throw new IllegalArgumentException ("Sprite value is null for id '%s'" .formatted (id ));
41
41
}
42
+ return value ;
43
+ }
44
+
45
+ public RectShort sprite (SID id ) {
46
+ SpriteData value = get (id );
42
47
if (value instanceof SingleSprite (RectShort rect )) {
43
48
return rect ;
44
49
}
45
50
throw new IllegalArgumentException ("Sprite ID '%s' does not reference a sprite" .formatted (id ));
46
51
}
47
52
48
53
public RectShort [] spriteSequence (SID id ) {
49
- requireNonNull (id );
50
- if (!data .containsKey (id )) {
51
- throw new IllegalArgumentException ("Unknown sprite ID '%s'" .formatted (id ));
52
- }
53
- Object value = data .get (id );
54
- if (value == null ) {
55
- throw new IllegalArgumentException ("Sprite value is null for id '%s'" .formatted (id ));
56
- }
54
+ SpriteData value = get (id );
57
55
if (value instanceof SpriteSequence (RectShort [] sequence )) {
58
56
return sequence ;
59
57
}
You can’t perform that action at this time.
0 commit comments