Oolite 1.91.0.7604-240417-a536cbe
Loading...
Searching...
No Matches
ProxyPlayerEntity.m
Go to the documentation of this file.
1/*
2
3ProxyPlayerEntity.m
4
5
6Oolite
7Copyright (C) 2004-2013 Giles C Williams and contributors
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22MA 02110-1301, USA.
23
24*/
25
26#import "ProxyPlayerEntity.h"
27
28
29@implementation ProxyPlayerEntity
30
31- (id)initWithKey:(NSString *)key definition:(NSDictionary *)dict
32{
33 self = [super initWithKey:key definition:dict];
34 if (self != nil)
35 {
36 [self setDialForwardShield:1.0f];
37 [self setDialAftShield:1.0f];
38 [self setDialFuelScoopStatus:[self hasScoop] ? SCOOP_STATUS_OKAY : SCOOP_STATUS_NOT_INSTALLED];
39 [self setCompassMode:[self hasEquipmentItemProviding:@"EQ_ADVANCED_COMPASS"] ? COMPASS_MODE_PLANET : COMPASS_MODE_BASIC];
40 [self setTradeInFactor:95];
41 }
42
43 return self;
44}
45
46
47- (void) copyValuesFromPlayer:(PlayerEntity *)player
48{
49 if (player == nil) return;
50
51 [self setFuelLeakRate:[player fuelLeakRate]];
52 [self setMassLocked:[player massLocked]];
53 [self setAtHyperspeed:[player atHyperspeed]];
54 [self setDialForwardShield:[player dialForwardShield]];
55 [self setDialAftShield:[player dialAftShield]];
56 [self setDialMissileStatus:[player dialMissileStatus]];
57 [self setDialFuelScoopStatus:[player dialFuelScoopStatus]];
58 [self setCompassMode:[player compassMode]];
59 [self setDialIdentEngaged:[player dialIdentEngaged]];
60 [self setAlertCondition:[player alertCondition]];
61 [self setTrumbleCount:[player trumbleCount]];
62 [self setTradeInFactor:[player tradeInFactor]];
63
64}
65
66
67- (BOOL) isPlayerLikeShip
68{
69 return YES;
70}
71
72
73- (float) fuelLeakRate
74{
75 return _fuelLeakRate;
76}
77
78- (void) setFuelLeakRate:(float)value
79{
80 _fuelLeakRate = fmax(value, 0.0f);
81}
82
83
84- (BOOL) massLocked
85{
86 return _massLocked;
87}
88
89- (void) setMassLocked:(BOOL)value
90{
91 _massLocked = !!value;
92}
93
94
95- (BOOL) atHyperspeed
96{
97 return _atHyperspeed;
98}
99
100- (void) setAtHyperspeed:(BOOL)value
101{
102 _atHyperspeed = !!value;
103}
104
105
106- (GLfloat) dialForwardShield
107{
108 return _dialForwardShield;
109}
110
111- (void) setDialForwardShield:(GLfloat)value
112{
113 _dialForwardShield = value;
114}
115
116
117- (GLfloat) dialAftShield
118{
119 return _dialAftShield;
120}
121
122- (void) setDialAftShield:(GLfloat)value
123{
124 _dialAftShield = value;
125}
126
127
129{
130 return _missileStatus;
131}
132
133- (void) setDialMissileStatus:(OOMissileStatus)value
134{
135 _missileStatus = value;
136}
137
138
140{
141 return _fuelScoopStatus;
142}
143
144- (void) setDialFuelScoopStatus:(OOFuelScoopStatus)value
145{
146 _fuelScoopStatus = value;
147}
148
149
151{
152 return _compassMode;
153}
154
155- (void) setCompassMode:(OOCompassMode)value
156{
157 _compassMode = value;
158}
159
160
161- (BOOL) dialIdentEngaged
162{
163 return _dialIdentEngaged;
164}
165
166- (void) setDialIdentEngaged:(BOOL)value
167{
168 _dialIdentEngaged = !!value;
169}
170
171
173{
174 return _alertCondition;
175}
176
177- (void) setAlertCondition:(OOAlertCondition)value
178{
179 _alertCondition = value;
180}
181
182
183- (NSUInteger) trumbleCount
184{
185 return _trumbleCount;
186}
187
188
189- (void) setTrumbleCount:(NSUInteger)value
190{
191 _trumbleCount = value;
192}
193
194
195- (void) setTradeInFactor:(int)tif
196{
197 _tradeInFactor = tif;
198}
199
200
202{
203 return _tradeInFactor;
204}
205
206
207
208// If you're here to add more properties, don't forget to update -copyValuesFromPlayer:.
209
210@end
211
212
213@implementation Entity (ProxyPlayer)
214
215- (BOOL) isPlayerLikeShip
216{
217 return NO;
218}
219
220@end
221
222
223@implementation PlayerEntity (ProxyPlayer)
224
225- (BOOL) isPlayerLikeShip
226{
227 return YES;
228}
229
230@end
return nil
OOCompassMode
Definition OOTypes.h:145
OOFuelScoopStatus
OOMissileStatus
OOAlertCondition
Definition ShipEntity.h:172
BOOL dialIdentEngaged()
NSUInteger trumbleCount
GLfloat dialAftShield()
OOFuelScoopStatus dialFuelScoopStatus()
GLfloat dialForwardShield()
OOMissileStatus dialMissileStatus()
OOAlertCondition alertCondition
OOCompassMode compassMode
void setDialForwardShield:(GLfloat value)
OOFuelScoopStatus dialFuelScoopStatus()
OOAlertCondition alertCondition()
OOCompassMode _compassMode
OOFuelScoopStatus _fuelScoopStatus
void setTradeInFactor:(int tif)
OOAlertCondition _alertCondition
OOMissileStatus _missileStatus
OOMissileStatus dialMissileStatus()
OOCompassMode compassMode()
void setDialAftShield:(GLfloat value)
BOOL hasScoop()
id initWithKey:definition:(NSString *key,[definition] NSDictionary *dict)
Definition ShipEntity.m:193
BOOL hasEquipmentItemProviding:(NSString *equipmentType)
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque