63 |
_position = position; |
_position = position; |
64 |
} |
} |
65 |
|
|
66 |
|
[[NSNotificationCenter defaultCenter] |
67 |
|
postNotificationName:@"updateObject" object: _game]; |
68 |
|
|
69 |
return self; |
return self; |
70 |
} |
} |
71 |
|
|
77 |
} |
} |
78 |
|
|
79 |
/** |
/** |
80 |
|
* Returns the game. |
81 |
|
*/ |
82 |
|
- (HgGame *) game |
83 |
|
{ |
84 |
|
return _game; |
85 |
|
} |
86 |
|
|
87 |
|
/** |
88 |
* Returns the object identifier. |
* Returns the object identifier. |
89 |
*/ |
*/ |
90 |
- (unsigned) identifier |
- (unsigned) identifier |
120 |
* FIXME - check position |
* FIXME - check position |
121 |
*/ |
*/ |
122 |
//[_position mapContainsPosition: position] |
//[_position mapContainsPosition: position] |
123 |
|
|
124 |
[[NSNotificationCenter defaultCenter] |
[[NSNotificationCenter defaultCenter] |
125 |
postNotificationName:@"updateObject" object:self]; |
postNotificationName:@"updateObject" object: _game]; |
126 |
|
|
127 |
_position = position; |
_position = position; |
128 |
} |
} |
142 |
- (void) setOrientation: (coord_t)orientation |
- (void) setOrientation: (coord_t)orientation |
143 |
{ |
{ |
144 |
[[NSNotificationCenter defaultCenter] |
[[NSNotificationCenter defaultCenter] |
145 |
postNotificationName:@"updateObject" object:self]; |
postNotificationName:@"updateObject" object: _game]; |
146 |
|
|
147 |
_orientation = orientation; |
_orientation = orientation; |
148 |
} |
} |
175 |
/* FIXME - not implemented */ |
/* FIXME - not implemented */ |
176 |
} |
} |
177 |
|
|
178 |
|
@end |
179 |
|
|
180 |
|
@implementation HgObject (NSCoding) |
181 |
|
|
182 |
/** |
/** |
183 |
* NSCoding method |
* NSCoding method |
184 |
* to encode and decode objects |
* to encode and decode objects |
185 |
*/ |
*/ |
186 |
- (void)encodeWithCoder: (NSCoder *)encoder |
- (void)encodeWithCoder: (NSCoder *)encoder |
187 |
{ |
{ |
188 |
[encoder encodeValueOfObjCType: "I" at: &_identifier]; |
[encoder encodeValueOfObjCType: "I" at: &_identifier]; |
195 |
{ |
{ |
196 |
[decoder decodeValueOfObjCType: "I" at: &_identifier]; |
[decoder decodeValueOfObjCType: "I" at: &_identifier]; |
197 |
NSNumber *numIdent = [NSNumber numberWithInt: _identifier]; |
NSNumber *numIdent = [NSNumber numberWithInt: _identifier]; |
198 |
|
|
199 |
HgObject *object = [[_game objects] objectForKey: numIdent]; |
HgGame *current = [HgGame currentGame]; |
200 |
|
HgObject *object = [[current objects] objectForKey: numIdent]; |
201 |
|
|
202 |
if (object != nil) |
if (object != nil) |
203 |
{ |
{ |
204 |
DESTROY(self); |
DESTROY(self); |
208 |
{ |
{ |
209 |
self = [super init]; |
self = [super init]; |
210 |
} |
} |
211 |
|
|
212 |
if (self != nil) |
if (self != nil) |
213 |
{ |
{ |
214 |
[decoder decodeValueOfObjCType: @encode(coord_t) at: &_position]; |
[decoder decodeValueOfObjCType: @encode(coord_t) at: &_position]; |
219 |
return self; |
return self; |
220 |
} |
} |
221 |
|
|
|
|
|
222 |
@end |
@end |