103 lines
2.6 KiB
C
103 lines
2.6 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 <stdio.h>
|
|
/*
|
|
#include "server.H"
|
|
#include "chest.H"
|
|
#include "actionopen.H"
|
|
#include "actionclose.H"
|
|
|
|
CChest::CChest():CSrvObject(){
|
|
|
|
setName("Chest");
|
|
|
|
state = CHESTSTATE_OPENED;
|
|
doorAngle = 45;
|
|
|
|
CGeometryObject * geometry = new CGeometryObject("Chest",7);
|
|
geometry->setBBox( new CBBox(-0.25,0.4,0,0.25,-0.4,0.5) );
|
|
|
|
doorGeometry = new CGeometryObject("Chest door",8);
|
|
doorGeometry->setPosition( CPosition(-0.25,0,0.5) );
|
|
doorGeometry->setDirection( CDirection(0,-doorAngle,0) );
|
|
doorGeometry->setBBox( new CBBox(0.0,0.4,0,0.5,-0.4,0.5) );
|
|
|
|
geometry->addGeometryObject( doorGeometry );
|
|
|
|
setGeometry(geometry);
|
|
|
|
addAction( new CActionOpen(this) );
|
|
addAction( new CActionClose(this) );
|
|
|
|
}
|
|
|
|
int CChest::open(){
|
|
if (state == CHESTSTATE_CLOSED) {
|
|
printf("Chest: open!\n");
|
|
state = CHESTSTATE_OPEN;
|
|
} else return FALSE;
|
|
return TRUE;
|
|
}
|
|
|
|
int CChest::close(){
|
|
if (state == CHESTSTATE_OPENED) {
|
|
printf("Chest: close!\n");
|
|
state = CHESTSTATE_CLOSE;
|
|
} else return FALSE;
|
|
return TRUE;
|
|
}
|
|
|
|
void CChest::animate( double time ){
|
|
// printf("Chest: animate( %f )\n",time );
|
|
switch (state) {
|
|
case CHESTSTATE_OPENED:
|
|
case CHESTSTATE_CLOSED:
|
|
return ;
|
|
break;
|
|
case CHESTSTATE_OPEN:
|
|
doorAngle += CHESTANGLE_SPEED*time;
|
|
if (doorAngle > 45.0){
|
|
doorAngle = 45.0;
|
|
state = CHESTSTATE_OPENED;
|
|
doorOpened();
|
|
}
|
|
doorGeometry->updateDirection( CDirection(0,-doorAngle,0) );
|
|
break;
|
|
case CHESTSTATE_CLOSE:
|
|
doorAngle -= CHESTANGLE_SPEED*time;
|
|
if (doorAngle < 0.0){
|
|
doorAngle = 0.0;
|
|
state = CHESTSTATE_CLOSED;
|
|
doorClosed();
|
|
}
|
|
doorGeometry->updateDirection( CDirection(0,-doorAngle,0) );
|
|
break;
|
|
}
|
|
}
|
|
|
|
void CChest::doorOpened(){
|
|
printf("Chest: doorOpened!\n");
|
|
}
|
|
|
|
void CChest::doorClosed(){
|
|
printf("Chest: doorClosed!\n");
|
|
}
|
|
*/
|