half of task compile.

dev-ui
Zaba999 2012-09-11 23:11:34 +02:00
parent e57be247c2
commit 1bb1eb7b87
25 changed files with 697 additions and 903 deletions

View File

@ -124,33 +124,33 @@ graphics/opengl/gldevice.cpp
# object/motion/motiontoto.cpp
# object/motion/motionvehicle.cpp
# object/motion/motionworm.cpp
# object/object.cpp
object/object.cpp
# object/robotmain.cpp
# object/task/task.cpp
# object/task/taskadvance.cpp
# object/task/taskbuild.cpp
# object/task/taskfire.cpp
# object/task/taskfireant.cpp
# object/task/taskflag.cpp
# object/task/taskgoto.cpp
# object/task/taskgungoal.cpp
# object/task/taskinfo.cpp
# object/task/taskmanager.cpp
# object/task/taskmanip.cpp
# object/task/taskpen.cpp
# object/task/taskrecover.cpp
# object/task/taskreset.cpp
# object/task/tasksearch.cpp
# object/task/taskshield.cpp
# object/task/taskspiderexplo.cpp
# object/task/tasktake.cpp
# object/task/taskterraform.cpp
# object/task/taskturn.cpp
# object/task/taskwait.cpp
# physics/physics.cpp
# script/cbottoken.cpp
# script/cmdtoken.cpp
# script/script.cpp
object/task/task.cpp
object/task/taskadvance.cpp
object/task/taskbuild.cpp
object/task/taskfire.cpp
object/task/taskfireant.cpp
object/task/taskflag.cpp
object/task/taskgoto.cpp
object/task/taskgungoal.cpp
object/task/taskinfo.cpp
object/task/taskmanager.cpp
object/task/taskmanip.cpp
object/task/taskpen.cpp
object/task/taskrecover.cpp
object/task/taskreset.cpp
object/task/tasksearch.cpp
object/task/taskshield.cpp
object/task/taskspiderexplo.cpp
object/task/tasktake.cpp
object/task/taskterraform.cpp
object/task/taskturn.cpp
object/task/taskwait.cpp
physics/physics.cpp
script/cbottoken.cpp
script/cmdtoken.cpp
script/script.cpp
# sound/sound.cpp
# ui/button.cpp
# ui/check.cpp

View File

@ -66,6 +66,7 @@ struct Light
float attenuation2;
//! Angle of spotlight cone (0-90 degrees)
float spotAngle;
//! Intensity of spotlight (0 = uniform; 128 = most intense)
float spotIntensity;

View File

@ -28,67 +28,6 @@
#include "object/object.h"
#include "physics/physics.h"
// TODO temporary stubs for CObject and CPhysics
void CObject::SetTransparency(float)
{
}
CObject* CObject::GetFret()
{
return nullptr;
}
CObject* CObject::GetPower()
{
return nullptr;
}
CObject* CObject::GetTruck()
{
return nullptr;
}
ObjectType CObject::GetType()
{
return OBJECT_NULL;
}
void CObject::SetGunGoalH(float)
{
}
void CObject::GetGlobalSphere(Math::Vector &pos, float &radius)
{
}
float CObject::GetAngleY(int)
{
return 0.0f;
}
Math::Vector CObject::GetPosition(int)
{
return Math::Vector();
}
void CObject::SetViewFromHere(Math::Vector &eye, float &dirH, float &dirV,
Math::Vector &lookat, Math::Vector &upVec,
Gfx::CameraType type)
{
}
CPhysics* CObject::GetPhysics()
{
return nullptr;
}
bool CPhysics::GetLand()
{
return false;
}
//! Changes the level of transparency of an object and objects transported (battery & cargo)
void SetTransparency(CObject* obj, float value)
{

View File

@ -16,9 +16,6 @@
// taskadvance.cpp
#include <stdio.h>
#include "object/task/taskadvance.h"
#include "math/geometry.h"
@ -45,13 +42,13 @@ CTaskAdvance::~CTaskAdvance()
bool CTaskAdvance::EventProcess(const Event &event)
{
if ( m_engine->RetPause() ) return true;
if ( event.event != EVENT_FRAME ) return true;
if ( m_engine->GetPause() ) return true;
if ( event.type != EVENT_FRAME ) return true;
m_fixTime += event.rTime;
// Momentarily stationary object (ant on the back)?
if ( m_object->RetFixed() )
if ( m_object->GetFixed() )
{
m_physics->SetMotorSpeedX(0.0f); // stops the advance
m_physics->SetMotorSpeedZ(0.0f); // stops the rotation
@ -70,12 +67,12 @@ Error CTaskAdvance::Start(float length)
{
m_direction = (length>=0.0f)?1.0f:-1.0f;
m_totalLength = fabs(length);
m_advanceLength = m_physics->RetLinLength(length);
m_startPos = m_object->RetPosition(0);
m_advanceLength = m_physics->GetLinLength(length);
m_startPos = m_object->GetPosition(0);
m_lastDist = 0.0f;
m_fixTime = 0.0f;
m_timeLimit = m_physics->RetLinTimeLength(m_totalLength, m_direction)*3.0f;
m_timeLimit = m_physics->GetLinTimeLength(m_totalLength, m_direction)*3.0f;
if ( m_timeLimit < 2.0f ) m_timeLimit = 2.0f;
m_physics->SetMotorSpeedX(m_direction*1.0f); // forward/backward
@ -93,7 +90,7 @@ Error CTaskAdvance::IsEnded()
Math::Vector pos;
float length;
if ( m_engine->RetPause() ) return ERR_CONTINUE;
if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError )
{
@ -106,7 +103,7 @@ Error CTaskAdvance::IsEnded()
return ERR_MOVE_IMPOSSIBLE;
}
pos = m_object->RetPosition(0);
pos = m_object->GetPosition(0);
length = Math::DistanceProjected(pos, m_startPos);
if ( length > m_lastDist ) // forward?

View File

@ -16,15 +16,14 @@
// taskbuild.cpp
#include <stdio.h>
#include "object/task/taskbuild.h"
#include "common/iman.h"
#include "old/light.h"
#include "old/terrain.h"
#include "old/water.h"
#include "graphics/core/color.h"
#include "graphics/core/light.h"
#include "graphics/engine/lightman.h"
#include "graphics/engine/terrain.h"
#include "graphics/engine/water.h"
#include "math/geometry.h"
#include "object/auto/auto.h"
#include "object/motion/motionhuman.h"
@ -32,9 +31,6 @@
#include "physics/physics.h"
#include "ui/displaytext.h"
// Object's constructor.
CTaskBuild::CTaskBuild(CInstanceManager* iMan, CObject* object)
@ -68,7 +64,7 @@ CTaskBuild::~CTaskBuild()
for ( i=0 ; i<TBMAXLIGHT ; i++ )
{
if ( m_lightRank[i] == -1 ) continue;
m_light->DeleteLight(m_lightRank[i]);
m_lightMan->DeleteLight(m_lightRank[i]);
}
}
@ -102,7 +98,7 @@ bool CTaskBuild::CreateBuilding(Math::Vector pos, float angle)
if ( m_type == OBJECT_INFO ) m_buildingHeight = 19.0f;
m_buildingHeight *= 0.25f;
m_buildingPos = m_building->RetPosition(0);
m_buildingPos = m_building->GetPosition(0);
m_buildingPos.y -= m_buildingHeight;
m_building->SetPosition(0, m_buildingPos);
return true;
@ -112,21 +108,21 @@ bool CTaskBuild::CreateBuilding(Math::Vector pos, float angle)
void CTaskBuild::CreateLight()
{
D3DLIGHT7 light;
D3DCOLORVALUE color;
Gfx::Light light;
Gfx::Color color;
Math::Vector center, pos, dir;
Math::Point c, p;
float angle;
int i;
if ( !m_engine->RetLightMode() ) return;
if ( !m_engine->GetLightMode() ) return;
center = m_metal->RetPosition(0);
center = m_metal->GetPosition(0);
angle = 0;
for ( i=0 ; i<TBMAXLIGHT ; i++ )
{
m_lightRank[i] = m_light->CreateLight();
m_lightRank[i] = m_lightMan->CreateLight();
if ( m_lightRank[i] == -1 ) continue;
c.x = center.x;
@ -139,32 +135,32 @@ void CTaskBuild::CreateLight()
pos.y = center.y+40.0f;
dir = center-pos;
ZeroMemory( &light, sizeof(light) );
light.dltType = D3DLIGHT_SPOT;
light.dcvDiffuse.r = 0.0f;
light.dcvDiffuse.g = 0.0f;
light.dcvDiffuse.b = 0.0f; // white (invisible)
light.dvPosition.x = pos.x;
light.dvPosition.y = pos.y;
light.dvPosition.z = pos.z;
light.dvDirection.x = dir.x;
light.dvDirection.y = dir.y;
light.dvDirection.z = dir.z;
light.dvRange = D3DLIGHT_RANGE_MAX;
light.dvFalloff = 1.0f;
light.dvAttenuation0 = 1.0f;
light.dvAttenuation1 = 0.0f;
light.dvAttenuation2 = 0.0f;
light.dvTheta = 0.0f;
light.dvPhi = Math::PI/4.0f;
m_light->SetLight(m_lightRank[i], light);
memset(&light, 0, sizeof(light));
light.type = Gfx::LIGHT_SPOT;
light.diffuse.r = 0.0f;
light.diffuse.g = 0.0f;
light.diffuse.b = 0.0f; // white (invisible)
light.position.x = pos.x;
light.position.y = pos.y;
light.position.z = pos.z;
light.direction.x = dir.x;
light.direction.y = dir.y;
light.direction.z = dir.z;
//TODO Is this value correct
light.spotIntensity = 128;
light.attenuation0 = 1.0f;
light.attenuation1 = 0.0f;
light.attenuation2 = 0.0f;
//TODO Is this value correct
light.spotAngle = 90;
m_lightMan->SetLight(m_lightRank[i], light);
color.r = -1.0f;
color.g = -1.0f;
color.b = -0.5f; // violet
color.a = 0.0f;
m_light->SetLightColor(m_lightRank[i], color);
m_light->SetLightColorSpeed(m_lightRank[i], 1.0f/((1.0f/m_speed)*0.25f));
m_lightMan->SetLightColor(m_lightRank[i], color);
m_lightMan->SetLightColorSpeed(m_lightRank[i], 1.0f/((1.0f/m_speed)*0.25f));
angle += (Math::PI*2.0f)/TBMAXLIGHT;
}
@ -176,7 +172,7 @@ void CTaskBuild::CreateLight()
void CTaskBuild::BlackLight()
{
D3DCOLORVALUE color;
Gfx::Color color;
int i;
for ( i=0 ; i<TBMAXLIGHT ; i++ )
@ -187,8 +183,8 @@ void CTaskBuild::BlackLight()
color.g = 0.0f;
color.b = 0.0f; // white (invisible)
color.a = 0.0f;
m_light->SetLightColor(m_lightRank[i], color);
m_light->SetLightColorSpeed(m_lightRank[i], 1.0f/((1.0f/m_speed)*0.75f));
m_lightMan->SetLightColor(m_lightRank[i], color);
m_lightMan->SetLightColorSpeed(m_lightRank[i], 1.0f/((1.0f/m_speed)*0.75f));
}
m_bBlack = true;
@ -203,8 +199,8 @@ bool CTaskBuild::EventProcess(const Event &event)
Math::Point dim;
float a, g, cirSpeed, dist, linSpeed;
if ( m_engine->RetPause() ) return true;
if ( event.event != EVENT_FRAME ) return true;
if ( m_engine->GetPause() ) return true;
if ( event.type != EVENT_FRAME ) return true;
if ( m_bError ) return false;
m_time += event.rTime;
@ -213,7 +209,7 @@ bool CTaskBuild::EventProcess(const Event &event)
if ( m_phase == TBP_TURN ) // preliminary rotation?
{
a = m_object->RetAngleY(0);
a = m_object->GetAngleY(0);
g = m_angleY;
cirSpeed = Math::Direction(a, g)*1.0f;
if ( cirSpeed > 1.0f ) cirSpeed = 1.0f;
@ -225,7 +221,7 @@ bool CTaskBuild::EventProcess(const Event &event)
if ( m_phase == TBP_MOVE ) // preliminary forward/backward?
{
dist = Math::Distance(m_object->RetPosition(0), m_metal->RetPosition(0));
dist = Math::Distance(m_object->GetPosition(0), m_metal->GetPosition(0));
linSpeed = 0.0f;
if ( dist > 30.0f ) linSpeed = 1.0f;
if ( dist < 30.0f ) linSpeed = -1.0f;
@ -258,8 +254,8 @@ bool CTaskBuild::EventProcess(const Event &event)
{
m_bBuild = true;
pos = m_metal->RetPosition(0);
a = m_object->RetAngleY(0);
pos = m_metal->GetPosition(0);
a = m_object->GetAngleY(0);
if ( !CreateBuilding(pos, a+Math::PI) )
{
m_metal->SetLock(false); // usable again
@ -270,7 +266,7 @@ bool CTaskBuild::EventProcess(const Event &event)
m_camera->FlushEffect();
Abort();
m_bError = true;
m_displayText->DisplayError(ERR_TOOMANY, m_object->RetPosition(0));
m_displayText->DisplayError(ERR_TOOMANY, m_object->GetPosition(0));
return false;
}
CreateLight();
@ -295,32 +291,32 @@ bool CTaskBuild::EventProcess(const Event &event)
BlackLight();
}
if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
m_lastParticule = m_time;
m_lastParticle = m_time;
pos = m_metal->RetPosition(0);
pos = m_metal->GetPosition(0);
speed.x = (Math::Rand()-0.5f)*20.0f;
speed.z = (Math::Rand()-0.5f)*20.0f;
speed.y = Math::Rand()*10.0f;
dim.x = Math::Rand()*6.0f+4.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIFIRE);
m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIFIRE);
pos = Math::Vector(0.0f, 0.5f, 0.0f);
mat = m_object->RetWorldMatrix(14);
mat = m_object->GetWorldMatrix(14);
pos = Transform(*mat, pos);
speed = m_metal->RetPosition(0);
speed = m_metal->GetPosition(0);
speed.x += (Math::Rand()-0.5f)*5.0f;
speed.z += (Math::Rand()-0.5f)*5.0f;
speed -= pos;
dim.x = 2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIFIREZ);
m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIFIREZ);
if ( Math::Rand() < 0.3f )
{
m_sound->Play(SOUND_BUILD, m_object->RetPosition(0), 0.5f, 1.0f*Math::Rand()*1.5f);
m_sound->Play(SOUND_BUILD, m_object->GetPosition(0), 0.5f, 1.0f*Math::Rand()*1.5f);
}
}
@ -337,25 +333,25 @@ Error CTaskBuild::Start(ObjectType type)
float iAngle, oAngle;
m_type = type;
m_lastParticule = 0.0f;
m_lastParticle = 0.0f;
m_progress = 0.0f;
iAngle = m_object->RetAngleY(0);
iAngle = m_object->GetAngleY(0);
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
oAngle = iAngle;
m_bError = true; // operation impossible
pos = m_object->RetPosition(0);
if ( pos.y < m_water->RetLevel() ) return ERR_BUILD_WATER;
pos = m_object->GetPosition(0);
if ( pos.y < m_water->GetLevel() ) return ERR_BUILD_WATER;
if ( !m_physics->RetLand() ) return ERR_BUILD_FLY;
if ( !m_physics->GetLand() ) return ERR_BUILD_FLY;
speed = m_physics->RetMotorSpeed();
speed = m_physics->GetMotorSpeed();
if ( speed.x != 0.0f ||
speed.z != 0.0f ) return ERR_BUILD_MOTOR;
if ( m_object->RetFret() != 0 ) return ERR_MANIP_BUSY;
if ( m_object->GetFret() != 0 ) return ERR_MANIP_BUSY;
m_metal = SearchMetalObject(oAngle, 2.0f, 100.0f, Math::PI*0.25f, err);
if ( err == ERR_BUILD_METALNEAR && m_metal != 0 )
@ -375,9 +371,9 @@ Error CTaskBuild::Start(ObjectType type)
m_phase = TBP_TURN; // rotation necessary preliminary
m_angleY = oAngle; // angle was reached
pv = m_object->RetPosition(0);
pv = m_object->GetPosition(0);
pv.y += 8.3f;
pm = m_metal->RetPosition(0);
pm = m_metal->GetPosition(0);
m_angleZ = Math::RotateAngle(Math::DistanceProjected(pv, pm), fabs(pv.y-pm.y));
m_physics->SetFreeze(true); // it does not move
@ -394,27 +390,27 @@ Error CTaskBuild::IsEnded()
CAuto* automat;
float angle, dist, time;
if ( m_engine->RetPause() ) return ERR_CONTINUE;
if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
if ( m_phase == TBP_TURN ) // preliminary rotation?
{
angle = m_object->RetAngleY(0);
angle = m_object->GetAngleY(0);
angle = Math::NormAngle(angle); // 0..2*Math::PI
if ( Math::TestAngle(angle, m_angleY-Math::PI*0.01f, m_angleY+Math::PI*0.01f) )
{
m_physics->SetMotorSpeedZ(0.0f);
dist = Math::Distance(m_object->RetPosition(0), m_metal->RetPosition(0));
dist = Math::Distance(m_object->GetPosition(0), m_metal->GetPosition(0));
if ( dist > 30.0f )
{
time = m_physics->RetLinTimeLength(dist-30.0f, 1.0f);
time = m_physics->GetLinTimeLength(dist-30.0f, 1.0f);
m_speed = 1.0f/time;
}
else
{
time = m_physics->RetLinTimeLength(30.0f-dist, -1.0f);
time = m_physics->GetLinTimeLength(30.0f-dist, -1.0f);
m_speed = 1.0f/time;
}
m_phase = TBP_MOVE;
@ -425,7 +421,7 @@ Error CTaskBuild::IsEnded()
if ( m_phase == TBP_MOVE ) // preliminary forward/backward?
{
dist = Math::Distance(m_object->RetPosition(0), m_metal->RetPosition(0));
dist = Math::Distance(m_object->GetPosition(0), m_metal->GetPosition(0));
if ( dist >= 25.0f && dist <= 35.0f )
{
@ -466,12 +462,12 @@ Error CTaskBuild::IsEnded()
{
if ( m_progress < 1.0f ) return ERR_CONTINUE;
m_soundChannel = m_sound->Play(SOUND_TREMBLE, m_object->RetPosition(0), 0.0f, 1.0f, true);
m_soundChannel = m_sound->Play(SOUND_TREMBLE, m_object->GetPosition(0), 0.0f, 1.0f, true);
m_sound->AddEnvelope(m_soundChannel, 0.7f, 1.0f, 1.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.7f, 1.5f, 7.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.0f, 1.5f, 2.0f, SOPER_STOP);
m_camera->StartEffect(CE_VIBRATION, m_metal->RetPosition(0), 1.0f);
m_camera->StartEffect(Gfx::CAM_EFFECT_VIBRATION, m_metal->GetPosition(0), 1.0f);
m_phase = TBP_BUILD;
m_speed = 1.0f/10.f; // duration of 10s
@ -482,7 +478,7 @@ Error CTaskBuild::IsEnded()
{
if ( m_progress < 1.0f ) return ERR_CONTINUE;
DeleteMark(m_metal->RetPosition(0), 20.0f);
DeleteMark(m_metal->GetPosition(0), 20.0f);
m_metal->DeleteObject(); // removes the metal
delete m_metal;
@ -494,7 +490,7 @@ Error CTaskBuild::IsEnded()
m_main->CreateShortcuts();
m_displayText->DisplayError(INFO_BUILD, m_buildingPos, 10.0f, 50.0f);
automat = m_building->RetAuto();
automat = m_building->GetAuto();
if ( automat != 0 )
{
automat->Init();
@ -583,16 +579,16 @@ Error CTaskBuild::FlatFloor()
if ( m_type == OBJECT_INFO ) radius = 5.0f;
if ( radius == 0.0f ) return ERR_GENERIC;
center = m_metal->RetPosition(0);
angle = m_terrain->RetFineSlope(center);
bLittleFlat = ( angle < FLATLIMIT );
center = m_metal->GetPosition(0);
angle = m_terrain->GetFineSlope(center);
bLittleFlat = ( angle < Gfx::TERRAIN_FLATLIMIT);
max = m_terrain->RetFlatZoneRadius(center, radius);
max = m_terrain->GetFlatZoneRadius(center, radius);
if ( max < radius ) // area too small?
{
if ( bLittleFlat )
{
m_main->SetShowLimit(1, PARTILIMIT3, m_metal, center, max, 10.0f);
m_main->SetShowLimit(1, Gfx::PARTILIMIT3, m_metal, center, max, 10.0f);
}
return bLittleFlat?ERR_BUILD_FLATLIT:ERR_BUILD_FLAT;
}
@ -601,18 +597,18 @@ Error CTaskBuild::FlatFloor()
bBase = false;
for ( i=0 ; i<1000000 ; i++ )
{
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->RetActif() ) continue; // inactive?
if ( pObj->RetTruck() != 0 ) continue; // object transported?
if ( !pObj->GetActif() ) continue; // inactive?
if ( pObj->GetTruck() != 0 ) continue; // object transported?
if ( pObj == m_metal ) continue;
if ( pObj == m_object ) continue;
type = pObj->RetType();
type = pObj->GetType();
if ( type == OBJECT_BASE )
{
oPos = pObj->RetPosition(0);
oPos = pObj->GetPosition(0);
dist = Math::Distance(center, oPos)-80.0f;
if ( dist < max )
{
@ -640,24 +636,24 @@ Error CTaskBuild::FlatFloor()
}
if ( max < radius )
{
m_main->SetShowLimit(1, PARTILIMIT2, m_metal, center, max, 10.0f);
m_main->SetShowLimit(1, Gfx::PARTILIMIT2, m_metal, center, max, 10.0f);
if ( bRadius < 2.0f ) bRadius = 2.0f;
m_main->SetShowLimit(2, PARTILIMIT3, m_metal, bPos, bRadius, 10.0f);
m_main->SetShowLimit(2, Gfx::PARTILIMIT3, m_metal, bPos, bRadius, 10.0f);
return bBase?ERR_BUILD_BASE:ERR_BUILD_BUSY;
}
max = 100000.0f;
for ( i=0 ; i<1000000 ; i++ )
{
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->RetActif() ) continue; // inactive?
if ( pObj->RetTruck() != 0 ) continue; // object transported?
if ( !pObj->GetActif() ) continue; // inactive?
if ( pObj->GetTruck() != 0 ) continue; // object transported?
if ( pObj == m_metal ) continue;
if ( pObj == m_object ) continue;
type = pObj->RetType();
type = pObj->GetType();
if ( type == OBJECT_DERRICK ||
type == OBJECT_FACTORY ||
type == OBJECT_STATION ||
@ -691,8 +687,8 @@ Error CTaskBuild::FlatFloor()
}
if ( max-BUILDMARGIN < radius )
{
m_main->SetShowLimit(1, PARTILIMIT2, m_metal, center, max-BUILDMARGIN, 10.0f);
m_main->SetShowLimit(2, PARTILIMIT3, m_metal, bPos, bRadius+BUILDMARGIN, 10.0f);
m_main->SetShowLimit(1, Gfx::PARTILIMIT2, m_metal, center, max-BUILDMARGIN, 10.0f);
m_main->SetShowLimit(2, Gfx::PARTILIMIT3, m_metal, bPos, bRadius+BUILDMARGIN, 10.0f);
return bBase?ERR_BUILD_BASE:ERR_BUILD_NARROW;
}
@ -711,8 +707,8 @@ CObject* CTaskBuild::SearchMetalObject(float &angle, float dMin, float dMax,
int i;
bool bMetal;
iPos = m_object->RetPosition(0);
iAngle = m_object->RetAngleY(0);
iPos = m_object->GetPosition(0);
iAngle = m_object->GetAngleY(0);
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
min = 1000000.0f;
@ -720,18 +716,18 @@ CObject* CTaskBuild::SearchMetalObject(float &angle, float dMin, float dMax,
bMetal = false;
for ( i=0 ; i<1000000 ; i++ )
{
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->RetActif() ) continue; // objet inactive?
if ( pObj->RetTruck() != 0 ) continue; // object transported?
if ( !pObj->GetActif() ) continue; // objet inactive?
if ( pObj->GetTruck() != 0 ) continue; // object transported?
type = pObj->RetType();
type = pObj->GetType();
if ( type != OBJECT_METAL ) continue;
bMetal = true; // metal exists
oPos = pObj->RetPosition(0);
oPos = pObj->GetPosition(0);
distance = Math::Distance(oPos, iPos);
a = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW!
@ -781,10 +777,10 @@ void CTaskBuild::DeleteMark(Math::Vector pos, float radius)
for ( i=0 ; i<1000000 ; i++ )
{
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->RetType();
type = pObj->GetType();
if ( type != OBJECT_MARKSTONE &&
type != OBJECT_MARKURANIUM &&
type != OBJECT_MARKKEYa &&
@ -793,7 +789,7 @@ void CTaskBuild::DeleteMark(Math::Vector pos, float radius)
type != OBJECT_MARKKEYd &&
type != OBJECT_MARKPOWER ) continue;
oPos = pObj->RetPosition(0);
oPos = pObj->GetPosition(0);
distance = Math::Distance(oPos, pos);
if ( distance <= radius )
{

View File

@ -72,14 +72,14 @@ protected:
bool m_bBuild; // true -> building built
bool m_bBlack; // true -> lights black -> white
float m_time; // absolute time
float m_lastParticule; // time of generation last particle
float m_lastParticle; // time of generation last particle
float m_progress; // progression (0..1)
float m_speed; // speed of progression
float m_angleY; // rotation angle of the vehicle
float m_angleZ; // angle of rotation of the gun
Math::Vector m_buildingPos; // initial position of the building
float m_buildingHeight; // height of the building
int m_lightRank[TBMAXLIGHT];// lights for the effects
int m_lightRank[TBMAXLIGHT]; // lights for the effects
int m_soundChannel;
};

View File

@ -16,12 +16,9 @@
// taskfire.cpp
#include <stdio.h>
#include "object/task/taskfire.h"
#include "old/particule.h"
#include "graphics/engine/particle.h"
#include "math/geometry.h"
#include "physics/physics.h"
@ -66,32 +63,32 @@ bool CTaskFire::EventProcess(const Event &event)
float energy, fire;
int i, channel;
if ( m_engine->RetPause() ) return true;
if ( event.event != EVENT_FRAME ) return true;
if ( m_engine->GetPause() ) return true;
if ( event.type != EVENT_FRAME ) return true;
if ( m_bError ) return false;
m_time += event.rTime;
m_lastSound -= event.rTime;
m_progress += event.rTime*m_speed;
power = m_object->RetPower();
power = m_object->GetPower();
if ( power != 0 )
{
energy = power->RetEnergy();
energy = power->GetEnergy();
if ( m_bOrganic ) fire = ENERGY_FIREi;
else if ( m_bRay ) fire = ENERGY_FIREr;
else fire = ENERGY_FIRE;
energy -= event.rTime*fire/power->RetCapacity();
energy -= event.rTime*fire/power->GetCapacity();
power->SetEnergy(energy);
}
if ( m_lastParticule+0.05f <= m_time )
if ( m_lastParticle+0.05f <= m_time )
{
m_lastParticule = m_time;
m_lastParticle = m_time;
if ( m_bOrganic )
{
mat = m_object->RetWorldMatrix(1); // insect-cannon
mat = m_object->GetWorldMatrix(1); // insect-cannon
for ( i=0 ; i<6 ; i++ )
{
@ -100,10 +97,10 @@ bool CTaskFire::EventProcess(const Event &event)
speed = Math::Vector(200.0f, 0.0f, 0.0f);
physics = m_object->RetPhysics();
physics = m_object->GetPhysics();
if ( physics != 0 )
{
speed += physics->RetLinMotion(MO_REASPEED);
speed += physics->GetLinMotion(MO_REASPEED);
}
speed.x += (Math::Rand()-0.5f)*10.0f;
@ -115,13 +112,13 @@ bool CTaskFire::EventProcess(const Event &event)
dim.x = Math::Rand()*0.5f+0.5f;
dim.y = dim.x;
channel = m_particule->CreateParticule(pos, speed, dim, PARTIGUN4, 0.8f, 0.0f, 0.0f);
m_particule->SetObjectFather(channel, m_object);
channel = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGUN4, 0.8f, 0.0f, 0.0f);
m_particle->SetObjectFather(channel, m_object);
}
}
else if ( m_bRay )
{
mat = m_object->RetWorldMatrix(2); // cannon
mat = m_object->GetWorldMatrix(2); // cannon
for ( i=0 ; i<4 ; i++ )
{
@ -139,9 +136,9 @@ bool CTaskFire::EventProcess(const Event &event)
dim.x = 1.0f;
dim.y = dim.x;
channel = m_particule->CreateTrack(pos, speed, dim, PARTITRACK11,
channel = m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK11,
2.0f, 200.0f, 0.5f, 1.0f);
m_particule->SetObjectFather(channel, m_object);
m_particle->SetObjectFather(channel, m_object);
speed = Math::Vector(5.0f, 0.0f, 0.0f);
speed.x += (Math::Rand()-0.5f)*1.0f;
@ -153,20 +150,20 @@ bool CTaskFire::EventProcess(const Event &event)
dim.x = 2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE2, 2.0f, 0.0f, 0.5f);
m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE2, 2.0f, 0.0f, 0.5f);
}
}
else
{
type = m_object->RetType();
type = m_object->GetType();
if ( type == OBJECT_MOBILErc )
{
mat = m_object->RetWorldMatrix(2); // cannon
mat = m_object->GetWorldMatrix(2); // cannon
}
else
{
mat = m_object->RetWorldMatrix(1); // cannon
mat = m_object->GetWorldMatrix(1); // cannon
}
for ( i=0 ; i<3 ; i++ )
@ -185,10 +182,10 @@ bool CTaskFire::EventProcess(const Event &event)
speed = Math::Vector(200.0f, 0.0f, 0.0f);
physics = m_object->RetPhysics();
physics = m_object->GetPhysics();
if ( physics != 0 )
{
speed += physics->RetLinMotion(MO_REASPEED);
speed += physics->GetLinMotion(MO_REASPEED);
}
speed.x += (Math::Rand()-0.5f)*3.0f;
@ -200,8 +197,8 @@ bool CTaskFire::EventProcess(const Event &event)
dim.x = Math::Rand()*0.7f+0.7f;
dim.y = dim.x;
channel = m_particule->CreateParticule(pos, speed, dim, PARTIGUN1, 0.8f, 0.0f, 0.0f);
m_particule->SetObjectFather(channel, m_object);
channel = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGUN1, 0.8f, 0.0f, 0.0f);
m_particle->SetObjectFather(channel, m_object);
}
if ( type != OBJECT_MOBILErc &&
@ -222,8 +219,8 @@ bool CTaskFire::EventProcess(const Event &event)
dim.x = Math::Rand()*1.2f+1.2f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTICRASH, 2.0f, 0.0f, 0.0f);
//? m_particule->CreateParticule(pos, speed, dim, PARTISMOKE2, 4.0f, 0.0f, 0.0f);
m_particle->CreateParticle(pos, speed, dim, Gfx::PARTICRASH, 2.0f, 0.0f, 0.0f);
//? m_particle->CreateParticle(pos, speed, dim, PARTISMOKE2, 4.0f, 0.0f, 0.0f);
}
}
@ -256,7 +253,7 @@ bool CTaskFire::EventProcess(const Event &event)
if ( m_bRay && m_lastSound <= 0.0f )
{
m_lastSound = Math::Rand()*0.4f+0.4f;
m_sound->Play(SOUND_FIREp, m_object->RetPosition(0));
m_sound->Play(SOUND_FIREp, m_object->GetPosition(0));
}
return true;
@ -274,7 +271,7 @@ Error CTaskFire::Start(float delay)
m_bError = true; // operation impossible
type = m_object->RetType();
type = m_object->GetType();
if ( type != OBJECT_MOBILEfc &&
type != OBJECT_MOBILEtc &&
type != OBJECT_MOBILEwc &&
@ -285,9 +282,9 @@ Error CTaskFire::Start(float delay)
type != OBJECT_MOBILEii &&
type != OBJECT_MOBILErc ) return ERR_FIRE_VEH;
//? if ( !m_physics->RetLand() ) return ERR_FIRE_FLY;
//? if ( !m_physics->GetLand() ) return ERR_FIRE_FLY;
speed = m_physics->RetMotorSpeed();
speed = m_physics->GetMotorSpeed();
//? if ( speed.x != 0.0f ||
//? speed.z != 0.0f ) return ERR_FIRE_MOTOR;
@ -309,18 +306,18 @@ Error CTaskFire::Start(float delay)
}
m_delay = delay;
power = m_object->RetPower();
power = m_object->GetPower();
if ( power == 0 ) return ERR_FIRE_ENERGY;
energy = power->RetEnergy();
energy = power->GetEnergy();
if ( m_bOrganic ) fire = m_delay*ENERGY_FIREi;
else if ( m_bRay ) fire = m_delay*ENERGY_FIREr;
else fire = m_delay*ENERGY_FIRE;
if ( energy < fire/power->RetCapacity()+0.05f ) return ERR_FIRE_ENERGY;
if ( energy < fire/power->GetCapacity()+0.05f ) return ERR_FIRE_ENERGY;
m_speed = 1.0f/m_delay;
m_progress = 0.0f;
m_time = 0.0f;
m_lastParticule = 0.0f;
m_lastParticle = 0.0f;
m_lastSound = 0.0f;
m_bError = false; // ok
@ -328,7 +325,7 @@ Error CTaskFire::Start(float delay)
if ( m_bOrganic )
{
m_soundChannel = m_sound->Play(SOUND_FIREi, m_object->RetPosition(0), 1.0f, 1.0f, true);
m_soundChannel = m_sound->Play(SOUND_FIREi, m_object->GetPosition(0), 1.0f, 1.0f, true);
if ( m_soundChannel != -1 )
{
m_sound->AddEnvelope(m_soundChannel, 1.0f, 1.0f, m_delay, SOPER_CONTINUE);
@ -340,7 +337,7 @@ Error CTaskFire::Start(float delay)
}
else
{
m_soundChannel = m_sound->Play(SOUND_FIRE, m_object->RetPosition(0), 1.0f, 1.0f, true);
m_soundChannel = m_sound->Play(SOUND_FIRE, m_object->GetPosition(0), 1.0f, 1.0f, true);
if ( m_soundChannel != -1 )
{
m_sound->AddEnvelope(m_soundChannel, 1.0f, 1.0f, m_delay, SOPER_CONTINUE);
@ -355,7 +352,7 @@ Error CTaskFire::Start(float delay)
Error CTaskFire::IsEnded()
{
if ( m_engine->RetPause() ) return ERR_CONTINUE;
if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
if ( m_progress < 1.0f ) return ERR_CONTINUE;

View File

@ -45,7 +45,7 @@ protected:
bool m_bOrganic;
float m_time;
float m_speed;
float m_lastParticule;
float m_lastParticle;
float m_lastSound;
int m_soundChannel;
};

View File

@ -16,12 +16,9 @@
// taskfireant.cpp
#include <stdio.h>
#include "object/task/taskfireant.h"
#include "old/particule.h"
#include "graphics/engine/particle.h"
#include "math/geometry.h"
#include "object/motion/motionant.h"
#include "physics/physics.h"
@ -51,11 +48,11 @@ bool CTaskFireAnt::EventProcess(const Event &event)
Math::Vector dir, vib;
float a, g, cirSpeed;
if ( m_engine->RetPause() ) return true;
if ( event.event != EVENT_FRAME ) return true;
if ( m_engine->GetPause() ) return true;
if ( event.type != EVENT_FRAME ) return true;
if ( m_bError ) return false;
if ( m_object->RetFixed() ) // insect on its back?
if ( m_object->GetFixed() ) // insect on its back?
{
m_bError = true;
return false;
@ -66,7 +63,7 @@ bool CTaskFireAnt::EventProcess(const Event &event)
if ( m_phase == TFA_TURN ) // preliminary rotation?
{
a = m_object->RetAngleY(0);
a = m_object->GetAngleY(0);
g = m_angle;
cirSpeed = Math::Direction(a, g)*2.0f;
if ( cirSpeed > 2.0f ) cirSpeed = 2.0f;
@ -89,24 +86,24 @@ Error CTaskFireAnt::Start(Math::Vector impact)
m_impact = impact;
m_bError = true; // operation impossible
if ( !m_physics->RetLand() ) return ERR_FIRE_VEH;
if ( !m_physics->GetLand() ) return ERR_FIRE_VEH;
type = m_object->RetType();
type = m_object->GetType();
if ( type != OBJECT_ANT ) return ERR_FIRE_VEH;
// Insect on its back?
if ( m_object->RetFixed() ) return ERR_FIRE_VEH;
if ( m_object->GetFixed() ) return ERR_FIRE_VEH;
m_physics->SetMotorSpeed(Math::Vector(0.0f, 0.0f, 0.0f));
pos = m_object->RetPosition(0);
pos = m_object->GetPosition(0);
m_angle = Math::RotateAngle(m_impact.x-pos.x, pos.z-m_impact.z); // CW !
m_phase = TFA_TURN;
m_speed = 1.0f/1.0f;
m_progress = 0.0f;
m_time = 0.0f;
m_lastParticule = 0.0f;
m_lastParticle = 0.0f;
m_bError = false; // ok
m_bFire = false; // once!
@ -123,13 +120,13 @@ Error CTaskFireAnt::IsEnded()
float angle, dist;
int i, channel;
if ( m_engine->RetPause() ) return ERR_CONTINUE;
if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
if ( m_object->RetFixed() ) return ERR_STOP; // insect on its back?
if ( m_object->GetFixed() ) return ERR_STOP; // insect on its back?
if ( m_phase == TFA_TURN ) // rotation ?
{
angle = m_object->RetAngleY(0);
angle = m_object->GetAngleY(0);
angle = Math::NormAngle(angle); // 0..2*Math::PI
if ( !Math::TestAngle(angle, m_angle-Math::PI*0.05f, m_angle+Math::PI*0.05f) ) return ERR_CONTINUE;
@ -164,7 +161,7 @@ Error CTaskFireAnt::IsEnded()
for ( i=0 ; i<20 ; i++ )
{
pos = Math::Vector(-2.5f, -0.7f, 0.0f);
mat = m_object->RetWorldMatrix(2);
mat = m_object->GetWorldMatrix(2);
pos = Math::Transform(*mat, pos);
dist = Math::Distance(pos, m_impact);
speed = m_impact-pos;
@ -173,8 +170,8 @@ Error CTaskFireAnt::IsEnded()
speed.z += (Math::Rand()-0.5f)*dist*1.2f;
dim.x = 1.0f;
dim.y = dim.x;
channel = m_particule->CreateParticule(pos, speed, dim, PARTIGUN2, 2.0f, 100.0f, 0.0f);
m_particule->SetObjectFather(channel, m_object);
channel = m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGUN2, 2.0f, 100.0f, 0.0f);
m_particle->SetObjectFather(channel, m_object);
}
}

View File

@ -58,6 +58,6 @@ protected:
bool m_bError;
bool m_bFire;
float m_time;
float m_lastParticule;
float m_lastParticle;
};

View File

@ -16,15 +16,13 @@
// taskflag.cpp
#include <stdio.h>
#include "object/task/taskflag.h"
#include "math/geometry.h"
#include "common/iman.h"
#include "old/water.h"
#include "old/pyro.h"
#include "graphics/engine/particle.h"
#include "graphics/engine/pyro.h"
#include "graphics/engine/water.h"
#include "physics/physics.h"
#include "object/motion/motionhuman.h"
@ -51,8 +49,8 @@ CTaskFlag::~CTaskFlag()
bool CTaskFlag::EventProcess(const Event &event)
{
if ( m_bError ) return true;
if ( m_engine->RetPause() ) return true;
if ( event.event != EVENT_FRAME ) return true;
if ( m_engine->GetPause() ) return true;
if ( event.type != EVENT_FRAME ) return true;
m_time += event.rTime;
@ -72,18 +70,18 @@ Error CTaskFlag::Start(TaskFlagOrder order, int rank)
m_time = 0.0f;
m_bError = true; // operation impossible
if ( !m_physics->RetLand() )
if ( !m_physics->GetLand() )
{
pos = m_object->RetPosition(0);
if ( pos.y < m_water->RetLevel() ) return ERR_FLAG_WATER;
pos = m_object->GetPosition(0);
if ( pos.y < m_water->GetLevel() ) return ERR_FLAG_WATER;
return ERR_FLAG_FLY;
}
speed = m_physics->RetMotorSpeed();
speed = m_physics->GetMotorSpeed();
if ( speed.x != 0.0f ||
speed.z != 0.0f ) return ERR_FLAG_MOTOR;
if ( m_object->RetFret() != 0 ) return ERR_FLAG_BUSY;
if ( m_object->GetFret() != 0 ) return ERR_FLAG_BUSY;
if ( order == TFL_CREATE )
{
@ -109,7 +107,7 @@ Error CTaskFlag::Start(TaskFlagOrder order, int rank)
Error CTaskFlag::IsEnded()
{
if ( m_engine->RetPause() ) return ERR_CONTINUE;
if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
if ( m_time < 2.0f ) return ERR_CONTINUE;
@ -143,12 +141,12 @@ CObject* CTaskFlag::SearchNearest(Math::Vector pos, ObjectType type)
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->RetEnable() ) continue;
if ( !pObj->GetEnable() ) continue;
oType = pObj->RetType();
oType = pObj->GetType();
if ( type == OBJECT_NULL )
{
if ( oType != OBJECT_FLAGb &&
@ -162,7 +160,7 @@ CObject* CTaskFlag::SearchNearest(Math::Vector pos, ObjectType type)
if ( oType != type ) continue;
}
oPos = pObj->RetPosition(0);
oPos = pObj->GetPosition(0);
dist = Math::DistanceProjected(oPos, pos);
if ( dist < min )
{
@ -185,12 +183,12 @@ int CTaskFlag::CountObject(ObjectType type)
count = 0;
for ( i=0 ; i<1000000 ; i++ )
{
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( !pObj->RetEnable() ) continue;
if ( !pObj->GetEnable() ) continue;
oType = pObj->RetType();
oType = pObj->GetType();
if ( type == OBJECT_NULL )
{
if ( oType != OBJECT_FLAGb &&
@ -215,7 +213,7 @@ Error CTaskFlag::CreateFlag(int rank)
{
CObject* pObj;
CObject* pNew;
CPyro* pyro;
Gfx::CPyro* pyro;
Math::Matrix* mat;
Math::Vector pos;
float dist;
@ -230,13 +228,13 @@ Error CTaskFlag::CreateFlag(int rank)
OBJECT_FLAGv,
};
mat = m_object->RetWorldMatrix(0);
mat = m_object->GetWorldMatrix(0);
pos = Transform(*mat, Math::Vector(4.0f, 0.0f, 0.0f));
pObj = SearchNearest(pos, OBJECT_NULL);
if ( pObj != 0 )
{
dist = Math::Distance(pos, pObj->RetPosition(0));
dist = Math::Distance(pos, pObj->GetPosition(0));
if ( dist < 10.0f )
{
return ERR_FLAG_PROXY;
@ -258,8 +256,8 @@ Error CTaskFlag::CreateFlag(int rank)
pNew->SetZoom(0, 0.0f);
m_sound->Play(SOUND_WAYPOINT, pos);
pyro = new CPyro(m_iMan);
pyro->Create(PT_FLCREATE, pNew);
pyro = new Gfx::CPyro(m_iMan);
pyro->Create(Gfx::PT_FLCREATE, pNew);
return ERR_OK;
}
@ -269,12 +267,12 @@ Error CTaskFlag::CreateFlag(int rank)
Error CTaskFlag::DeleteFlag()
{
CObject* pObj;
CPyro* pyro;
Gfx::CPyro* pyro;
Math::Vector iPos, oPos;
float iAngle, angle, aLimit, dist;
iPos = m_object->RetPosition(0);
iAngle = m_object->RetAngleY(0);
iPos = m_object->GetPosition(0);
iAngle = m_object->GetAngleY(0);
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
pObj = SearchNearest(iPos, OBJECT_NULL);
@ -282,13 +280,13 @@ Error CTaskFlag::DeleteFlag()
{
return ERR_FLAG_DELETE;
}
dist = Math::Distance(iPos, pObj->RetPosition(0));
dist = Math::Distance(iPos, pObj->GetPosition(0));
if ( dist > 10.0f )
{
return ERR_FLAG_DELETE;
}
oPos = pObj->RetPosition(0);
oPos = pObj->GetPosition(0);
angle = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
aLimit = 45.0f*Math::PI/180.0f;
if ( !Math::TestAngle(angle, iAngle-aLimit, iAngle+aLimit) )
@ -297,8 +295,8 @@ Error CTaskFlag::DeleteFlag()
}
m_sound->Play(SOUND_WAYPOINT, iPos);
pyro = new CPyro(m_iMan);
pyro->Create(PT_FLDELETE, pObj);
pyro = new Gfx::CPyro(m_iMan);
pyro->Create(Gfx::PT_FLDELETE, pObj);
return ERR_OK;
}

File diff suppressed because it is too large Load Diff

View File

@ -16,9 +16,6 @@
// taskgungoal.cpp
#include <stdio.h>
#include "object/task/taskgungoal.h"
#include "object/object.h"
@ -46,8 +43,8 @@ bool CTaskGunGoal::EventProcess(const Event &event)
{
float dir;
if ( m_engine->RetPause() ) return true;
if ( event.event != EVENT_FRAME ) return true;
if ( m_engine->GetPause() ) return true;
if ( event.type != EVENT_FRAME ) return true;
m_progress += event.rTime*m_speed;
@ -82,9 +79,9 @@ Error CTaskGunGoal::Start(float dirV, float dirH)
float speedV, speedH;
int i;
m_initialDirV = m_object->RetGunGoalV();
m_initialDirV = m_object->GetGunGoalV();
m_object->SetGunGoalV(dirV);
m_finalDirV = m_object->RetGunGoalV(); // possible direction
m_finalDirV = m_object->GetGunGoalV(); // possible direction
m_object->SetGunGoalV(m_initialDirV); // gives initial direction
if ( m_finalDirV == m_initialDirV )
@ -96,9 +93,9 @@ Error CTaskGunGoal::Start(float dirV, float dirH)
speedV = 1.0f/(fabs(m_finalDirV-m_initialDirV)*1.0f);
}
m_initialDirH = m_object->RetGunGoalH();
m_initialDirH = m_object->GetGunGoalH();
m_object->SetGunGoalH(dirH);
m_finalDirH = m_object->RetGunGoalH(); // possible direction
m_finalDirH = m_object->GetGunGoalH(); // possible direction
m_object->SetGunGoalH(m_initialDirH); // gives initial direction
if ( m_finalDirH == m_initialDirH )
@ -115,7 +112,7 @@ Error CTaskGunGoal::Start(float dirV, float dirH)
if ( m_finalDirV != m_initialDirV ||
m_finalDirH != m_initialDirH )
{
i = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.3f, 1.5f, true);
i = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 0.3f, 1.5f, true);
m_sound->AddEnvelope(i, 0.3f, 1.5f, 1.0f/m_speed, SOPER_STOP);
}
@ -128,7 +125,7 @@ Error CTaskGunGoal::Start(float dirV, float dirH)
Error CTaskGunGoal::IsEnded()
{
if ( m_engine->RetPause() ) return ERR_CONTINUE;
if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_initialDirV == m_finalDirV &&
m_initialDirH == m_finalDirH ) return ERR_STOP;

View File

@ -16,13 +16,10 @@
// taskinfo.cpp
#include <stdio.h>
#include "object/task/taskinfo.h"
#include "common/iman.h"
#include "old/particule.h"
#include "graphics/engine/particle.h"
#include "object/auto/autoinfo.h"
@ -47,8 +44,8 @@ CTaskInfo::~CTaskInfo()
bool CTaskInfo::EventProcess(const Event &event)
{
if ( m_engine->RetPause() ) return true;
if ( event.event != EVENT_FRAME ) return true;
if ( m_engine->GetPause() ) return true;
if ( event.type != EVENT_FRAME ) return true;
if ( m_bError ) return false;
m_progress += event.rTime*m_speed; // other advance
@ -60,7 +57,7 @@ bool CTaskInfo::EventProcess(const Event &event)
// Assigns the goal was achieved.
Error CTaskInfo::Start(char *name, float value, float power, bool bSend)
Error CTaskInfo::Start(const char *name, float value, float power, bool bSend)
{
CObject* pInfo;
CAutoInfo* pAuto;
@ -77,7 +74,7 @@ Error CTaskInfo::Start(char *name, float value, float power, bool bSend)
return ERR_INFO_NULL;
}
pAuto = (CAutoInfo*)pInfo->RetAuto();
pAuto = static_cast<CAutoInfo*>(pInfo->GetAuto());
if ( pAuto == 0 )
{
return ERR_INFO_NULL;
@ -86,10 +83,10 @@ Error CTaskInfo::Start(char *name, float value, float power, bool bSend)
op = 1; // transmission impossible
if ( bSend ) // send?
{
total = pInfo->RetInfoTotal();
total = pInfo->GetInfoTotal();
for ( i=0 ; i<total ; i++ )
{
info = pInfo->RetInfo(i);
info = pInfo->GetInfo(i);
if ( strcmp(info.name, name) == 0 )
{
info.value = value;
@ -114,10 +111,10 @@ Error CTaskInfo::Start(char *name, float value, float power, bool bSend)
}
else // receive?
{
total = pInfo->RetInfoTotal();
total = pInfo->GetInfoTotal();
for ( i=0 ; i<total ; i++ )
{
info = pInfo->RetInfo(i);
info = pInfo->GetInfo(i);
if ( strcmp(info.name, name) == 0 )
{
m_object->SetInfoReturn(info.value);
@ -134,19 +131,19 @@ Error CTaskInfo::Start(char *name, float value, float power, bool bSend)
if ( op == 0 ) // transmission?
{
pos = pInfo->RetPosition(0);
pos = pInfo->GetPosition(0);
pos.y += 9.5f;
goal = m_object->RetPosition(0);
goal = m_object->GetPosition(0);
goal.y += 4.0f;
m_particule->CreateRay(pos, goal, PARTIRAY3, Math::Point(2.0f, 2.0f), 1.0f);
m_particle->CreateRay(pos, goal, Gfx::PARTIRAY3, Math::Point(2.0f, 2.0f), 1.0f);
}
if ( op == 2 ) // reception?
{
goal = pInfo->RetPosition(0);
goal = pInfo->GetPosition(0);
goal.y += 9.5f;
pos = m_object->RetPosition(0);
pos = m_object->GetPosition(0);
pos.y += 4.0f;
m_particule->CreateRay(pos, goal, PARTIRAY3, Math::Point(2.0f, 2.0f), 1.0f);
m_particle->CreateRay(pos, goal, Gfx::PARTIRAY3, Math::Point(2.0f, 2.0f), 1.0f);
}
m_progress = 0.0f;
@ -162,7 +159,7 @@ Error CTaskInfo::Start(char *name, float value, float power, bool bSend)
Error CTaskInfo::IsEnded()
{
if ( m_engine->RetPause() ) return ERR_CONTINUE;
if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
if ( m_progress < 1.0f ) return ERR_CONTINUE;
@ -190,21 +187,21 @@ CObject* CTaskInfo::SearchInfo(float power)
float dist, min;
int i;
iPos = m_object->RetPosition(0);
iPos = m_object->GetPosition(0);
min = 100000.0f;
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->RetType();
type = pObj->GetType();
if ( type != OBJECT_INFO ) continue;
if ( !pObj->RetActif() ) continue;
if ( !pObj->GetActif() ) continue;
oPos = pObj->RetPosition(0);
oPos = pObj->GetPosition(0);
dist = Math::Distance(oPos, iPos);
if ( dist > power ) continue; // too far?
if ( dist < min )

View File

@ -31,7 +31,7 @@ public:
bool EventProcess(const Event &event);
Error Start(char *name, float value, float power, bool bSend);
Error Start(const char *name, float value, float power, bool bSend);
Error IsEnded();
bool Abort();

View File

@ -67,7 +67,7 @@ CTaskManager::~CTaskManager()
Error CTaskManager::StartTaskWait(float time)
{
m_task = new CTaskWait(m_iMan, m_object);
return ((CTaskWait*)m_task)->Start(time);
return (static_cast<CTaskWait*>(m_task))->Start(time);
}
// Advance straight ahead a certain distance.
@ -75,7 +75,7 @@ Error CTaskManager::StartTaskWait(float time)
Error CTaskManager::StartTaskAdvance(float length)
{
m_task = new CTaskAdvance(m_iMan, m_object);
return ((CTaskAdvance*)m_task)->Start(length);
return (static_cast<CTaskAdvance*>(m_task))->Start(length);
}
// Turns through an certain angle.
@ -83,7 +83,7 @@ Error CTaskManager::StartTaskAdvance(float length)
Error CTaskManager::StartTaskTurn(float angle)
{
m_task = new CTaskTurn(m_iMan, m_object);
return ((CTaskTurn*)m_task)->Start(angle);
return (static_cast<CTaskTurn*>(m_task))->Start(angle);
}
// Reaches a given position.
@ -91,7 +91,7 @@ Error CTaskManager::StartTaskTurn(float angle)
Error CTaskManager::StartTaskGoto(Math::Vector pos, float altitude, TaskGotoGoal goalMode, TaskGotoCrash crashMode)
{
m_task = new CTaskGoto(m_iMan, m_object);
return ((CTaskGoto*)m_task)->Start(pos, altitude, goalMode, crashMode);
return (static_cast<CTaskGoto*>(m_task))->Start(pos, altitude, goalMode, crashMode);
}
// Move the manipulator arm.
@ -99,7 +99,7 @@ Error CTaskManager::StartTaskGoto(Math::Vector pos, float altitude, TaskGotoGoal
Error CTaskManager::StartTaskTake()
{
m_task = new CTaskTake(m_iMan, m_object);
return ((CTaskTake*)m_task)->Start();
return (static_cast<CTaskTake*>(m_task))->Start();
}
// Move the manipulator arm.
@ -107,7 +107,7 @@ Error CTaskManager::StartTaskTake()
Error CTaskManager::StartTaskManip(TaskManipOrder order, TaskManipArm arm)
{
m_task = new CTaskManip(m_iMan, m_object);
return ((CTaskManip*)m_task)->Start(order, arm);
return (static_cast<CTaskManip*>(m_task))->Start(order, arm);
}
// Puts or removes a flag.
@ -115,7 +115,7 @@ Error CTaskManager::StartTaskManip(TaskManipOrder order, TaskManipArm arm)
Error CTaskManager::StartTaskFlag(TaskFlagOrder order, int rank)
{
m_task = new CTaskFlag(m_iMan, m_object);
return ((CTaskFlag*)m_task)->Start(order, rank);
return (static_cast<CTaskFlag*>(m_task))->Start(order, rank);
}
// Builds a building.
@ -123,7 +123,7 @@ Error CTaskManager::StartTaskFlag(TaskFlagOrder order, int rank)
Error CTaskManager::StartTaskBuild(ObjectType type)
{
m_task = new CTaskBuild(m_iMan, m_object);
return ((CTaskBuild*)m_task)->Start(type);
return (static_cast<CTaskBuild*>(m_task))->Start(type);
}
// Probe the ground.
@ -131,7 +131,7 @@ Error CTaskManager::StartTaskBuild(ObjectType type)
Error CTaskManager::StartTaskSearch()
{
m_task = new CTaskSearch(m_iMan, m_object);
return ((CTaskSearch*)m_task)->Start();
return (static_cast<CTaskSearch*>(m_task))->Start();
}
// Reads an information terminal.
@ -139,7 +139,7 @@ Error CTaskManager::StartTaskSearch()
Error CTaskManager::StartTaskInfo(const char *name, float value, float power, bool bSend)
{
m_task = new CTaskInfo(m_iMan, m_object);
return ((CTaskInfo*)m_task)->Start(name, value, power, bSend);
return (static_cast<CTaskInfo*>(m_task))->Start(name, value, power, bSend);
}
// Terraforms the ground.
@ -147,7 +147,7 @@ Error CTaskManager::StartTaskInfo(const char *name, float value, float power, bo
Error CTaskManager::StartTaskTerraform()
{
m_task = new CTaskTerraform(m_iMan, m_object);
return ((CTaskTerraform*)m_task)->Start();
return (static_cast<CTaskTerraform*>(m_task))->Start();
}
// Changes the pencil.
@ -155,7 +155,7 @@ Error CTaskManager::StartTaskTerraform()
Error CTaskManager::StartTaskPen(bool bDown, int color)
{
m_task = new CTaskPen(m_iMan, m_object);
return ((CTaskPen*)m_task)->Start(bDown, color);
return (static_cast<CTaskPen*>(m_task))->Start(bDown, color);
}
// Recovers a ruin.
@ -163,7 +163,7 @@ Error CTaskManager::StartTaskPen(bool bDown, int color)
Error CTaskManager::StartTaskRecover()
{
m_task = new CTaskRecover(m_iMan, m_object);
return ((CTaskRecover*)m_task)->Start();
return (static_cast<CTaskRecover*>(m_task))->Start();
}
// Deploys the shield.
@ -173,15 +173,15 @@ Error CTaskManager::StartTaskShield(TaskShieldMode mode, float delay)
if ( mode == TSM_UP )
{
m_task = new CTaskShield(m_iMan, m_object);
return ((CTaskShield*)m_task)->Start(mode, delay);
return (static_cast<CTaskShield*>(m_task))->Start(mode, delay);
}
if ( mode == TSM_DOWN && m_task != 0 )
{
return ((CTaskShield*)m_task)->Start(mode, delay);
return (static_cast<CTaskShield*>(m_task))->Start(mode, delay);
}
if ( mode == TSM_UPDATE && m_task != 0 )
{
return ((CTaskShield*)m_task)->Start(mode, delay);
return (static_cast<CTaskShield*>(m_task))->Start(mode, delay);
}
return ERR_GENERIC;
}
@ -192,7 +192,7 @@ Error CTaskManager::StartTaskFire(float delay)
{
m_bPilot = true;
m_task = new CTaskFire(m_iMan, m_object);
return ((CTaskFire*)m_task)->Start(delay);
return (static_cast<CTaskFire*>(m_task))->Start(delay);
}
// Shoots with the ant.
@ -200,7 +200,7 @@ Error CTaskManager::StartTaskFire(float delay)
Error CTaskManager::StartTaskFireAnt(Math::Vector impact)
{
m_task = new CTaskFireAnt(m_iMan, m_object);
return ((CTaskFireAnt*)m_task)->Start(impact);
return (static_cast<CTaskFireAnt*>(m_task))->Start(impact);
}
// Adjusts higher.
@ -208,7 +208,7 @@ Error CTaskManager::StartTaskFireAnt(Math::Vector impact)
Error CTaskManager::StartTaskGunGoal(float dirV, float dirH)
{
m_task = new CTaskGunGoal(m_iMan, m_object);
return ((CTaskGunGoal*)m_task)->Start(dirV, dirH);
return (static_cast<CTaskGunGoal*>(m_task))->Start(dirV, dirH);
}
// Suicide of the spider.
@ -216,7 +216,7 @@ Error CTaskManager::StartTaskGunGoal(float dirV, float dirH)
Error CTaskManager::StartTaskSpiderExplo()
{
m_task = new CTaskSpiderExplo(m_iMan, m_object);
return ((CTaskSpiderExplo*)m_task)->Start();
return (static_cast<CTaskSpiderExplo*>(m_task))->Start();
}
// Reset.
@ -224,7 +224,7 @@ Error CTaskManager::StartTaskSpiderExplo()
Error CTaskManager::StartTaskReset(Math::Vector goal, Math::Vector angle)
{
m_task = new CTaskReset(m_iMan, m_object);
return ((CTaskReset*)m_task)->Start(goal, angle);
return (static_cast<CTaskReset*>(m_task))->Start(goal, angle);
}

View File

@ -16,14 +16,11 @@
// taskmanip.cpp
#include <stdio.h>
#include "object/task/taskmanip.h"
#include "common/iman.h"
#include "old/terrain.h"
#include "old/pyro.h"
#include "graphics/engine/terrain.h"
#include "graphics/engine/pyro.h"
#include "math/geometry.h"
#include "object/robotmain.h"
#include "physics/physics.h"
@ -65,8 +62,8 @@ bool CTaskManip::EventProcess(const Event &event)
float angle, a, g, cirSpeed, progress;
int i;
if ( m_engine->RetPause() ) return true;
if ( event.event != EVENT_FRAME ) return true;
if ( m_engine->GetPause() ) return true;
if ( event.type != EVENT_FRAME ) return true;
if ( m_bError ) return false;
if ( m_bBee ) // bee?
@ -76,10 +73,10 @@ bool CTaskManip::EventProcess(const Event &event)
if ( m_bTurn ) // preliminary rotation?
{
a = m_object->RetAngleY(0);
a = m_object->GetAngleY(0);
g = m_angle;
cirSpeed = Math::Direction(a, g)*1.0f;
if ( m_physics->RetType() == TYPE_FLYING ) // flying on the ground?
if ( m_physics->GetType() == TYPE_FLYING ) // flying on the ground?
{
cirSpeed *= 4.0f; // more fishing
}
@ -107,23 +104,23 @@ bool CTaskManip::EventProcess(const Event &event)
{
if ( m_step == 0 ) // fall?
{
pos = m_object->RetPosition(1);
pos = m_object->GetPosition(1);
pos.y = 3.0f-progress*2.0f;
m_object->SetPosition(1, pos);
}
if ( m_step == 1 ) // farm?
{
pos = m_object->RetPosition(2);
pos = m_object->GetPosition(2);
pos.z = -1.5f+progress*0.5f;
m_object->SetPosition(2, pos);
pos = m_object->RetPosition(3);
pos = m_object->GetPosition(3);
pos.z = 1.5f-progress*0.5f;
m_object->SetPosition(3, pos);
}
if ( m_step == 2 ) // up?
{
pos = m_object->RetPosition(1);
pos = m_object->GetPosition(1);
pos.y = 3.0f-(1.0f-progress)*2.0f;
m_object->SetPosition(1, pos);
}
@ -132,23 +129,23 @@ bool CTaskManip::EventProcess(const Event &event)
{
if ( m_step == 0 ) // fall?
{
pos = m_object->RetPosition(1);
pos = m_object->GetPosition(1);
pos.y = 3.0f-progress*2.0f;
m_object->SetPosition(1, pos);
}
if ( m_step == 1 ) // farm?
{
pos = m_object->RetPosition(2);
pos = m_object->GetPosition(2);
pos.z = -1.5f+(1.0f-progress)*0.5f;
m_object->SetPosition(2, pos);
pos = m_object->RetPosition(3);
pos = m_object->GetPosition(3);
pos.z = 1.5f-(1.0f-progress)*0.5f;
m_object->SetPosition(3, pos);
}
if ( m_step == 2 ) // up?
{
pos = m_object->RetPosition(1);
pos = m_object->GetPosition(1);
pos.y = 3.0f-(1.0f-progress)*2.0f;
m_object->SetPosition(1, pos);
}
@ -238,7 +235,7 @@ void CTaskManip::InitAngle()
for ( i=0 ; i<5 ; i++ )
{
m_initialAngle[i] = m_object->RetAngleZ(i+1);
m_initialAngle[i] = m_object->GetAngleZ(i+1);
}
max = 0.0f;
@ -250,10 +247,10 @@ void CTaskManip::InitAngle()
if ( m_speed > 3.0f ) m_speed = 3.0f; // piano, ma non troppo (?)
energy = 0.0f;
power = m_object->RetPower();
power = m_object->GetPower();
if ( power != 0 )
{
energy = power->RetEnergy();
energy = power->GetEnergy();
}
if ( energy == 0.0f )
@ -290,7 +287,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
{
ObjectType type;
CObject *front, *other, *power;
CPyro *pyro;
Gfx::CPyro *pyro;
float iAngle, dist, len;
float fDist, fAngle, oDist, oAngle, oHeight;
Math::Vector pos, fPos, oPos;
@ -301,7 +298,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
m_progress = 0.0f;
m_speed = 1.0f/1.5f;
iAngle = m_object->RetAngleY(0);
iAngle = m_object->GetAngleY(0);
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
oAngle = iAngle;
@ -314,12 +311,12 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
m_physics->SetMotorSpeed(Math::Vector(0.0f, 0.0f, 0.0f));
type = m_object->RetType();
type = m_object->GetType();
if ( type == OBJECT_BEE ) // bee?
{
if ( m_object->RetFret() == 0 )
if ( m_object->GetFret() == 0 )
{
if ( !m_physics->RetLand() ) return ERR_MANIP_FLY;
if ( !m_physics->GetLand() ) return ERR_MANIP_FLY;
other = SearchTakeUnderObject(m_targetPos, MARGIN_BEE);
if ( other == 0 ) return ERR_MANIP_NIL;
@ -330,19 +327,19 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
}
else
{
other = m_object->RetFret(); // other = ball
other = m_object->GetFret(); // other = ball
m_object->SetFret(0); // lick the ball
other->SetTruck(0);
pos = m_object->RetPosition(0);
pos = m_object->GetPosition(0);
pos.y -= 3.0f;
other->SetPosition(0, pos);
pos = m_object->RetPosition(0);
pos = m_object->GetPosition(0);
pos.y += 2.0f;
m_object->SetPosition(0, pos); // against the top of jump
pyro = new CPyro(m_iMan);
pyro->Create(PT_FALL, other); // the ball falls
pyro = new Gfx::CPyro(m_iMan);
pyro->Create(Gfx::PT_FALL, other); // the ball falls
}
m_bBee = true;
@ -361,13 +358,13 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
}
m_energy = 0.0f;
power = m_object->RetPower();
power = m_object->GetPower();
if ( power != 0 )
{
m_energy = power->RetEnergy();
m_energy = power->GetEnergy();
}
if ( !m_physics->RetLand() ) return ERR_MANIP_FLY;
if ( !m_physics->GetLand() ) return ERR_MANIP_FLY;
if ( type != OBJECT_MOBILEfa &&
type != OBJECT_MOBILEta &&
@ -385,7 +382,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
if ( order == TMO_AUTO )
{
if ( m_object->RetFret() == 0 )
if ( m_object->GetFret() == 0 )
{
m_order = TMO_GRAB;
}
@ -399,16 +396,16 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
m_order = order;
}
if ( m_order == TMO_GRAB && m_object->RetFret() != 0 )
if ( m_order == TMO_GRAB && m_object->GetFret() != 0 )
{
return ERR_MANIP_BUSY;
}
if ( m_order == TMO_DROP && m_object->RetFret() == 0 )
if ( m_order == TMO_DROP && m_object->GetFret() == 0 )
{
return ERR_MANIP_EMPTY;
}
//? speed = m_physics->RetMotorSpeed();
//? speed = m_physics->GetMotorSpeed();
//? if ( speed.x != 0.0f ||
//? speed.z != 0.0f ) return ERR_MANIP_MOTOR;
@ -427,7 +424,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
}
else if ( other != 0 && oDist < fDist )
{
if ( other->RetPower() == 0 ) return ERR_MANIP_NIL;
if ( other->GetPower() == 0 ) return ERR_MANIP_NIL;
m_targetPos = oPos;
m_angle = oAngle;
m_height = oHeight;
@ -451,7 +448,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
}
if ( m_arm == TMA_POWER )
{
if ( m_object->RetPower() == 0 ) return ERR_MANIP_NIL;
if ( m_object->GetPower() == 0 ) return ERR_MANIP_NIL;
}
}
@ -460,7 +457,7 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
if ( m_arm == TMA_FFRONT )
{
other = SearchOtherObject(true, oPos, oDist, oAngle, oHeight);
if ( other != 0 && other->RetPower() == 0 )
if ( other != 0 && other->GetPower() == 0 )
{
m_targetPos = oPos;
m_angle = oAngle;
@ -479,27 +476,27 @@ Error CTaskManip::Start(TaskManipOrder order, TaskManipArm arm)
}
if ( m_arm == TMA_POWER )
{
if ( m_object->RetPower() != 0 ) return ERR_MANIP_OCC;
if ( m_object->GetPower() != 0 ) return ERR_MANIP_OCC;
}
}
dist = Math::Distance(m_object->RetPosition(0), m_targetPos);
dist = Math::Distance(m_object->GetPosition(0), m_targetPos);
len = dist-TAKE_DIST;
if ( m_arm == TMA_OTHER ) len -= TAKE_DIST_OTHER;
if ( len < 0.0f ) len = 0.0f;
if ( m_arm == TMA_FBACK ) len = -len;
m_advanceLength = dist-m_physics->RetLinLength(len);
m_advanceLength = dist-m_physics->GetLinLength(len);
if ( dist <= m_advanceLength+0.2f ) m_move = 0.0f; // not necessary to advance
if ( m_energy == 0.0f ) m_move = 0.0f;
if ( m_move != 0.0f ) // forward or backward?
{
m_timeLimit = m_physics->RetLinTimeLength(fabs(len))*1.5f;
m_timeLimit = m_physics->GetLinTimeLength(fabs(len))*1.5f;
if ( m_timeLimit < 0.5f ) m_timeLimit = 0.5f;
}
if ( m_object->RetFret() == 0 ) // not carrying anything?
if ( m_object->GetFret() == 0 ) // not carrying anything?
{
m_hand = TMH_OPEN; // open clamp
}
@ -540,7 +537,7 @@ Error CTaskManip::IsEnded()
float angle, dist;
int i;
if ( m_engine->RetPause() ) return ERR_CONTINUE;
if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
if ( m_bBee ) // bee?
@ -550,7 +547,7 @@ Error CTaskManip::IsEnded()
if ( m_bTurn ) // preliminary rotation?
{
angle = m_object->RetAngleY(0);
angle = m_object->GetAngleY(0);
angle = Math::NormAngle(angle); // 0..2*Math::PI
if ( Math::TestAngle(angle, m_angle-Math::PI*0.01f, m_angle+Math::PI*0.01f) )
@ -570,7 +567,7 @@ Error CTaskManip::IsEnded()
if ( m_timeLimit <= 0.0f )
{
//OK 1.9
dist = Math::Distance(m_object->RetPosition(0), m_targetPos);
dist = Math::Distance(m_object->GetPosition(0), m_targetPos);
if ( dist <= m_advanceLength + 2.0f )
{
m_move = 0.0f; // advance ended
@ -588,7 +585,7 @@ Error CTaskManip::IsEnded()
}
}
dist = Math::Distance(m_object->RetPosition(0), m_targetPos);
dist = Math::Distance(m_object->GetPosition(0), m_targetPos);
if ( dist <= m_advanceLength )
{
m_move = 0.0f; // advance ended
@ -624,7 +621,7 @@ Error CTaskManip::IsEnded()
{
if ( m_bSubm ) m_speed = 1.0f/1.5f;
if ( !TruckTakeObject() &&
m_object->RetFret() == 0 )
m_object->GetFret() == 0 )
{
m_hand = TMH_OPEN; // reopens the clamp
m_arm = TMA_NEUTRAL;
@ -638,7 +635,7 @@ Error CTaskManip::IsEnded()
(m_fretType == OBJECT_POWER ||
m_fretType == OBJECT_ATOMIC ) )
{
m_sound->Play(SOUND_POWEROFF, m_object->RetPosition(0));
m_sound->Play(SOUND_POWEROFF, m_object->GetPosition(0));
}
m_arm = TMA_STOCK;
InitAngle();
@ -653,7 +650,7 @@ Error CTaskManip::IsEnded()
if ( m_step == 1 )
{
if ( m_bSubm ) m_speed = 1.0f/0.7f;
fret = m_object->RetFret();
fret = m_object->GetFret();
if ( TruckDeposeObject() )
{
if ( (m_arm == TMA_OTHER ||
@ -661,7 +658,7 @@ Error CTaskManip::IsEnded()
(m_fretType == OBJECT_POWER ||
m_fretType == OBJECT_ATOMIC ) )
{
m_sound->Play(SOUND_POWERON, m_object->RetPosition(0));
m_sound->Play(SOUND_POWERON, m_object->GetPosition(0));
}
if ( fret != 0 && m_fretType == OBJECT_METAL && m_arm == TMA_FFRONT )
{
@ -693,7 +690,7 @@ bool CTaskManip::Abort()
{
int i;
if ( m_object->RetFret() == 0 ) // not carrying anything?
if ( m_object->GetFret() == 0 ) // not carrying anything?
{
m_hand = TMH_OPEN; // open clamp
m_arm = TMA_NEUTRAL;
@ -729,16 +726,16 @@ CObject* CTaskManip::SearchTakeUnderObject(Math::Vector &pos, float dLimit)
float min, distance;
int i;
iPos = m_object->RetPosition(0);
iPos = m_object->GetPosition(0);
min = 1000000.0f;
pBest = 0;
for ( i=0 ; i<1000000 ; i++ )
{
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->RetType();
type = pObj->GetType();
if ( type != OBJECT_FRET &&
type != OBJECT_STONE &&
@ -754,11 +751,11 @@ CObject* CTaskManip::SearchTakeUnderObject(Math::Vector &pos, float dLimit)
type != OBJECT_KEYd &&
type != OBJECT_TNT ) continue;
if ( pObj->RetTruck() != 0 ) continue; // object transported?
if ( pObj->RetLock() ) continue;
if ( pObj->RetZoomY(0) != 1.0f ) continue;
if ( pObj->GetTruck() != 0 ) continue; // object transported?
if ( pObj->GetLock() ) continue;
if ( pObj->GetZoomY(0) != 1.0f ) continue;
oPos = pObj->RetPosition(0);
oPos = pObj->GetPosition(0);
distance = Math::Distance(oPos, iPos);
if ( distance <= dLimit &&
distance < min )
@ -769,7 +766,7 @@ CObject* CTaskManip::SearchTakeUnderObject(Math::Vector &pos, float dLimit)
}
if ( pBest != 0 )
{
pos = pBest->RetPosition(0);
pos = pBest->GetPosition(0);
}
return pBest;
}
@ -785,8 +782,8 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos,
float min, iAngle, bAngle, aLimit, dLimit, f;
int i;
iPos = m_object->RetPosition(0);
iAngle = m_object->RetAngleY(0);
iPos = m_object->GetPosition(0);
iAngle = m_object->GetAngleY(0);
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
if ( bAdvance && m_energy > 0.0f )
@ -806,10 +803,10 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos,
bAngle = 0.0f;
for ( i=0 ; i<1000000 ; i++ )
{
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->RetType();
type = pObj->GetType();
if ( type != OBJECT_FRET &&
type != OBJECT_STONE &&
@ -830,11 +827,11 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos,
type != OBJECT_SCRAP4 &&
type != OBJECT_SCRAP5 ) continue;
if ( pObj->RetTruck() != 0 ) continue; // object transported?
if ( pObj->RetLock() ) continue;
if ( pObj->RetZoomY(0) != 1.0f ) continue;
if ( pObj->GetTruck() != 0 ) continue; // object transported?
if ( pObj->GetLock() ) continue;
if ( pObj->GetZoomY(0) != 1.0f ) continue;
oPos = pObj->RetPosition(0);
oPos = pObj->GetPosition(0);
distance = fabs(Math::Distance(oPos, iPos)-TAKE_DIST);
f = 1.0f-distance/50.0f;
if ( f < 0.5f ) f = 0.5f;
@ -859,7 +856,7 @@ CObject* CTaskManip::SearchTakeFrontObject(bool bAdvance, Math::Vector &pos,
}
else
{
pos = pBest->RetPosition(0);
pos = pBest->GetPosition(0);
distance = min;
angle = bAngle;
}
@ -877,8 +874,8 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos,
float min, iAngle, bAngle, aLimit, dLimit, f;
int i;
iPos = m_object->RetPosition(0);
iAngle = m_object->RetAngleY(0)+Math::PI;
iPos = m_object->GetPosition(0);
iAngle = m_object->GetAngleY(0)+Math::PI;
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
if ( bAdvance && m_energy > 0.0f )
@ -897,10 +894,10 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos,
bAngle = 0.0f;
for ( i=0 ; i<1000000 ; i++ )
{
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->RetType();
type = pObj->GetType();
if ( type != OBJECT_FRET &&
type != OBJECT_STONE &&
@ -921,11 +918,11 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos,
type != OBJECT_SCRAP4 &&
type != OBJECT_SCRAP5 ) continue;
if ( pObj->RetTruck() != 0 ) continue; // object transported?
if ( pObj->RetLock() ) continue;
if ( pObj->RetZoomY(0) != 1.0f ) continue;
if ( pObj->GetTruck() != 0 ) continue; // object transported?
if ( pObj->GetLock() ) continue;
if ( pObj->GetZoomY(0) != 1.0f ) continue;
oPos = pObj->RetPosition(0);
oPos = pObj->GetPosition(0);
distance = fabs(Math::Distance(oPos, iPos)-TAKE_DIST);
f = 1.0f-distance/50.0f;
if ( f < 0.5f ) f = 0.5f;
@ -950,7 +947,7 @@ CObject* CTaskManip::SearchTakeBackObject(bool bAdvance, Math::Vector &pos,
}
else
{
pos = pBest->RetPosition(0);
pos = pBest->GetPosition(0);
distance = min;
angle = bAngle;
}
@ -978,7 +975,7 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos,
if ( m_bSubm ) return 0; // impossible with the submarine
if ( !m_object->GetCrashSphere(0, iPos, iRad) ) return 0;
iAngle = m_object->RetAngleY(0);
iAngle = m_object->GetAngleY(0);
iAngle = Math::NormAngle(iAngle); // 0..2*Math::PI
if ( bAdvance && m_energy > 0.0f )
@ -994,12 +991,12 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos,
for ( i=0 ; i<1000000 ; i++ )
{
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue; // yourself?
type = pObj->RetType();
type = pObj->GetType();
if ( type != OBJECT_MOBILEfa &&
type != OBJECT_MOBILEta &&
type != OBJECT_MOBILEwa &&
@ -1032,22 +1029,22 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos,
type != OBJECT_LABO &&
type != OBJECT_NUCLEAR ) continue;
pPower = pObj->RetPower();
pPower = pObj->GetPower();
if ( pPower != 0 )
{
if ( pPower->RetLock() ) continue;
if ( pPower->RetZoomY(0) != 1.0f ) continue;
if ( pPower->GetLock() ) continue;
if ( pPower->GetZoomY(0) != 1.0f ) continue;
powerType = pPower->RetType();
powerType = pPower->GetType();
if ( powerType == OBJECT_NULL ||
powerType == OBJECT_FIX ) continue;
}
mat = pObj->RetWorldMatrix(0);
character = pObj->RetCharacter();
mat = pObj->GetWorldMatrix(0);
character = pObj->GetCharacter();
oPos = Transform(*mat, character->posPower);
oAngle = pObj->RetAngleY(0);
oAngle = pObj->GetAngleY(0);
if ( type == OBJECT_TOWER ||
type == OBJECT_RESEARCH )
{
@ -1080,7 +1077,7 @@ CObject* CTaskManip::SearchOtherObject(bool bAdvance, Math::Vector &pos,
angle = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
if ( Math::TestAngle(angle, iAngle-aLimit, iAngle+aLimit) )
{
character = pObj->RetCharacter();
character = pObj->GetCharacter();
height = character->posPower.y;
pos = oPos;
return pObj;
@ -1105,12 +1102,12 @@ bool CTaskManip::TruckTakeObject()
if ( m_arm == TMA_GRAB ) // takes immediately?
{
fret = m_object->RetFret();
fret = m_object->GetFret();
if ( fret == 0 ) return false; // nothing to take?
m_fretType = fret->RetType();
m_fretType = fret->GetType();
if ( m_object->RetType() == OBJECT_HUMAN ||
m_object->RetType() == OBJECT_TECH )
if ( m_object->GetType() == OBJECT_HUMAN ||
m_object->GetType() == OBJECT_TECH )
{
fret->SetTruck(m_object);
fret->SetTruckPart(4); // takes with the hand
@ -1150,7 +1147,7 @@ bool CTaskManip::TruckTakeObject()
{
fret = SearchTakeFrontObject(false, pos, dist, angle);
if ( fret == 0 ) return false; // nothing to take?
m_fretType = fret->RetType();
m_fretType = fret->GetType();
if ( m_bSubm )
{
@ -1182,7 +1179,7 @@ bool CTaskManip::TruckTakeObject()
{
fret = SearchTakeBackObject(false, pos, dist, angle);
if ( fret == 0 ) return false; // nothing to take?
m_fretType = fret->RetType();
m_fretType = fret->GetType();
fret->SetTruck(m_object);
fret->SetTruckPart(3); // takes with the hand
@ -1198,9 +1195,9 @@ bool CTaskManip::TruckTakeObject()
if ( m_arm == TMA_POWER ) // takes battery in the back?
{
fret = m_object->RetPower();
fret = m_object->GetPower();
if ( fret == 0 ) return false; // no battery?
m_fretType = fret->RetType();
m_fretType = fret->GetType();
pos = Math::Vector(4.7f, 0.0f, 0.0f); // relative to the hand (lem4)
fret->SetPosition(0, pos);
@ -1218,9 +1215,9 @@ bool CTaskManip::TruckTakeObject()
other = SearchOtherObject(false, pos, dist, angle, m_height);
if ( other == 0 ) return false;
fret = other->RetPower();
fret = other->GetPower();
if ( fret == 0 ) return false; // the other does not have a battery?
m_fretType = fret->RetType();
m_fretType = fret->GetType();
other->SetPower(0);
fret->SetTruck(m_object);
@ -1251,15 +1248,15 @@ bool CTaskManip::TruckDeposeObject()
if ( m_arm == TMA_FFRONT ) // deposits on the ground in front?
{
fret = m_object->RetFret();
fret = m_object->GetFret();
if ( fret == 0 ) return false; // nothing transported?
m_fretType = fret->RetType();
m_fretType = fret->GetType();
mat = fret->RetWorldMatrix(0);
mat = fret->GetWorldMatrix(0);
pos = Transform(*mat, Math::Vector(0.0f, 1.0f, 0.0f));
m_terrain->MoveOnFloor(pos);
m_terrain->AdjustToFloor(pos);
fret->SetPosition(0, pos);
fret->SetAngleY(0, m_object->RetAngleY(0)+Math::PI/2.0f);
fret->SetAngleY(0, m_object->GetAngleY(0)+Math::PI/2.0f);
fret->SetAngleX(0, 0.0f);
fret->SetAngleZ(0, 0.0f);
fret->FloorAdjust(); // plate well on the ground
@ -1270,15 +1267,15 @@ bool CTaskManip::TruckDeposeObject()
if ( m_arm == TMA_FBACK ) // deposited on the ground behind?
{
fret = m_object->RetFret();
fret = m_object->GetFret();
if ( fret == 0 ) return false; // nothing transported?
m_fretType = fret->RetType();
m_fretType = fret->GetType();
mat = fret->RetWorldMatrix(0);
mat = fret->GetWorldMatrix(0);
pos = Transform(*mat, Math::Vector(0.0f, 1.0f, 0.0f));
m_terrain->MoveOnFloor(pos);
m_terrain->AdjustToFloor(pos);
fret->SetPosition(0, pos);
fret->SetAngleY(0, m_object->RetAngleY(0)+Math::PI/2.0f);
fret->SetAngleY(0, m_object->GetAngleY(0)+Math::PI/2.0f);
fret->SetAngleX(0, 0.0f);
fret->SetAngleZ(0, 0.0f);
@ -1288,16 +1285,16 @@ bool CTaskManip::TruckDeposeObject()
if ( m_arm == TMA_POWER ) // deposits battery in the back?
{
fret = m_object->RetFret();
fret = m_object->GetFret();
if ( fret == 0 ) return false; // nothing transported?
m_fretType = fret->RetType();
m_fretType = fret->GetType();
if ( m_object->RetPower() != 0 ) return false;
if ( m_object->GetPower() != 0 ) return false;
fret->SetTruck(m_object);
fret->SetTruckPart(0); // carried by the base
character = m_object->RetCharacter();
character = m_object->GetCharacter();
fret->SetPosition(0, character->posPower);
fret->SetAngleY(0, 0.0f);
fret->SetAngleX(0, 0.0f);
@ -1312,17 +1309,17 @@ bool CTaskManip::TruckDeposeObject()
other = SearchOtherObject(false, pos, dist, angle, m_height);
if ( other == 0 ) return false;
fret = other->RetPower();
fret = other->GetPower();
if ( fret != 0 ) return false; // the other already has a battery?
fret = m_object->RetFret();
fret = m_object->GetFret();
if ( fret == 0 ) return false;
m_fretType = fret->RetType();
m_fretType = fret->GetType();
other->SetPower(fret);
fret->SetTruck(other);
character = other->RetCharacter();
character = other->GetCharacter();
fret->SetPosition(0, character->posPower);
fret->SetAngleY(0, 0.0f);
fret->SetAngleX(0, 0.0f);
@ -1345,17 +1342,17 @@ bool CTaskManip::IsFreeDeposeObject(Math::Vector pos)
float oRadius;
int i, j;
mat = m_object->RetWorldMatrix(0);
mat = m_object->GetWorldMatrix(0);
iPos = Transform(*mat, pos);
for ( i=0 ; i<1000000 ; i++ )
{
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
if ( !pObj->RetActif() ) continue; // inactive?
if ( pObj->RetTruck() != 0 ) continue; // object transported?
if ( !pObj->GetActif() ) continue; // inactive?
if ( pObj->GetTruck() != 0 ) continue; // object transported?
j = 0;
while ( pObj->GetCrashSphere(j++, oPos, oRadius) )
@ -1375,7 +1372,7 @@ void CTaskManip::SoundManip(float time, float amplitude, float frequency)
{
int i;
i = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.0f, 0.3f*frequency, true);
i = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 0.0f, 0.3f*frequency, true);
m_sound->AddEnvelope(i, 0.5f*amplitude, 1.0f*frequency, 0.1f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 0.5f*amplitude, 1.0f*frequency, time-0.1f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 0.0f, 0.3f*frequency, 0.1f, SOPER_STOP);

View File

@ -16,12 +16,9 @@
// taskpen.cpp
#include <stdio.h>
#include "object/task/taskpen.h"
#include "old/particule.h"
#include "graphics/engine/particle.h"
#include "math/geometry.h"
#include "object/object.h"
@ -49,8 +46,8 @@ bool CTaskPen::EventProcess(const Event &event)
Math::Point dim;
int i;
if ( m_engine->RetPause() ) return true;
if ( event.event != EVENT_FRAME ) return true;
if ( m_engine->GetPause() ) return true;
if ( event.type != EVENT_FRAME ) return true;
if ( m_bError ) return false;
if ( m_delay == 0.0f )
@ -67,17 +64,17 @@ bool CTaskPen::EventProcess(const Event &event)
if ( m_phase == TPP_UP ) // back the pencil
{
i = AngleToRank(m_object->RetAngleY(1));
pos = m_object->RetPosition(10+i);
i = AngleToRank(m_object->GetAngleY(1));
pos = m_object->GetPosition(10+i);
pos.y = -3.2f*(1.0f-m_progress);
m_object->SetPosition(10+i, pos);
}
if ( m_phase == TPP_TURN ) // turns the carousel?
{
if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
m_lastParticule = m_time;
m_lastParticle = m_time;
pos = m_supportPos;
pos.x += (Math::Rand()-0.5f)*5.0f;
@ -87,7 +84,7 @@ bool CTaskPen::EventProcess(const Event &event)
speed.y = Math::Rand()*2.0f;
dim.x = Math::Rand()*1.5f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTISMOKE3, 4.0f);
m_particle->CreateParticle(pos, speed, dim, Gfx::PARTISMOKE3, 4.0f);
}
m_object->SetAngleY(1, m_oldAngle+(m_newAngle-m_oldAngle)*m_progress);
@ -95,9 +92,9 @@ bool CTaskPen::EventProcess(const Event &event)
if ( m_phase == TPP_DOWN ) // down the pencil?
{
if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
m_lastParticule = m_time;
m_lastParticle = m_time;
pos = m_supportPos;
pos.x += (Math::Rand()-0.5f)*5.0f;
@ -107,11 +104,11 @@ bool CTaskPen::EventProcess(const Event &event)
speed.y = Math::Rand()*5.0f;
dim.x = Math::Rand()*1.0f+1.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIVAPOR, 4.0f);
m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIVAPOR, 4.0f);
}
i = AngleToRank(m_object->RetAngleY(1));
pos = m_object->RetPosition(10+i);
i = AngleToRank(m_object->GetAngleY(1));
pos = m_object->GetPosition(10+i);
if ( m_timeDown == 0.0f )
{
pos.y = 0.0f;
@ -138,16 +135,16 @@ Error CTaskPen::Start(bool bDown, int color)
m_bError = true; // operation impossible
type = m_object->RetType();
type = m_object->GetType();
if ( type != OBJECT_MOBILEdr ) return ERR_FIRE_VEH;
m_bError = false; // ok
m_oldAngle = m_object->RetAngleY(1);
m_oldAngle = m_object->GetAngleY(1);
m_newAngle = ColorToAngle(color);
i = AngleToRank(m_oldAngle);
pos = m_object->RetPosition(10+i);
pos = m_object->GetPosition(10+i);
if ( pos.y == 0.0f ) // pencil at the top?
{
@ -167,7 +164,7 @@ Error CTaskPen::Start(bool bDown, int color)
m_timeDown = 0.0f;
}
mat = m_object->RetWorldMatrix(0);
mat = m_object->GetWorldMatrix(0);
pos = Math::Vector(-3.0f, 7.0f, 0.0f);
pos = Math::Transform(*mat, pos); // position of carousel
m_supportPos = pos;
@ -182,7 +179,7 @@ Error CTaskPen::Start(bool bDown, int color)
SoundManip(m_timeUp, 1.0f, 0.5f);
}
m_lastParticule = 0.0f;
m_lastParticle = 0.0f;
//? m_camera->StartCentering(m_object, Math::PI*0.60f, 99.9f, 5.0f, 0.5f);
@ -193,7 +190,7 @@ Error CTaskPen::Start(bool bDown, int color)
Error CTaskPen::IsEnded()
{
if ( m_engine->RetPause() ) return ERR_CONTINUE;
if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
if ( m_progress < 1.0f ) return ERR_CONTINUE;
@ -205,7 +202,7 @@ Error CTaskPen::IsEnded()
m_progress = 0.0f;
m_delay = fabs(m_oldAngle-m_newAngle)/Math::PI;
m_time = 0.0f;
m_lastParticule = 0.0f;
m_lastParticle = 0.0f;
if ( m_delay > 0.0f )
{
SoundManip(m_delay, 1.0f, 1.0f);
@ -220,7 +217,7 @@ Error CTaskPen::IsEnded()
m_progress = 0.0f;
m_delay = m_timeDown;
m_time = 0.0f;
m_lastParticule = 0.0f;
m_lastParticle = 0.0f;
return ERR_CONTINUE;
}
@ -243,7 +240,7 @@ void CTaskPen::SoundManip(float time, float amplitude, float frequency)
{
int i;
i = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.0f, 0.3f*frequency, true);
i = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 0.0f, 0.3f*frequency, true);
m_sound->AddEnvelope(i, 0.5f*amplitude, 1.0f*frequency, 0.1f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 0.5f*amplitude, 1.0f*frequency, time-0.1f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 0.0f, 0.3f*frequency, 0.1f, SOPER_STOP);
@ -257,7 +254,7 @@ int CTaskPen::AngleToRank(float angle)
//? return (int)(angle/(-45.0f*Math::PI/180.0f));
angle = -angle;
angle += (45.0f*Math::PI/180.0f)/2.0f;
return (int)(angle/(45.0f*Math::PI/180.0f));
return static_cast<int>(angle/(45.0f*Math::PI/180.0f));
}
// Converting a color to the angle of carousel of pencils.

View File

@ -57,7 +57,7 @@ protected:
float m_progress;
float m_delay;
float m_time;
float m_lastParticule;
float m_lastParticle;
Math::Vector m_supportPos;
float m_timeUp;

View File

@ -23,7 +23,7 @@
#include "math/geometry.h"
#include "common/iman.h"
#include "old/particule.h"
#include "graphics/engine/particle.h"
#include "physics/physics.h"
#include "ui/displaytext.h"
@ -58,13 +58,13 @@ bool CTaskRecover::EventProcess(const Event &event)
Math::Point dim;
float a, g, cirSpeed, angle, energy, dist, linSpeed;
if ( m_engine->RetPause() ) return true;
if ( event.event != EVENT_FRAME ) return true;
if ( m_engine->GetPause() ) return true;
if ( event.type != EVENT_FRAME ) return true;
if ( m_bError ) return false;
if ( m_phase == TRP_TURN ) // preliminary rotation?
{
a = m_object->RetAngleY(0);
a = m_object->GetAngleY(0);
g = m_angle;
cirSpeed = Math::Direction(a, g)*1.0f;
if ( cirSpeed > 1.0f ) cirSpeed = 1.0f;
@ -90,7 +90,7 @@ bool CTaskRecover::EventProcess(const Event &event)
if ( m_phase == TRP_MOVE ) // preliminary forward/backward?
{
dist = Math::Distance(m_object->RetPosition(0), m_ruin->RetPosition(0));
dist = Math::Distance(m_object->GetPosition(0), m_ruin->GetPosition(0));
linSpeed = 0.0f;
if ( dist > RECOVER_DIST ) linSpeed = 1.0f;
if ( dist < RECOVER_DIST ) linSpeed = -1.0f;
@ -100,10 +100,10 @@ bool CTaskRecover::EventProcess(const Event &event)
if ( m_phase == TRP_OPER )
{
power = m_object->RetPower();
power = m_object->GetPower();
if ( power != 0 )
{
energy = power->RetEnergy();
energy = power->GetEnergy();
power->SetEnergy(energy-ENERGY_RECOVER*event.rTime*m_speed);
}
@ -122,9 +122,9 @@ bool CTaskRecover::EventProcess(const Event &event)
m_metal->SetZoom(0, (m_progress-0.5f)/0.3f);
}
if ( m_lastParticule+m_engine->ParticuleAdapt(0.02f) <= m_time )
if ( m_lastParticle+m_engine->ParticleAdapt(0.02f) <= m_time )
{
m_lastParticule = m_time;
m_lastParticle = m_time;
pos = m_recoverPos;
pos.x += (Math::Rand()-0.5f)*8.0f*(1.0f-m_progress);
@ -135,7 +135,7 @@ bool CTaskRecover::EventProcess(const Event &event)
speed.y = Math::Rand()*15.0f;
dim.x = Math::Rand()*2.0f+1.5f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIRECOVER, 1.0f, 0.0f, 0.0f);
m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIRECOVER, 1.0f, 0.0f, 0.0f);
}
}
@ -149,9 +149,9 @@ bool CTaskRecover::EventProcess(const Event &event)
m_object->SetAngleZ(3, angle);
m_object->SetAngleZ(5, angle);
if ( m_lastParticule+m_engine->ParticuleAdapt(0.02f) <= m_time )
if ( m_lastParticle+m_engine->ParticleAdapt(0.02f) <= m_time )
{
m_lastParticule = m_time;
m_lastParticle = m_time;
pos = m_recoverPos;
pos.y -= 4.0f;
@ -160,7 +160,7 @@ bool CTaskRecover::EventProcess(const Event &event)
speed.y = Math::Rand()*15.0f;
dim.x = Math::Rand()*2.0f+1.5f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIRECOVER, 1.0f, 0.0f, 0.0f);
m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIRECOVER, 1.0f, 0.0f, 0.0f);
}
}
@ -180,17 +180,17 @@ Error CTaskRecover::Start()
ObjectType type;
m_bError = true; // operation impossible
if ( !m_physics->RetLand() ) return ERR_RECOVER_VEH;
if ( !m_physics->GetLand() ) return ERR_RECOVER_VEH;
type = m_object->RetType();
type = m_object->GetType();
if ( type != OBJECT_MOBILErr ) return ERR_RECOVER_VEH;
power = m_object->RetPower();
power = m_object->GetPower();
if ( power == 0 ) return ERR_RECOVER_ENERGY;
energy = power->RetEnergy();
if ( energy < ENERGY_RECOVER/power->RetCapacity()+0.05f ) return ERR_RECOVER_ENERGY;
energy = power->GetEnergy();
if ( energy < ENERGY_RECOVER/power->GetCapacity()+0.05f ) return ERR_RECOVER_ENERGY;
mat = m_object->RetWorldMatrix(0);
mat = m_object->GetWorldMatrix(0);
pos = Math::Vector(RECOVER_DIST, 3.3f, 0.0f);
pos = Transform(*mat, pos); // position in front
m_recoverPos = pos;
@ -199,8 +199,8 @@ Error CTaskRecover::Start()
if ( m_ruin == 0 ) return ERR_RECOVER_NULL;
m_ruin->SetLock(true); // ruin no longer usable
iPos = m_object->RetPosition(0);
oPos = m_ruin->RetPosition(0);
iPos = m_object->GetPosition(0);
oPos = m_ruin->GetPosition(0);
m_angle = Math::RotateAngle(oPos.x-iPos.x, iPos.z-oPos.z); // CW !
m_metal = 0;
@ -209,7 +209,7 @@ Error CTaskRecover::Start()
m_progress = 0.0f;
m_speed = 1.0f/1.0f;
m_time = 0.0f;
m_lastParticule = 0.0f;
m_lastParticle = 0.0f;
m_bError = false; // ok
@ -227,27 +227,27 @@ Error CTaskRecover::IsEnded()
float angle, dist, time;
int i;
if ( m_engine->RetPause() ) return ERR_CONTINUE;
if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
if ( m_phase == TRP_TURN ) // preliminary rotation?
{
angle = m_object->RetAngleY(0);
angle = m_object->GetAngleY(0);
angle = Math::NormAngle(angle); // 0..2*Math::PI
if ( Math::TestAngle(angle, m_angle-Math::PI*0.01f, m_angle+Math::PI*0.01f) )
{
m_physics->SetMotorSpeedZ(0.0f);
dist = Math::Distance(m_object->RetPosition(0), m_ruin->RetPosition(0));
dist = Math::Distance(m_object->GetPosition(0), m_ruin->GetPosition(0));
if ( dist > RECOVER_DIST )
{
time = m_physics->RetLinTimeLength(dist-RECOVER_DIST, 1.0f);
time = m_physics->GetLinTimeLength(dist-RECOVER_DIST, 1.0f);
m_speed = 1.0f/time;
}
else
{
time = m_physics->RetLinTimeLength(RECOVER_DIST-dist, -1.0f);
time = m_physics->GetLinTimeLength(RECOVER_DIST-dist, -1.0f);
m_speed = 1.0f/time;
}
m_phase = TRP_MOVE;
@ -258,19 +258,19 @@ Error CTaskRecover::IsEnded()
if ( m_phase == TRP_MOVE ) // preliminary advance?
{
dist = Math::Distance(m_object->RetPosition(0), m_ruin->RetPosition(0));
dist = Math::Distance(m_object->GetPosition(0), m_ruin->GetPosition(0));
if ( dist >= RECOVER_DIST-1.0f &&
dist <= RECOVER_DIST+1.0f )
{
m_physics->SetMotorSpeedX(0.0f);
mat = m_object->RetWorldMatrix(0);
mat = m_object->GetWorldMatrix(0);
pos = Math::Vector(RECOVER_DIST, 3.3f, 0.0f);
pos = Transform(*mat, pos); // position in front
m_recoverPos = pos;
i = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.0f, 0.9f, true);
i = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 0.0f, 0.9f, true);
m_sound->AddEnvelope(i, 1.0f, 1.5f, 0.3f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 1.0f, 1.5f, 1.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 0.0f, 0.9f, 0.3f, SOPER_STOP);
@ -310,15 +310,15 @@ Error CTaskRecover::IsEnded()
m_metal->SetLock(true); // metal not yet usable
m_metal->SetZoom(0, 0.0f);
mat = m_object->RetWorldMatrix(0);
mat = m_object->GetWorldMatrix(0);
pos = Math::Vector(RECOVER_DIST, 3.1f, 3.9f);
pos = Transform(*mat, pos);
goal = Math::Vector(RECOVER_DIST, 3.1f, -3.9f);
goal = Transform(*mat, goal);
m_particule->CreateRay(pos, goal, PARTIRAY2,
m_particle->CreateRay(pos, goal, Gfx::PARTIRAY2,
Math::Point(2.0f, 2.0f), 8.0f);
m_soundChannel = m_sound->Play(SOUND_RECOVER, m_ruin->RetPosition(0), 0.0f, 1.0f, true);
m_soundChannel = m_sound->Play(SOUND_RECOVER, m_ruin->GetPosition(0), 0.0f, 1.0f, true);
m_sound->AddEnvelope(m_soundChannel, 0.6f, 1.0f, 2.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.6f, 1.0f, 4.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(m_soundChannel, 0.0f, 0.7f, 2.0f, SOPER_STOP);
@ -338,7 +338,7 @@ Error CTaskRecover::IsEnded()
m_soundChannel = -1;
i = m_sound->Play(SOUND_MANIP, m_object->RetPosition(0), 0.0f, 0.9f, true);
i = m_sound->Play(SOUND_MANIP, m_object->GetPosition(0), 0.0f, 0.9f, true);
m_sound->AddEnvelope(i, 1.0f, 1.5f, 0.3f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 1.0f, 1.5f, 1.0f, SOPER_CONTINUE);
m_sound->AddEnvelope(i, 0.0f, 0.9f, 0.3f, SOPER_STOP);
@ -389,10 +389,10 @@ CObject* CTaskRecover::SearchRuin()
min = 100000.0f;
for ( i=0 ; i<1000000 ; i++ )
{
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
type = pObj->RetType();
type = pObj->GetType();
if ( type == OBJECT_RUINmobilew1 ||
type == OBJECT_RUINmobilew2 ||
type == OBJECT_RUINmobilet1 ||
@ -400,7 +400,7 @@ CObject* CTaskRecover::SearchRuin()
type == OBJECT_RUINmobiler1 ||
type == OBJECT_RUINmobiler2 ) // vehicle in ruin?
{
oPos = pObj->RetPosition(0);
oPos = pObj->GetPosition(0);
dist = Math::Distance(oPos, m_recoverPos);
if ( dist > 40.0f ) continue;

View File

@ -56,7 +56,7 @@ protected:
float m_speed;
float m_time;
float m_angle;
float m_lastParticule;
float m_lastParticle;
bool m_bError;
CObject* m_ruin;
CObject* m_metal;

View File

@ -16,9 +16,6 @@
// taskreset.cpp
#include <stdio.h>
#include "object/task/taskreset.h"
#include "common/iman.h"
@ -55,8 +52,8 @@ bool CTaskReset::EventProcess(const Event &event)
Math::Point dim;
float angle, duration;
if ( m_engine->RetPause() ) return true;
if ( event.event != EVENT_FRAME ) return true;
if ( m_engine->GetPause() ) return true;
if ( event.type != EVENT_FRAME ) return true;
if ( m_bError ) return false;
m_time += event.rTime;
@ -69,9 +66,9 @@ bool CTaskReset::EventProcess(const Event &event)
m_object->SetAngleY(0, angle);
m_object->SetZoom(0, 1.0f-m_progress);
if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
m_lastParticule = m_time;
m_lastParticle = m_time;
pos = m_begin;
pos.x += (Math::Rand()-0.5f)*5.0f;
@ -81,7 +78,7 @@ bool CTaskReset::EventProcess(const Event &event)
speed.y = 5.0f+Math::Rand()*5.0f;
dim.x = Math::Rand()*2.0f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIGLINTb, 2.0f);
m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINTb, 2.0f);
pos = m_begin;
speed.x = (Math::Rand()-0.5f)*20.0f;
@ -94,7 +91,7 @@ bool CTaskReset::EventProcess(const Event &event)
dim.y = dim.x;
pos.y += dim.y;
duration = Math::Rand()*1.5f+1.5f;
m_particule->CreateTrack(pos, speed, dim, PARTITRACK6,
m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK6,
duration, 0.0f,
duration*0.9f, 0.7f);
}
@ -105,9 +102,9 @@ bool CTaskReset::EventProcess(const Event &event)
pos = m_begin+(m_goal-m_begin)*m_progress;
m_object->SetPosition(0, pos);
if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
m_lastParticule = m_time;
m_lastParticle = m_time;
pos.x += (Math::Rand()-0.5f)*5.0f;
pos.z += (Math::Rand()-0.5f)*5.0f;
@ -116,7 +113,7 @@ bool CTaskReset::EventProcess(const Event &event)
speed.y = 2.0f+Math::Rand()*2.0f;
dim.x = Math::Rand()*2.0f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIGLINTb, 2.0f);
m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINTb, 2.0f);
}
}
@ -127,9 +124,9 @@ bool CTaskReset::EventProcess(const Event &event)
m_object->SetAngleY(0, angle);
m_object->SetZoom(0, m_progress);
if ( m_lastParticule+m_engine->ParticuleAdapt(0.05f) <= m_time )
if ( m_lastParticle+m_engine->ParticleAdapt(0.05f) <= m_time )
{
m_lastParticule = m_time;
m_lastParticle = m_time;
pos = m_goal;
pos.x += (Math::Rand()-0.5f)*5.0f;
@ -139,7 +136,7 @@ bool CTaskReset::EventProcess(const Event &event)
speed.y = 5.0f+Math::Rand()*5.0f;
dim.x = Math::Rand()*2.0f+2.0f;
dim.y = dim.x;
m_particule->CreateParticule(pos, speed, dim, PARTIGLINTb, 2.0f);
m_particle->CreateParticle(pos, speed, dim, Gfx::PARTIGLINTb, 2.0f);
pos = m_goal;
speed.x = (Math::Rand()-0.5f)*20.0f;
@ -150,7 +147,7 @@ bool CTaskReset::EventProcess(const Event &event)
dim.y = dim.x;
pos.y += dim.y;
duration = Math::Rand()*1.5f+1.5f;
m_particule->CreateTrack(pos, speed, dim, PARTITRACK6,
m_particle->CreateTrack(pos, speed, dim, Gfx::PARTITRACK6,
duration, 0.0f,
duration*0.9f, 0.7f);
}
@ -168,24 +165,24 @@ Error CTaskReset::Start(Math::Vector goal, Math::Vector angle)
CObject* fret;
int i;
fret = m_object->RetFret();
if ( fret != 0 && fret->RetResetCap() == RESET_MOVE )
fret = m_object->GetFret();
if ( fret != 0 && fret->GetResetCap() == RESET_MOVE )
{
fret->SetTruck(0);
m_object->SetFret(0); // does nothing
}
if ( !m_main->RetNiceReset() ) // quick return?
if ( !m_main->GetNiceReset() ) // quick return?
{
m_object->SetPosition(0, goal);
m_object->SetAngle(0, angle);
m_brain->RunProgram(m_object->RetResetRun());
m_brain->RunProgram(m_object->GetResetRun());
m_bError = false;
return ERR_OK;
}
m_begin = m_object->RetPosition(0);
m_begin = m_object->GetPosition(0);
m_goal = goal;
m_angle = angle;
@ -195,12 +192,12 @@ Error CTaskReset::Start(Math::Vector goal, Math::Vector angle)
return ERR_RESET_NEAR;
}
m_iAngle = m_object->RetAngleY(0);
m_iAngle = m_object->GetAngleY(0);
m_time = 0.0f;
m_phase = TRSP_ZOUT;
m_speed = 1.0f/RESET_DELAY_ZOOM;
m_progress = 0.0f;
m_lastParticule = 0.0f;
m_lastParticle = 0.0f;
m_object->SetResetBusy(true);
@ -219,12 +216,12 @@ Error CTaskReset::IsEnded()
float dist;
int i;
if ( !m_main->RetNiceReset() ) // quick return?
if ( !m_main->GetNiceReset() ) // quick return?
{
return ERR_STOP;
}
if ( m_engine->RetPause() ) return ERR_CONTINUE;
if ( m_engine->GetPause() ) return ERR_CONTINUE;
if ( m_bError ) return ERR_STOP;
if ( m_progress < 1.0f ) return ERR_CONTINUE;
@ -254,13 +251,13 @@ Error CTaskReset::IsEnded()
m_object->SetAngle(0, m_angle);
m_object->SetZoom(0, 1.0f);
power = m_object->RetPower();
power = m_object->GetPower();
if ( power != 0 )
{
power->SetEnergy(power->RetCapacity()); // refueling
power->SetEnergy(power->GetCapacity()); // refueling
}
m_brain->RunProgram(m_object->RetResetRun());
m_brain->RunProgram(m_object->GetResetRun());
m_object->SetResetBusy(false);
return ERR_STOP;
}
@ -278,12 +275,12 @@ bool CTaskReset::SearchVehicle()
for ( i=0 ; i<1000000 ; i++ )
{
pObj = (CObject*)m_iMan->SearchInstance(CLASS_OBJECT, i);
pObj = static_cast<CObject*>(m_iMan->SearchInstance(CLASS_OBJECT, i));
if ( pObj == 0 ) break;
if ( pObj == m_object ) continue;
type = pObj->RetType();
type = pObj->GetType();
if ( type != OBJECT_HUMAN &&
type != OBJECT_TECH &&
type != OBJECT_MOBILEfa &&

View File

@ -57,7 +57,7 @@ protected:
float m_time;
float m_speed;
float m_progress;
float m_lastParticule; // time of generation last particle
float m_lastParticle; // time of generation last particle
float m_iAngle;
};

View File

@ -16,14 +16,11 @@
// tasktake.cpp
#include <stdio.h>
#include "object/task/tasktake.h"
#include "common/iman.h"
#include "old/terrain.h"
#include "old/water.h"
#include "graphics/engine/terrain.h"
#include "graphics/engine/water.h"
#include "math/geometry.h"
#include "object/motion/motionhuman.h"
#include "object/robotmain.h"

View File

@ -59,7 +59,8 @@ protected:
bool IsFreeDeposeObject(Math::Vector pos);
protected:
CTerrain* m_terrain;
//TODO this is same member as in base class, probable should be deleted
Gfx::CTerrain* m_terrain;
TaskTakeOrder m_order;
TaskTakeArm m_arm;