Exemplo n.º 1
0
bool NexusZone::collide(BfObject *hitObject)
{
    if(isGhost())
        return false;

    // From here on out, runs on server only

    if( ! (isShipType(hitObject->getObjectTypeNumber())) )
        return false;

    Ship *theShip = static_cast<Ship *>(hitObject);

    if(theShip->mHasExploded)                             // Ignore collisions with exploded ships
        return false;

    GameType *gameType = getGame()->getGameType();
    NexusGameType *nexusGameType = NULL;

    if(gameType && gameType->getGameTypeId() == NexusGame)
        nexusGameType = static_cast<NexusGameType *>(getGame()->getGameType());

    if(nexusGameType && nexusGameType->isNexusOpen())      // Is the nexus open?
        nexusGameType->shipTouchNexus(theShip, this);

    return false;
}
Exemplo n.º 2
0
/**
 * @luafunc int LuaGameInfo::getNexusTimeLeft()
 *
 * @brief The number of seconds until the nexus opens or closes.
 *
 * @return The number of seconds until the Nexus opens or closes, or nil if this
 * is not a nexus game.  If this function returns 0, the Nexus will remain in its 
 * current state until the end of the game
 */
S32 LuaGameInfo::lua_getNexusTimeLeft(lua_State *L)
{
   GameType *gameType = mServerGame->getGameType();
   if(!gameType || gameType->getGameTypeId() != NexusGame)
      return returnNil(L);

   return returnInt(L, static_cast<NexusGameType *>(gameType)->getNexusTimeLeftMs() / 1000);
}
Exemplo n.º 3
0
/**
 * @luafunc bool LuaGameInfo::isNexusOpen()
 *
 * @brief Get whether the nexus is open
 *
 * @return `true` if the Nexus is open during a Nexus game.
 */
S32 LuaGameInfo::lua_isNexusOpen(lua_State *L)
{
   GameType *gameType = mServerGame->getGameType();
   if(!gameType || gameType->getGameTypeId() != NexusGame)
      return returnNil(L);

   return returnBool(L, static_cast<NexusGameType *>(gameType)->isNexusOpen());
}
Exemplo n.º 4
0
/**
 * @luafunc bool NexusZone::isOpen()
 *
 * @return The current state of the Nexus. `true` for open, `false` for closed.
 *
 * @note Since all Nexus items open and close together, this method will return
 * the same value for all Nexus zones in a game at any given time.
 */
S32 NexusZone::lua_isOpen(lua_State *L)
{
    if(!mGame)
        return returnBool(L, false);

    GameType *gameType = mGame->getGameType();

    if(gameType->getGameTypeId() == NexusGame)
        return returnBool(L, static_cast<NexusGameType *>(gameType)->isNexusOpen());
    else
        return returnBool(L, false);     // If not a Nexus game, Nexus will never be open
}
Exemplo n.º 5
0
void NexusZone::onAddedToGame(Game *theGame)
{
    Parent::onAddedToGame(theGame);

    if(!isGhost())
        setScopeAlways();    // Always visible!

    GameType *gameType = getGame()->getGameType();

    if(gameType && gameType->getGameTypeId() == NexusGame)
        static_cast<NexusGameType *>(gameType)->addNexus(this);
}
Exemplo n.º 6
0
void NexusZone::render() const
{
#ifndef ZAP_DEDICATED
    GameType *gameType = getGame() ? getGame()->getGameType() : NULL;
    NexusGameType *nexusGameType = NULL;

    if(gameType && gameType->getGameTypeId() == NexusGame)
        nexusGameType = static_cast<NexusGameType *>(gameType);

    bool isOpen = nexusGameType && nexusGameType->isNexusOpen();
    F32 glowFraction = gameType ? gameType->mZoneGlowTimer.getFraction() : 0;

    GameObjectRender::renderNexus(getOutline(), getFill(), getCentroid(), getLabelAngle(), isOpen, glowFraction);
#endif
}
Exemplo n.º 7
0
/**
 * @luafunc NexusZone::setClosedTime(int seconds)
 *
 * @brief Set the time (in seconds) that the Nexus will remain closed.
 *
 * @descr Pass 0 if the Nexus should never open, causing the Nexus to remain
 * closed permanently. Passing a negative time will generate an error.
 *
 * @param seconds Time in seconds that the Nexus should remain closed.
 *
 * @note Since all Nexus items open and close together, this method will affect
 * all Nexus items in a game.
 *
 * Also note that in a level file, closing times are specified in fractions of
 * minutes, whereas this method works with seconds.
 */
S32 NexusZone::lua_setClosedTime(lua_State *L)
{
    checkArgList(L, functionArgs, "NexusZone", "setCloseTime");

    if(!mGame)
        return 0;

    GameType *gameType = mGame->getGameType();

    if(gameType->getGameTypeId() != NexusGame)       // Do nothing if this is not a Nexus game
        return 0;

    static_cast<NexusGameType *>(gameType)->setNewClosedTime(getInt(L, 1));

    return 0;
}