Dock.isQueued(ship) function
This commit is contained in:
parent
540632aa52
commit
0c8f228758
@ -629,6 +629,11 @@ MA 02110-1301, USA.
|
|||||||
{
|
{
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
// player docking manually
|
||||||
|
if ([ship isPlayer] && [[self owner] playerReservedDock] == self)
|
||||||
|
{
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,9 @@ MA 02110-1301, USA.
|
|||||||
static JSObject *sDockPrototype;
|
static JSObject *sDockPrototype;
|
||||||
|
|
||||||
static BOOL JSDockGetDockEntity(JSContext *context, JSObject *stationObj, DockEntity **outEntity);
|
static BOOL JSDockGetDockEntity(JSContext *context, JSObject *stationObj, DockEntity **outEntity);
|
||||||
|
static BOOL JSDockGetShipEntity(JSContext *context, JSObject *shipObj, ShipEntity **outEntity);
|
||||||
|
|
||||||
|
static JSBool DockIsQueued(JSContext *context, uintN argc, jsval *vp);
|
||||||
|
|
||||||
|
|
||||||
static JSBool DockGetProperty(JSContext *context, JSObject *this, jsid propID, jsval *value);
|
static JSBool DockGetProperty(JSContext *context, JSObject *this, jsid propID, jsval *value);
|
||||||
@ -83,6 +86,7 @@ static JSPropertySpec sDockProperties[] =
|
|||||||
static JSFunctionSpec sDockMethods[] =
|
static JSFunctionSpec sDockMethods[] =
|
||||||
{
|
{
|
||||||
// JS name Function min args
|
// JS name Function min args
|
||||||
|
{ "isQueued", DockIsQueued, 1 },
|
||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -117,6 +121,28 @@ static BOOL JSDockGetDockEntity(JSContext *context, JSObject *dockObj, DockEntit
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static BOOL JSDockGetShipEntity(JSContext *context, JSObject *shipObj, ShipEntity **outEntity)
|
||||||
|
{
|
||||||
|
OOJS_PROFILE_ENTER
|
||||||
|
|
||||||
|
BOOL result;
|
||||||
|
Entity *entity = nil;
|
||||||
|
|
||||||
|
if (outEntity == NULL) return NO;
|
||||||
|
*outEntity = nil;
|
||||||
|
|
||||||
|
result = OOJSEntityGetEntity(context, shipObj, &entity);
|
||||||
|
if (!result) return NO;
|
||||||
|
|
||||||
|
if (![entity isKindOfClass:[ShipEntity class]]) return NO;
|
||||||
|
|
||||||
|
*outEntity = (ShipEntity *)entity;
|
||||||
|
return YES;
|
||||||
|
|
||||||
|
OOJS_PROFILE_EXIT
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@implementation DockEntity (OOJavaScriptExtensions)
|
@implementation DockEntity (OOJavaScriptExtensions)
|
||||||
|
|
||||||
- (void)getJSClass:(JSClass **)outClass andPrototype:(JSObject **)outPrototype
|
- (void)getJSClass:(JSClass **)outClass andPrototype:(JSObject **)outPrototype
|
||||||
@ -227,3 +253,28 @@ static JSBool DockSetProperty(JSContext *context, JSObject *this, jsid propID, J
|
|||||||
|
|
||||||
// *** Methods ***
|
// *** Methods ***
|
||||||
|
|
||||||
|
static JSBool DockIsQueued(JSContext *context, uintN argc, jsval *vp)
|
||||||
|
{
|
||||||
|
OOJS_NATIVE_ENTER(context)
|
||||||
|
|
||||||
|
BOOL result = NO;
|
||||||
|
DockEntity *dock = nil;
|
||||||
|
|
||||||
|
JSDockGetDockEntity(context, OOJS_THIS, &dock);
|
||||||
|
if (argc == 0)
|
||||||
|
{
|
||||||
|
OOJSReportBadArguments(context, @"Dock", @"isQueued", MIN(argc, 1U), OOJS_ARGV, nil, @"ship");
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
ShipEntity *ship = nil;
|
||||||
|
JSDockGetShipEntity(context, JSVAL_TO_OBJECT(OOJS_ARGV[0]), &ship);
|
||||||
|
if (ship != nil)
|
||||||
|
{
|
||||||
|
result = [dock shipIsInDockingQueue:ship];
|
||||||
|
}
|
||||||
|
|
||||||
|
OOJS_RETURN_BOOL(result);
|
||||||
|
|
||||||
|
OOJS_NATIVE_EXIT
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user