139 lines
3.3 KiB
C
139 lines
3.3 KiB
C
/*
|
|
* PVVMUD a 3D MUD
|
|
* Copyright (C) 1998-1999 Programvareverkstedet (pvv@pvv.org)
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
*
|
|
*/
|
|
#include "pvvmud.H"
|
|
#include "worldanimation.H"
|
|
#include "worldworld.H"
|
|
#include "worldobject.H"
|
|
|
|
CWorldAnimationList::CWorldAnimationList(){
|
|
m_lastTime = 0;
|
|
}
|
|
|
|
void CWorldAnimationList::add( CWorldAnimation * animation , DWORD time ){
|
|
|
|
DWORD deltaTime;
|
|
|
|
if (m_lastTime == 0)
|
|
deltaTime = 0;
|
|
else
|
|
deltaTime = time - m_lastTime;
|
|
|
|
if (animation->animate( time, deltaTime )){
|
|
addLast( (CObject*)animation );
|
|
} else {
|
|
delete animation;
|
|
}
|
|
}
|
|
|
|
void CWorldAnimationList::animate( DWORD time ){
|
|
CObjectListItem * item = getFirst();
|
|
while (item != NULL){
|
|
CWorldAnimation * animation = (CWorldAnimation*)item->getObject();
|
|
item = item->getNext();
|
|
|
|
// if (time >= animation->getStartTime()){
|
|
// if (time >= animation->getStopTime()) {
|
|
// remove( animation );
|
|
// } else {
|
|
|
|
|
|
DWORD deltaTime;
|
|
|
|
if (m_lastTime == 0)
|
|
deltaTime = 0;
|
|
else
|
|
deltaTime = time - m_lastTime;
|
|
|
|
m_lastTime = time;
|
|
|
|
if (!animation->animate( time, deltaTime )){
|
|
remove( animation );
|
|
delete animation;
|
|
}
|
|
|
|
// }
|
|
// }
|
|
|
|
}
|
|
}
|
|
|
|
void CWorldAnimationList::clearList(){
|
|
deleteAll();
|
|
}
|
|
|
|
void CWorldAnimationList::sendObjectAnimation( DWORD objectId,
|
|
CListener * listener)
|
|
{
|
|
CObjectListItem * item = getFirst();
|
|
while (item != NULL){
|
|
CWorldAnimation * animation = (CWorldAnimation*)item->getObject();
|
|
item = item->getNext();
|
|
|
|
if (animation->getObjectId() == objectId){
|
|
listener->sendAnimation( animation );
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
CWorldAnimation::CWorldAnimation(DWORD objectId){
|
|
m_world = NULL;
|
|
m_startTime = m_stopTime = 0;
|
|
m_objectId = objectId;
|
|
}
|
|
|
|
CWorldAnimation::~CWorldAnimation(){
|
|
}
|
|
|
|
CWorldWorld * CWorldAnimation::getWorld(){
|
|
return m_world;
|
|
}
|
|
|
|
void CWorldAnimation::setWorld( CWorldWorld * world ){
|
|
m_world = world;
|
|
}
|
|
|
|
DWORD CWorldAnimation::getObjectId(){
|
|
return m_objectId;
|
|
}
|
|
|
|
CWorldObject * CWorldAnimation::getObject(){
|
|
return getWorld()->getObject( m_objectId );
|
|
}
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Function : animate
|
|
// Return : TRUE if more animation to do
|
|
// FALSE if end of animation
|
|
//
|
|
int CWorldAnimation::animate( DWORD time, DWORD deltaTime ){
|
|
return animate( time );
|
|
}
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// Function : animate
|
|
// Return : TRUE if more animation to do
|
|
// FALSE if end of animation
|
|
//
|
|
int CWorldAnimation::animate( DWORD time ){
|
|
return FALSE;
|
|
}
|