line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright (c) 2016 Timm Murray |
2
|
|
|
|
|
|
|
# All rights reserved. |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Redistribution and use in source and binary forms, with or without |
5
|
|
|
|
|
|
|
# modification, are permitted provided that the following conditions are met: |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# * Redistributions of source code must retain the above copyright notice, |
8
|
|
|
|
|
|
|
# this list of conditions and the following disclaimer. |
9
|
|
|
|
|
|
|
# * Redistributions in binary form must reproduce the above copyright |
10
|
|
|
|
|
|
|
# notice, this list of conditions and the following disclaimer in the |
11
|
|
|
|
|
|
|
# documentation and/or other materials provided with the distribution. |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
14
|
|
|
|
|
|
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15
|
|
|
|
|
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
16
|
|
|
|
|
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
17
|
|
|
|
|
|
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
18
|
|
|
|
|
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
19
|
|
|
|
|
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
20
|
|
|
|
|
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
21
|
|
|
|
|
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
22
|
|
|
|
|
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
23
|
|
|
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE. |
24
|
|
|
|
|
|
|
package Game::Asset::Type; |
25
|
|
|
|
|
|
|
$Game::Asset::Type::VERSION = '0.4'; |
26
|
7
|
|
|
7
|
|
528
|
use strict; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
162
|
|
27
|
7
|
|
|
7
|
|
31
|
use warnings; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
134
|
|
28
|
7
|
|
|
7
|
|
2580
|
use Moose::Role; |
|
7
|
|
|
|
|
30007
|
|
|
7
|
|
|
|
|
27
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
requires 'type'; |
32
|
|
|
|
|
|
|
requires '_process_content'; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has 'name' => ( |
35
|
|
|
|
|
|
|
is => 'ro', |
36
|
|
|
|
|
|
|
isa => 'Str', |
37
|
|
|
|
|
|
|
required => 1, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
has 'full_name' => ( |
40
|
|
|
|
|
|
|
is => 'ro', |
41
|
|
|
|
|
|
|
isa => 'Str', |
42
|
|
|
|
|
|
|
required => 1, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
has 'has_been_processed' => ( |
45
|
|
|
|
|
|
|
traits => ['Bool'], |
46
|
|
|
|
|
|
|
is => 'ro', |
47
|
|
|
|
|
|
|
isa => 'Bool', |
48
|
|
|
|
|
|
|
handles => { |
49
|
|
|
|
|
|
|
'_set_has_been_processed' => 'set', |
50
|
|
|
|
|
|
|
}, |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
has '_orig_content' => ( |
53
|
|
|
|
|
|
|
is => 'rw', |
54
|
|
|
|
|
|
|
isa => 'Str', |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub process_content |
59
|
|
|
|
|
|
|
{ |
60
|
8
|
|
|
8
|
1
|
24
|
my ($self, $content) = @_; |
61
|
8
|
50
|
|
|
|
284
|
return if $self->has_been_processed; |
62
|
8
|
|
|
|
|
47
|
$self->_process_content( $content ); |
63
|
8
|
|
|
|
|
267
|
$self->_set_has_been_processed; |
64
|
8
|
|
|
|
|
25
|
return; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
__END__ |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 NAME |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Game::Asset::Type - Role for asset types |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 DESCRIPTION |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Each file in the asset archive is represented by a class that does this role. |
79
|
|
|
|
|
|
|
Types are determined by L<Game::Asset> using the file extension. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 PROVIDES |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 process_content |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This is called with the full data. If it's the first time the data was passed, |
86
|
|
|
|
|
|
|
then it calls C<_process_content()> and sets C<has_been_processed()> to true. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 name |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
The short name (without extension) of the asset. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 full_name |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
The full name (with extension) of the asset. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 has_been_processed |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Boolean. If true, then the asset data has already been passed once to |
99
|
|
|
|
|
|
|
C<process_content()>. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 _orig_content |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
The C<_process_content()> method should set this to the original, untouched |
104
|
|
|
|
|
|
|
data passed in. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 REQUIRES |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 type |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Returns the name of the type. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head2 _process_content |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Passed the untouched data so it can be processed. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |