/* WARNING: exposed to plugin through SFLPluginAPI */ int32_t PluginManager::registerObject_(const int8_t* type, const SFLPluginRegisterParams* params) { if (!isValidObject(type, params)) return -1; SFLPluginVersion pm_version = pluginApi_.version; // Strict compatibility on ABI if (pm_version.abi != params->version.abi) return -1; // Backware compatibility on API if (pm_version.api > params->version.api) return -1; std::string key((const char *)type); // wild card registration? if (key == std::string("*")) { wildCardVec_.push_back(*params); return 0; } // fails on duplicate for exactMatch map if (exactMatchMap_.find(key) != exactMatchMap_.end()) return -1; exactMatchMap_[key] = *params; return 0; }
void MultiHideObject(OBJECT *pMultiObj) { // validate object pointer assert(isValidObject(pMultiObj)); // set master shape to null animation frame pMultiObj->hShape = 0; // change all objects MultiReshape(pMultiObj); }
//----------------------------------------------------------------------------- // // VActorPhysicsController::getWaterObject(); // // Get the current Water Object the Actor is in. // //----------------------------------------------------------------------------- WaterObject *VActorPhysicsController::getWaterObject( void ) { // Valid Object? if ( !isValidObject() ) { // No. return NULL; } return mObject->getCurrentWaterObject(); }
//----------------------------------------------------------------------------- // // VActorPhysicsController::getPathObject(); // // Get the Path Object the Actor is mounted to. // //----------------------------------------------------------------------------- VPath *VActorPhysicsController::getPathObject( void ) { // Valid Object? if ( !isValidObject() ) { // No. return NULL; } return mMountedPath; }
/** * Returns the x,y position of an objects animation point. * @param pObj Pointer to object * @param pPosX Gets set to objects X animation position * @param pPosY Gets set to objects Y animation position */ void GetAniPosition(OBJECT *pObj, int *pPosX, int *pPosY) { // validate object pointer assert(isValidObject(pObj)); // get the animation offset of the object GetAniOffset(pObj->hImg, pObj->flags, pPosX, pPosY); // from animation offset and objects position - determine objects animation point *pPosX += fracToInt(pObj->xPos); *pPosY += fracToInt(pObj->yPos); }
//----------------------------------------------------------------------------- // // VActorPhysicsController::isPathing(); // // Is the Actor Pathing? // //----------------------------------------------------------------------------- const bool VActorPhysicsController::isPathing( void ) { // Valid Object? if ( !isValidObject() ) { // No. return false; } return ( mMountedPath != NULL ); }
//----------------------------------------------------------------------------- // // VActorPhysicsController::getTransform(); // // Get the Actor's Transform. // //----------------------------------------------------------------------------- MatrixF VActorPhysicsController::getTransform( void ) { // Valid Object? if ( !isValidObject() ) { // No. return MatrixF::Identity; } // Return Transform. return mObject->getTransform(); }
//----------------------------------------------------------------------------- // // VActorPhysicsController::getPosition(); // // Get the Actor's Position. // //----------------------------------------------------------------------------- Point3F VActorPhysicsController::getPosition( void ) { // Valid Object? if ( !isValidObject() ) { // No. return Point3F::Zero; } // Return Position. return mObject->getPosition(); }
//----------------------------------------------------------------------------- // // VActorPhysicsController::setPosition( pPosition ); // // Set the Actor's Position. // //----------------------------------------------------------------------------- void VActorPhysicsController::setPosition( const Point3F &pPosition ) { // Valid Object? if ( !isValidObject() ) { // No. return; } // Apply Position. mObject->setPosition( pPosition ); }
//----------------------------------------------------------------------------- // // VActorPhysicsController::getVelocity(); // // Get the Actor's Velocity. // //----------------------------------------------------------------------------- VectorF VActorPhysicsController::getVelocity( void ) { // Valid Object? if ( !isValidObject() ) { // No. return VectorF::Zero; } // Return Velocity. return mVelocity; }
//----------------------------------------------------------------------------- // // VActorPhysicsController::setTransform( pTransform ); // // Set the Actor's Transform. // //----------------------------------------------------------------------------- void VActorPhysicsController::setTransform( const MatrixF &pTransform ) { // Valid Object? if ( !isValidObject() ) { // No. return; } // Apply Transform. mObject->setTransform( pTransform ); }
//----------------------------------------------------------------------------- // // VActorPhysicsController::isInWater(); // // Is the Actor in the Water? // //----------------------------------------------------------------------------- const bool VActorPhysicsController::isInWater( void ) { // Valid Objects? if ( !isValidObject() || !getWaterObject() ) { // No. return false; } // Submerged? return ( ( mObject->getWaterCoverage() + POINT_EPSILON ) >= mObject->getDataBlock()->getSumbergeCoverage() ); }
//----------------------------------------------------------------------------- // // VActorPhysicsController::isOnGround(); // // Is the Actor On the Ground? // //----------------------------------------------------------------------------- const bool VActorPhysicsController::isOnGround( void ) { // Valid Objects? if ( !isValidObject() ) { // No. return false; } // On Ground? return ( mOnGround && mGroundObject && !isInWater() ); }
//----------------------------------------------------------------------------- // // VActorPhysicsController::isInAir(); // // Is the Actor in the Air? // //----------------------------------------------------------------------------- const bool VActorPhysicsController::isInAir( void ) { // Valid Objects? if ( !isValidObject() ) { // No. return false; } // In Air? return ( !isOnGround() && !isInWater() ); }
void MultiForceRedraw(POBJECT pMultiObj) { // validate object pointer assert(isValidObject(pMultiObj)); // for all the objects that make up this multi-part do { // signal a change in the object pMultiObj->flags |= DMA_CHANGED; // next obj in list pMultiObj = pMultiObj->pSlave; } while (pMultiObj != NULL); }
void MultiInsertObject(OBJECT **pObjList, OBJECT *pInsObj) { // validate object pointer assert(isValidObject(pInsObj)); // for all the objects that make up this multi-part do { // add next part to the specified list InsertObject(pObjList, pInsObj); // next obj in list pInsObj = pInsObj->pSlave; } while (pInsObj != NULL); }
void MultiReshape(OBJECT *pMultiObj) { SCNHANDLE hFrame; // validate object pointer assert(isValidObject(pMultiObj)); // get objects current anim frame hFrame = pMultiObj->hShape; if (hFrame != 0 && hFrame != pMultiObj->hMirror) { // a valid shape frame which is different from previous // get pointer to frame const FRAME *pFrame = (const FRAME *)LockMem(hFrame); // update previous pMultiObj->hMirror = hFrame; while (READ_LE_UINT32(pFrame) != 0 && pMultiObj != NULL) { // a normal image - update the current object with this image AnimateObject(pMultiObj, READ_LE_UINT32(pFrame)); // move to next image for this frame pFrame++; // move to next part of object pMultiObj = pMultiObj->pSlave; } // null the remaining object parts while (pMultiObj != NULL) { // set a null image for this object part AnimateObject(pMultiObj, 0); // move to next part of object pMultiObj = pMultiObj->pSlave; } } else if (hFrame == 0) { // update previous pMultiObj->hMirror = hFrame; // null all the object parts while (pMultiObj != NULL) { // set a null image for this object part AnimateObject(pMultiObj, 0); // move to next part of object pMultiObj = pMultiObj->pSlave; } } }
void MultiHorizontalFlip(OBJECT *pFlipObj) { // validate object pointer assert(isValidObject(pFlipObj)); // for all the objects that make up this multi-part do { // horizontally flip the next part AnimateObjectFlags(pFlipObj, pFlipObj->flags ^ DMA_FLIPH, pFlipObj->hImg); // next obj in list pFlipObj = pFlipObj->pSlave; } while (pFlipObj != NULL); }
void MultiDeleteObject(OBJECT **pObjList, OBJECT *pMultiObj) { // validate object pointer assert(isValidObject(pMultiObj)); // for all the objects that make up this multi-part do { // delete object DelObject(pObjList, pMultiObj); // next obj in list pMultiObj = pMultiObj->pSlave; } while (pMultiObj != NULL); }
void MultiSetAniY(OBJECT *pMultiObj, int newAniY) { int curAniX, curAniY; // objects current animation position // validate object pointer assert(isValidObject(pMultiObj)); // get master objects current animation position GetAniPosition(pMultiObj, &curAniX, &curAniY); // calc y difference between current and new positions curAniX = 0; newAniY -= curAniY; // move all pieces by the difference MultiMoveRelXY(pMultiObj, curAniX, newAniY); }
/** * Give a object a new image and new orientation flags. * @param pAniObj Object to be updated * @param newflags Objects new flags * @param hNewImg Objects new image */ void AnimateObjectFlags(OBJECT *pAniObj, int newflags, SCNHANDLE hNewImg) { // validate object pointer assert(isValidObject(pAniObj)); if (pAniObj->hImg != hNewImg || (pAniObj->flags & DMA_HARDFLAGS) != (newflags & DMA_HARDFLAGS)) { // something has changed int oldAniX, oldAniY; // objects old animation offsets int newAniX, newAniY; // objects new animation offsets // get objects old animation offsets GetAniOffset(pAniObj->hImg, pAniObj->flags, &oldAniX, &oldAniY); // get objects new animation offsets GetAniOffset(hNewImg, newflags, &newAniX, &newAniY); if (hNewImg) { // get pointer to image const IMAGE *pNewImg = (IMAGE *)LockMem(hNewImg); // setup new shape pAniObj->width = FROM_LE_16(pNewImg->imgWidth); pAniObj->height = FROM_LE_16(pNewImg->imgHeight) & ~C16_FLAG_MASK; newflags &= ~C16_FLAG_MASK; newflags |= FROM_LE_16(pNewImg->imgHeight) & C16_FLAG_MASK; // set objects bitmap definition pAniObj->hBits = FROM_LE_32(pNewImg->hImgBits); } else { // null image pAniObj->width = 0; pAniObj->height = 0; pAniObj->hBits = 0; } // set objects flags and signal a change pAniObj->flags = newflags | DMA_CHANGED; // set objects image pAniObj->hImg = hNewImg; // adjust objects position - subtract new from old for difference pAniObj->xPos += intToFrac(oldAniX - newAniX); pAniObj->yPos += intToFrac(oldAniY - newAniY); } }
void MultiSetZPosition(OBJECT *pMultiObj, int newZ) { // validate object pointer assert(isValidObject(pMultiObj)); // for all the objects that make up this multi-part do { // signal a change in the object pMultiObj->flags |= DMA_CHANGED; // set the new z position pMultiObj->zPos = newZ; // next obj in list pMultiObj = pMultiObj->pSlave; } while (pMultiObj != NULL); }
/** * Deletes an object from the specified object list and places it * on the free list. * @param pObjList List to delete object from * @param pDelObj Object to delete */ void DelObject(OBJECT *pObjList, OBJECT *pDelObj) { OBJECT *pPrev, *pObj; // object list traversal pointers const Common::Rect rcScreen(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); // validate object pointer assert(isValidObject(pDelObj)); #ifdef DEBUG // one less object in use --numObj; assert(numObj >= 0); #endif for (pPrev = pObjList, pObj = pObjList->pNext; pObj != NULL; pPrev = pObj, pObj = pObj->pNext) { if (pObj == pDelObj) { // found object to delete if (IntersectRectangle(pDelObj->rcPrev, pDelObj->rcPrev, rcScreen)) { // allocate a clipping rect for objects previous pos AddClipRect(pDelObj->rcPrev); } // make PREV next = OBJ next - removes OBJ from list pPrev->pNext = pObj->pNext; // place free list in OBJ next pObj->pNext = pFreeObjects; // add OBJ to top of free list pFreeObjects = pObj; // delete objects palette if (pObj->pPal) FreePalette(pObj->pPal); // quit return; } } // if we get to here - object has not been found on the list // This can be triggered in Act 3 in DW1 while talking to the guard, // so this has been turned to a warning instead of an error warning("DelObject(): formally 'assert(0)!'"); }
//----------------------------------------------------------------------------- // // VActorPhysicsController::update( pDelta, pMove ); // // ... // //----------------------------------------------------------------------------- void VActorPhysicsController::update( const F32 &pDelta, const Move *pMove ) { // Valid Objects? if ( !isValidObject() ) { // No, Quit Now. return; } // Pre-tick Update. preTickUpdate( pDelta ); // Integrate Tick Update. integrateTickUpdate( pDelta, pMove ); // Post-tick Update. postTickUpdate( pDelta ); }
void MultiMoveRelXY(OBJECT *pMultiObj, int deltaX, int deltaY) { // validate object pointer assert(isValidObject(pMultiObj)); if (deltaX == 0 && deltaY == 0) return; // ignore no change // for all the objects that make up this multi-part do { // signal a change in the object pMultiObj->flags |= DMA_CHANGED; // adjust the x position pMultiObj->xPos += intToFrac(deltaX); // adjust the y position pMultiObj->yPos += intToFrac(deltaY); // next obj in list pMultiObj = pMultiObj->pSlave; } while (pMultiObj != NULL); }
int MultiLeftmost(OBJECT *pMulti) { int left; // validate object pointer assert(isValidObject(pMulti)); // init leftmost point to first object left = fracToInt(pMulti->xPos); // for all the objects in this multi while ((pMulti = pMulti->pSlave) != NULL) { if (pMulti->hImg != 0) { // non null object part if (fracToInt(pMulti->xPos) < left) // this object is further left left = fracToInt(pMulti->xPos); } } // return left-most point return left; }
int MultiRightmost(OBJECT *pMulti) { int right; // validate object pointer assert(isValidObject(pMulti)); // init right-most point to first object right = fracToInt(pMulti->xPos) + pMulti->width; // for all the objects in this multi while ((pMulti = pMulti->pSlave) != NULL) { if (pMulti->hImg != 0) { // non null object part if (fracToInt(pMulti->xPos) + pMulti->width > right) // this object is further right right = fracToInt(pMulti->xPos) + pMulti->width; } } // return right-most point return right - 1; }
int MultiHighest(OBJECT *pMulti) { int highest; // validate object pointer assert(isValidObject(pMulti)); // init highest point to first object highest = fracToInt(pMulti->yPos); // for all the objects in this multi while ((pMulti = pMulti->pSlave) != NULL) { if (pMulti->hImg != 0) { // non null object part if (fracToInt(pMulti->yPos) < highest) // this object is higher highest = fracToInt(pMulti->yPos); } } // return highest point return highest; }
int MultiLowest(OBJECT *pMulti) { int lowest; // validate object pointer assert(isValidObject(pMulti)); // init lowest point to first object lowest = fracToInt(pMulti->yPos) + pMulti->height; // for all the objects in this multi while ((pMulti = pMulti->pSlave) != NULL) { if (pMulti->hImg != 0) { // non null object part if (fracToInt(pMulti->yPos) + pMulti->height > lowest) // this object is lower lowest = fracToInt(pMulti->yPos) + pMulti->height; } } // return lowest point return lowest - 1; }
//----------------------------------------------------------------------------- // // VActorPhysicsController::initPhysicsTable(); // // Register the available physics states which this controller may utilize. // //----------------------------------------------------------------------------- bool VActorPhysicsController::initPhysicsTable( void ) { // Valid Object? if ( !isValidObject() ) { // No, Quit Now. return false; } // Clear the Table. mPhysicsStateTable.clear(); // Fetch Sequence List. VActorData::tPhysicsStateVector *stateList = getObjectDataBlock()->getPhysicsStateList(); // Initialise the Physics States. for ( VActorData::tPhysicsStateVector::iterator itr = stateList->begin(); itr != stateList->end(); itr++ ) { // Fetch Sequence Definition. const VActorData::sPhysicsState &physState = ( *itr ); // Valid State? if ( physState.State ) { // Register State. mPhysicsStateTable.registerState( physState.State, physState.Priority ); } } // Sort the Table. mPhysicsStateTable.sort(); // Valid. return true; }