| 1 | package SDL::Tutorial::3DWorld::3DS::Chunk; | ||
| 2 | |||
| 3 | use 5.008; | ||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | |||
| 7 | our $VERSION = '0.33'; | ||
| 8 | |||
| 9 | |||
| 10 | |||
| 11 | |||
| 12 | |||
| 13 | ###################################################################### | ||
| 14 | # Constructor and Accessors | ||
| 15 | |||
| 16 | sub new { | ||
| 17 | my $class = shift; | ||
| 18 | bless { children => [ ], @_ }, $class; | ||
| 19 | } | ||
| 20 | |||
| 21 | sub start { | ||
| 22 | $_[0]->{start}; | ||
| 23 | } | ||
| 24 | |||
| 25 | sub type { | ||
| 26 | $_[0]->{type}; | ||
| 27 | } | ||
| 28 | |||
| 29 | sub bytes { | ||
| 30 | $_[0]->{bytes}; | ||
| 31 | } | ||
| 32 | |||
| 33 | sub children { | ||
| 34 | @{ $_[0]->{children} }; | ||
| 35 | } | ||
| 36 | |||
| 37 | |||
| 38 | |||
| 39 | |||
| 40 | |||
| 41 | ###################################################################### | ||
| 42 | # Parsing Methods | ||
| 43 | |||
| 44 | sub add { | ||
| 45 | push @{ shift->{children} }, @_; | ||
| 46 | } | ||
| 47 | |||
| 48 | sub next_start { | ||
| 49 | $_[0]->{start} + $_[0]->{bytes}; | ||
| 50 | } | ||
| 51 | |||
| 52 | sub child_start { | ||
| 53 | $_[0]->{start} + 6; | ||
| 54 | } | ||
| 55 | |||
| 56 | 1; |