63 |
_position = position; |
_position = position; |
64 |
} |
} |
65 |
|
|
|
[[NSNotificationCenter defaultCenter] |
|
|
postNotificationName:@"updateObject" object: _game]; |
|
|
|
|
66 |
return self; |
return self; |
67 |
} |
} |
68 |
|
|
109 |
/** |
/** |
110 |
* Set the current position of the object. |
* Set the current position of the object. |
111 |
* The position must be contained in the map. |
* The position must be contained in the map. |
112 |
* Post an notification named "updateObject" containing the current object. |
* Post an notification named "updateObject" containing the current game and |
113 |
|
* the current object. |
114 |
*/ |
*/ |
115 |
- (void) setPosition: (coord_t)position |
- (void) setPosition: (coord_t)position |
116 |
{ |
{ |
119 |
*/ |
*/ |
120 |
//[_position mapContainsPosition: position] |
//[_position mapContainsPosition: position] |
121 |
|
|
|
[[NSNotificationCenter defaultCenter] |
|
|
postNotificationName:@"updateObject" object: _game]; |
|
|
|
|
122 |
_position = position; |
_position = position; |
123 |
|
|
124 |
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"updateObject" |
125 |
|
object: _game |
126 |
|
userInfo: [NSDictionary dictionaryWithObject: self |
127 |
|
forKey: @"HgObject"]]; |
128 |
|
|
129 |
} |
} |
130 |
|
|
131 |
/** |
/** |
138 |
|
|
139 |
/** |
/** |
140 |
* Set the orientation of the object. |
* Set the orientation of the object. |
141 |
* Post an notification named "updateObject" containing the current object. |
* Post an notification named "updateObject" containing the current game and |
142 |
|
* the current object. |
143 |
*/ |
*/ |
144 |
- (void) setOrientation: (coord_t)orientation |
- (void) setOrientation: (coord_t)orientation |
145 |
{ |
{ |
|
[[NSNotificationCenter defaultCenter] |
|
|
postNotificationName:@"updateObject" object: _game]; |
|
|
|
|
146 |
_orientation = orientation; |
_orientation = orientation; |
147 |
|
|
148 |
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"updateObject" |
149 |
|
object: _game |
150 |
|
userInfo: [NSDictionary dictionaryWithObject: self |
151 |
|
forKey: @"HgObject"]]; |
152 |
} |
} |
153 |
|
|
154 |
/* FIXME implementation a revoir */ |
/* FIXME implementation a revoir */ |
172 |
NSParameterAssert (![_boundingBoxes containsObject: boundingBoxes]); |
NSParameterAssert (![_boundingBoxes containsObject: boundingBoxes]); |
173 |
|
|
174 |
[_boundingBoxes addObject: boundingBoxes]; |
[_boundingBoxes addObject: boundingBoxes]; |
175 |
|
|
176 |
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"updateObject" |
177 |
|
object: _game |
178 |
|
userInfo: [NSDictionary dictionaryWithObject: self |
179 |
|
forKey: @"HgObject"]]; |
180 |
} |
} |
181 |
|
|
182 |
- (void) collide: (HgObject *)object |
- (void) collide: (HgObject *)object |
189 |
@implementation HgObject (NSCoding) |
@implementation HgObject (NSCoding) |
190 |
|
|
191 |
/** |
/** |
192 |
* NSCoding method |
* NSCoding method to encode and decode objects |
193 |
* to encode and decode objects |
*/ |
|
*/ |
|
194 |
- (void)encodeWithCoder: (NSCoder *)encoder |
- (void)encodeWithCoder: (NSCoder *)encoder |
195 |
{ |
{ |
196 |
[encoder encodeValueOfObjCType: "I" at: &_identifier]; |
[encoder encodeValueOfObjCType: "I" at: &_identifier]; |
203 |
{ |
{ |
204 |
[decoder decodeValueOfObjCType: "I" at: &_identifier]; |
[decoder decodeValueOfObjCType: "I" at: &_identifier]; |
205 |
NSNumber *numIdent = [NSNumber numberWithInt: _identifier]; |
NSNumber *numIdent = [NSNumber numberWithInt: _identifier]; |
206 |
|
|
207 |
//HgGame *current = [HgGame currentGame]; |
HgGame *currentGame = [HgGame currentGame]; |
208 |
HgObject *object = [[_game objects] objectForKey: numIdent]; |
HgObject *object = [[currentGame objects] objectForKey: numIdent]; |
209 |
|
|
210 |
if (object != nil) |
if (object != nil) |
211 |
{ |
{ |
212 |
DESTROY(self); |
DESTROY(self); |