CFlyingObject; CJetFlyingObject
parent
1b73830f28
commit
5d52214737
|
@ -655,7 +655,6 @@ bool CAutoFactory::CreateVehicle()
|
|||
CObject* vehicle = CObjectManager::GetInstancePointer()->CreateObject(params);
|
||||
|
||||
vehicle->SetLock(true); // not usable
|
||||
vehicle->SetRange(30.0f);
|
||||
|
||||
CPhysics* physics = vehicle->GetPhysics();
|
||||
if ( physics != nullptr )
|
||||
|
|
|
@ -52,8 +52,7 @@ CProgrammableObjectImpl::CProgrammableObjectImpl(ObjectInterfaceTypes& types, CO
|
|||
, m_soluceName("")
|
||||
, m_traceRecord(false)
|
||||
{
|
||||
assert(m_object != nullptr);
|
||||
assert(m_object->Implements(ObjectInterfaceType::TaskExecutor));
|
||||
//assert(m_object->Implements(ObjectInterfaceType::TaskExecutor));
|
||||
}
|
||||
|
||||
CProgrammableObjectImpl::~CProgrammableObjectImpl()
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* 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 3 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, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "object/object_interface_type.h"
|
||||
|
||||
#include "object/interface/movable_object.h"
|
||||
|
||||
/**
|
||||
* \class CFlyingObject
|
||||
* \brief Interface for objects that can fly
|
||||
*/
|
||||
class CFlyingObject : CMovableObject
|
||||
{
|
||||
public:
|
||||
explicit CFlyingObject(ObjectInterfaceTypes& types)
|
||||
: CMovableObject(types)
|
||||
{
|
||||
types[static_cast<int>(ObjectInterfaceType::Flying)] = true;
|
||||
}
|
||||
virtual ~CFlyingObject()
|
||||
{}
|
||||
};
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* This file is part of the Colobot: Gold Edition source code
|
||||
* Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
|
||||
* http://epsiteс.ch; http://colobot.info; http://github.com/colobot
|
||||
*
|
||||
* 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 3 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, see http://gnu.org/licenses
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "object/object_interface_type.h"
|
||||
|
||||
#include "object/interface/flying_object.h"
|
||||
|
||||
/**
|
||||
* \class CJetFlyingObject
|
||||
* \brief Interface for objects that can fly using a jet engine
|
||||
*/
|
||||
class CJetFlyingObject : CFlyingObject
|
||||
{
|
||||
public:
|
||||
explicit CJetFlyingObject(ObjectInterfaceTypes& types)
|
||||
: CFlyingObject(types)
|
||||
{
|
||||
types[static_cast<int>(ObjectInterfaceType::JetFlying)] = true;
|
||||
}
|
||||
virtual ~CJetFlyingObject()
|
||||
{}
|
||||
|
||||
//! Sets jet engine heating speed (bigger = slower, 0 for infinite)
|
||||
virtual void SetRange(float range) = 0;
|
||||
//! Returns jet engine heating speed (bigger = slower, 0 for infinite)
|
||||
virtual float GetRange() = 0;
|
||||
};
|
|
@ -330,8 +330,6 @@ void CMotionAnt::CreatePhysics()
|
|||
-35,35,0, -25,40,0, -40,65,0, // s7: feet 1..3
|
||||
};
|
||||
|
||||
m_physics->SetType(TYPE_ROLLING);
|
||||
|
||||
character = m_object->GetCharacter();
|
||||
character->wheelFront = 3.0f;
|
||||
character->wheelBack = 3.0f;
|
||||
|
|
|
@ -310,8 +310,6 @@ void CMotionBee::CreatePhysics()
|
|||
-110,75,-15, -130,80,-25, -125,40,0, // s2: feet 1..3
|
||||
};
|
||||
|
||||
m_physics->SetType(TYPE_FLYING);
|
||||
|
||||
character = m_object->GetCharacter();
|
||||
character->wheelFront = 3.0f;
|
||||
character->wheelBack = 3.0f;
|
||||
|
|
|
@ -501,8 +501,6 @@ void CMotionHuman::CreatePhysics(ObjectType type)
|
|||
0,20,0, -10,5,5, 0,0,0, // s15: hands/feet/-
|
||||
};
|
||||
|
||||
m_physics->SetType(TYPE_FLYING);
|
||||
|
||||
character = m_object->GetCharacter();
|
||||
character->wheelFront = 4.0f;
|
||||
character->wheelBack = 4.0f;
|
||||
|
|
|
@ -59,8 +59,6 @@ void CMotionLevelController::Create(Math::Vector pos, float angle, ObjectType ty
|
|||
m_object->SetObjectRank(0, rank);
|
||||
|
||||
// Movement
|
||||
m_physics->SetType(TYPE_FLYING);
|
||||
|
||||
m_physics->SetLinMotionX(MO_ADVSPEED, 50.0f);
|
||||
m_physics->SetLinMotionX(MO_RECSPEED, 50.0f);
|
||||
m_physics->SetLinMotionX(MO_ADVACCEL, 20.0f);
|
||||
|
@ -83,4 +81,3 @@ void CMotionLevelController::Create(Math::Vector pos, float angle, ObjectType ty
|
|||
m_physics->SetCirMotionY(MO_RECACCEL, 2.0f);
|
||||
m_physics->SetCirMotionY(MO_STOACCEL, 2.0f);
|
||||
}
|
||||
|
||||
|
|
|
@ -270,8 +270,6 @@ void CMotionQueen::CreatePhysics()
|
|||
0,0,0, 0,0,0, 0,0,0, // t2: unused
|
||||
};
|
||||
|
||||
m_physics->SetType(TYPE_ROLLING);
|
||||
|
||||
character = m_object->GetCharacter();
|
||||
character->wheelFront = 10.0f;
|
||||
character->wheelBack = 10.0f;
|
||||
|
|
|
@ -265,8 +265,6 @@ void CMotionSpider::CreatePhysics()
|
|||
-5,0,0, -5,0,0, -5,0,0, -5,0,0, // s5: fingers 1..4
|
||||
};
|
||||
|
||||
m_physics->SetType(TYPE_ROLLING);
|
||||
|
||||
character = m_object->GetCharacter();
|
||||
character->wheelFront = 4.0f;
|
||||
character->wheelBack = 4.0f;
|
||||
|
|
|
@ -968,8 +968,6 @@ void CMotionVehicle::CreatePhysics(ObjectType type)
|
|||
type == OBJECT_MOBILEws ||
|
||||
type == OBJECT_MOBILEwt ) // wheels?
|
||||
{
|
||||
m_physics->SetType(TYPE_ROLLING);
|
||||
|
||||
character->wheelFront = 3.0f;
|
||||
character->wheelBack = 4.0f;
|
||||
character->wheelLeft = 4.0f;
|
||||
|
@ -996,8 +994,6 @@ void CMotionVehicle::CreatePhysics(ObjectType type)
|
|||
|
||||
if ( type == OBJECT_MOBILEtg )
|
||||
{
|
||||
m_physics->SetType(TYPE_ROLLING);
|
||||
|
||||
character->wheelFront = 4.0f;
|
||||
character->wheelBack = 3.0f;
|
||||
character->wheelLeft = 4.0f;
|
||||
|
@ -1027,8 +1023,6 @@ void CMotionVehicle::CreatePhysics(ObjectType type)
|
|||
type == OBJECT_MOBILEti ||
|
||||
type == OBJECT_MOBILEts ) // caterpillars?
|
||||
{
|
||||
m_physics->SetType(TYPE_ROLLING);
|
||||
|
||||
character->wheelFront = 4.0f;
|
||||
character->wheelBack = 4.0f;
|
||||
character->wheelLeft = 4.8f;
|
||||
|
@ -1058,8 +1052,6 @@ void CMotionVehicle::CreatePhysics(ObjectType type)
|
|||
type == OBJECT_MOBILEii ||
|
||||
type == OBJECT_MOBILEis ) // legs?
|
||||
{
|
||||
m_physics->SetType(TYPE_ROLLING);
|
||||
|
||||
character->wheelFront = 4.0f;
|
||||
character->wheelBack = 4.0f;
|
||||
character->wheelLeft = 5.0f;
|
||||
|
@ -1091,8 +1083,6 @@ void CMotionVehicle::CreatePhysics(ObjectType type)
|
|||
type == OBJECT_MOBILEfs ||
|
||||
type == OBJECT_MOBILEft ) // flying?
|
||||
{
|
||||
m_physics->SetType(TYPE_FLYING);
|
||||
|
||||
character->wheelFront = 5.0f;
|
||||
character->wheelBack = 4.0f;
|
||||
character->wheelLeft = 4.5f;
|
||||
|
@ -1127,8 +1117,6 @@ void CMotionVehicle::CreatePhysics(ObjectType type)
|
|||
type == OBJECT_MOBILErr ||
|
||||
type == OBJECT_MOBILErs ) // large caterpillars?
|
||||
{
|
||||
m_physics->SetType(TYPE_ROLLING);
|
||||
|
||||
character->wheelFront = 5.0f;
|
||||
character->wheelBack = 5.0f;
|
||||
character->wheelLeft = 6.0f;
|
||||
|
@ -1155,8 +1143,6 @@ void CMotionVehicle::CreatePhysics(ObjectType type)
|
|||
|
||||
if ( type == OBJECT_MOBILEsa )
|
||||
{
|
||||
m_physics->SetType(TYPE_ROLLING);
|
||||
|
||||
character->wheelFront = 4.0f;
|
||||
character->wheelBack = 4.0f;
|
||||
character->wheelLeft = 4.0f;
|
||||
|
@ -1183,8 +1169,6 @@ void CMotionVehicle::CreatePhysics(ObjectType type)
|
|||
|
||||
if ( type == OBJECT_MOBILEdr )
|
||||
{
|
||||
m_physics->SetType(TYPE_ROLLING);
|
||||
|
||||
character->wheelFront = 4.0f;
|
||||
character->wheelBack = 4.0f;
|
||||
character->wheelLeft = 4.0f;
|
||||
|
@ -1211,8 +1195,6 @@ void CMotionVehicle::CreatePhysics(ObjectType type)
|
|||
|
||||
if ( type == OBJECT_APOLLO2 ) // jeep?
|
||||
{
|
||||
m_physics->SetType(TYPE_ROLLING);
|
||||
|
||||
character->wheelFront = 6.0f;
|
||||
character->wheelBack = 6.0f;
|
||||
character->wheelLeft = 5.0f;
|
||||
|
|
|
@ -150,8 +150,6 @@ void CMotionWorm::CreatePhysics()
|
|||
{
|
||||
Character* character;
|
||||
|
||||
m_physics->SetType(TYPE_ROLLING);
|
||||
|
||||
character = m_object->GetCharacter();
|
||||
character->wheelFront = 10.0f;
|
||||
character->wheelBack = 10.0f;
|
||||
|
@ -356,4 +354,3 @@ bool CMotionWorm::EventFrame(const Event &event)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@ enum class ObjectInterfaceType
|
|||
Carrier, //!< object that can carry other objects
|
||||
Powered, //!< object powered with power cell
|
||||
Movable, //!< objects that can move
|
||||
Flying, //!< objects that can fly
|
||||
JetFlying, //!< objects that can fly using a jet engine
|
||||
Controllable, //!< objects that can be selected and controlled by the player
|
||||
PowerContainer, //!< objects that hold power
|
||||
Ranged, //!< objects that have a operation range to be displayed after pressing button in the UI
|
||||
|
|
|
@ -82,7 +82,7 @@ COldObject::COldObject(int id)
|
|||
, CJostleableObject(m_implementedInterfaces)
|
||||
, CCarrierObject(m_implementedInterfaces)
|
||||
, CPoweredObject(m_implementedInterfaces)
|
||||
, CMovableObject(m_implementedInterfaces)
|
||||
, CJetFlyingObject(m_implementedInterfaces)
|
||||
, CControllableObject(m_implementedInterfaces)
|
||||
, CPowerContainerObjectImpl(m_implementedInterfaces, this)
|
||||
, CRangedObject(m_implementedInterfaces)
|
||||
|
@ -116,7 +116,7 @@ COldObject::COldObject(int id)
|
|||
m_transporter = 0;
|
||||
m_transporterLink = 0;
|
||||
m_shield = 1.0f;
|
||||
m_range = 0.0f;
|
||||
m_range = 30.0f;
|
||||
m_transparency = 0.0f;
|
||||
m_lastEnergy = 999.9f;
|
||||
m_bSelect = false;
|
||||
|
@ -658,6 +658,48 @@ void COldObject::SetType(ObjectType type)
|
|||
m_param = 1.0f; // shield up to default
|
||||
}
|
||||
|
||||
// TODO: Temporary hack
|
||||
if ( m_type == OBJECT_MOBILEfa || // WingedGrabber
|
||||
m_type == OBJECT_MOBILEfs || // WingedSniffer
|
||||
m_type == OBJECT_MOBILEfc || // WingedShooter
|
||||
m_type == OBJECT_MOBILEfi || // WingedOrgaShooter
|
||||
m_type == OBJECT_MOBILEft || // winged PracticeBot (unused)
|
||||
m_type == OBJECT_HUMAN || // Me
|
||||
m_type == OBJECT_TECH ) // Tech
|
||||
{
|
||||
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::Flying)] = true;
|
||||
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::JetFlying)] = true;
|
||||
}
|
||||
else if ( m_type == OBJECT_BEE )
|
||||
{
|
||||
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::Flying)] = true;
|
||||
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::JetFlying)] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::Flying)] = false;
|
||||
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::JetFlying)] = false;
|
||||
}
|
||||
|
||||
// TODO: Another temporary hack
|
||||
if ( m_type == OBJECT_MOTHER ||
|
||||
m_type == OBJECT_ANT ||
|
||||
m_type == OBJECT_SPIDER ||
|
||||
m_type == OBJECT_BEE ||
|
||||
m_type == OBJECT_WORM ||
|
||||
m_type == OBJECT_APOLLO2 ||
|
||||
m_type == OBJECT_MOBILEdr ||
|
||||
m_type == OBJECT_CONTROLLER ||
|
||||
m_type == OBJECT_HUMAN ||
|
||||
m_type == OBJECT_TECH )
|
||||
{
|
||||
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::Powered)] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::Powered)] = true;
|
||||
}
|
||||
|
||||
if ( m_type == OBJECT_MOBILEwc ||
|
||||
m_type == OBJECT_MOBILEtc ||
|
||||
m_type == OBJECT_MOBILEfc ||
|
||||
|
@ -805,7 +847,6 @@ void COldObject::Read(CLevelParserLine* line)
|
|||
SetCameraLock(line->GetParam("cameraLock")->AsBool(false));
|
||||
SetEnergyLevel(line->GetParam("energy")->AsFloat(0.0f));
|
||||
SetShield(line->GetParam("shield")->AsFloat(1.0f));
|
||||
SetRange(line->GetParam("range")->AsFloat(1.0f));
|
||||
SetSelectable(line->GetParam("selectable")->AsBool(true));
|
||||
SetFixed(line->GetParam("fixed")->AsBool(false));
|
||||
SetCollisions(line->GetParam("clip")->AsBool(true));
|
||||
|
@ -1060,7 +1101,7 @@ void COldObject::SetPartPosition(int part, const Math::Vector &pos)
|
|||
m_engine->SetObjectShadowPos(rank, shPos);
|
||||
|
||||
float height = 0.0f;
|
||||
if ( m_physics != nullptr && m_physics->GetType() == TYPE_FLYING )
|
||||
if ( Implements(ObjectInterfaceType::Flying) )
|
||||
{
|
||||
height = pos.y-shPos.y;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,9 @@
|
|||
|
||||
#include "object/interface/carrier_object.h"
|
||||
#include "object/interface/controllable_object.h"
|
||||
#include "object/interface/flying_object.h"
|
||||
#include "object/interface/interactive_object.h"
|
||||
#include "object/interface/jet_flying_object.h"
|
||||
#include "object/interface/jostleable_object.h"
|
||||
#include "object/interface/movable_object.h"
|
||||
#include "object/interface/power_container_object.h"
|
||||
|
@ -77,7 +79,7 @@ class COldObject : public CObject,
|
|||
public CJostleableObject,
|
||||
public CCarrierObject,
|
||||
public CPoweredObject,
|
||||
public CMovableObject,
|
||||
public CJetFlyingObject,
|
||||
public CControllableObject,
|
||||
public CPowerContainerObjectImpl,
|
||||
public CRangedObject
|
||||
|
|
|
@ -115,16 +115,6 @@ float COldObjectInterface::GetShield()
|
|||
}
|
||||
|
||||
|
||||
void COldObjectInterface::SetRange(float delay)
|
||||
{
|
||||
throw std::logic_error("SetRange: not implemented!");
|
||||
}
|
||||
|
||||
float COldObjectInterface::GetRange()
|
||||
{
|
||||
throw std::logic_error("GetRange: not implemented!");
|
||||
}
|
||||
|
||||
void COldObjectInterface::SetFixed(bool bFixed)
|
||||
{
|
||||
throw std::logic_error("SetFixed: not implemented!");
|
||||
|
|
|
@ -99,10 +99,6 @@ public:
|
|||
virtual void SetMagnifyDamage(float factor);
|
||||
virtual float GetMagnifyDamage();
|
||||
|
||||
// This goes to CFlyingObject (child of CMovableObject)
|
||||
virtual void SetRange(float delay);
|
||||
virtual float GetRange();
|
||||
|
||||
// This goes to CBaseAlien or something like that
|
||||
virtual void SetFixed(bool bFixed);
|
||||
virtual bool GetFixed();
|
||||
|
|
|
@ -1208,8 +1208,8 @@ void CRobotMain::ExecuteCmd(char *cmd)
|
|||
if (strcmp(cmd, "addfreezer") == 0)
|
||||
{
|
||||
CObject* object = GetSelect();
|
||||
if (object != nullptr)
|
||||
object->SetRange(object->GetRange()*10.0f);
|
||||
if (object != nullptr && object->Implements(ObjectInterfaceType::JetFlying))
|
||||
dynamic_cast<CJetFlyingObject*>(object)->SetRange(dynamic_cast<CJetFlyingObject*>(object)->GetRange()*10.0f);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ bool CTaskGoto::EventProcess(const Event &event)
|
|||
|
||||
pos = m_object->GetPosition();
|
||||
|
||||
if ( m_physics->GetType() == TYPE_FLYING && m_altitude == 0.0f )
|
||||
if ( m_object->Implements(ObjectInterfaceType::Flying) && m_altitude == 0.0f )
|
||||
{
|
||||
if ( m_physics->GetLand() )
|
||||
{
|
||||
|
@ -206,7 +206,7 @@ bool CTaskGoto::EventProcess(const Event &event)
|
|||
}
|
||||
}
|
||||
|
||||
if ( m_physics->GetType() == TYPE_FLYING && m_altitude > 0.0f )
|
||||
if ( m_object->Implements(ObjectInterfaceType::Flying) && m_altitude > 0.0f )
|
||||
{
|
||||
goal = m_bmPoints[m_bmIndex];
|
||||
goal.y = pos.y;
|
||||
|
@ -345,7 +345,7 @@ bool CTaskGoto::EventProcess(const Event &event)
|
|||
}
|
||||
|
||||
if ( m_phase != TGP_TURN &&
|
||||
m_physics->GetType() == TYPE_FLYING &&
|
||||
m_object->Implements(ObjectInterfaceType::Flying) &&
|
||||
m_altitude > 0.0f )
|
||||
{
|
||||
pos = m_object->GetPosition();
|
||||
|
@ -395,7 +395,7 @@ bool CTaskGoto::EventProcess(const Event &event)
|
|||
a = m_object->GetRotationY();
|
||||
g = Math::RotateAngle(rot.x, -rot.y); // CW !
|
||||
cirSpeed = Math::Direction(a, g)*1.0f;
|
||||
//? if ( m_physics->GetType() == TYPE_FLYING &&
|
||||
//? if ( m_object->Implements(ObjectInterfaceType::Flying) &&
|
||||
//? m_physics->GetLand() ) // flying on the ground?
|
||||
//? {
|
||||
//? cirSpeed *= 4.0f; // more fishing
|
||||
|
@ -405,7 +405,7 @@ bool CTaskGoto::EventProcess(const Event &event)
|
|||
|
||||
dist = Math::DistanceProjected(m_goal, pos);
|
||||
linSpeed = dist/(m_physics->GetLinStopLength()*1.5f);
|
||||
//? if ( m_physics->GetType() == TYPE_FLYING &&
|
||||
//? if ( m_object->Implements(ObjectInterfaceType::Flying) &&
|
||||
//? m_physics->GetLand() ) // flying on the ground?
|
||||
//? {
|
||||
//? linSpeed *= 8.0f; // more fishing
|
||||
|
@ -708,7 +708,7 @@ Error CTaskGoto::Start(Math::Vector goal, float altitude,
|
|||
m_bTake = true; // object was taken on arrival (final rotation)
|
||||
}
|
||||
|
||||
if ( m_physics->GetType() == TYPE_FLYING && m_altitude == 0.0f )
|
||||
if ( m_object->Implements(ObjectInterfaceType::Flying) && m_altitude == 0.0f )
|
||||
{
|
||||
pos = m_object->GetPosition();
|
||||
dist = Math::DistanceProjected(pos, m_goal);
|
||||
|
@ -773,7 +773,7 @@ Error CTaskGoto::IsEnded()
|
|||
|
||||
if ( m_phase == TGP_BEAMUP ) // off?
|
||||
{
|
||||
if ( m_physics->GetType() == TYPE_FLYING && m_altitude > 0.0f )
|
||||
if ( m_object->Implements(ObjectInterfaceType::Flying) && m_altitude > 0.0f )
|
||||
{
|
||||
level = m_terrain->GetFloorLevel(pos, true, true);
|
||||
h = level+m_altitude-20.0f;
|
||||
|
@ -826,7 +826,7 @@ Error CTaskGoto::IsEnded()
|
|||
|
||||
if ( m_phase == TGP_BEAMDOWN ) // landed?
|
||||
{
|
||||
if ( m_physics->GetType() == TYPE_FLYING && m_altitude > 0.0f )
|
||||
if ( m_object->Implements(ObjectInterfaceType::Flying) && m_altitude > 0.0f )
|
||||
{
|
||||
if ( !m_physics->GetLand() ) return ERR_CONTINUE;
|
||||
m_physics->SetMotorSpeedY(0.0f); // stops the descent
|
||||
|
@ -877,7 +877,7 @@ Error CTaskGoto::IsEnded()
|
|||
|
||||
if ( m_phase == TGP_LAND ) // landed?
|
||||
{
|
||||
if ( m_physics->GetType() == TYPE_FLYING && m_altitude > 0.0f )
|
||||
if ( m_object->Implements(ObjectInterfaceType::Flying) && m_altitude > 0.0f )
|
||||
{
|
||||
if ( !m_physics->GetLand() ) return ERR_CONTINUE;
|
||||
m_physics->SetMotorSpeedY(0.0f);
|
||||
|
@ -1259,7 +1259,7 @@ bool CTaskGoto::GetHotPoint(CObject *pObj, Math::Vector &pos,
|
|||
return true;
|
||||
}
|
||||
|
||||
if ( type == OBJECT_PARA && m_physics->GetType() == TYPE_FLYING )
|
||||
if ( type == OBJECT_PARA && m_object->Implements(ObjectInterfaceType::Flying) )
|
||||
{
|
||||
mat = pObj->GetWorldMatrix(0);
|
||||
if ( bTake && distance != 0.0f ) suppl = 20.0f;
|
||||
|
@ -1818,7 +1818,7 @@ void CTaskGoto::BitmapObject()
|
|||
if (IsObjectBeingTransported(pObj)) continue;
|
||||
|
||||
float h = m_terrain->GetFloorLevel(pObj->GetPosition(), false);
|
||||
if ( m_physics->GetType() == TYPE_FLYING && m_altitude > 0.0f )
|
||||
if ( m_object->Implements(ObjectInterfaceType::Flying) && m_altitude > 0.0f )
|
||||
{
|
||||
h += m_altitude;
|
||||
}
|
||||
|
@ -1828,7 +1828,7 @@ void CTaskGoto::BitmapObject()
|
|||
Math::Vector oPos = crashSphere.sphere.pos;
|
||||
float oRadius = crashSphere.sphere.radius;
|
||||
|
||||
if ( m_physics->GetType() == TYPE_FLYING && m_altitude > 0.0f ) // flying?
|
||||
if ( m_object->Implements(ObjectInterfaceType::Flying) && m_altitude > 0.0f ) // flying?
|
||||
{
|
||||
if ( oPos.y-oRadius > h+8.0f ||
|
||||
oPos.y+oRadius < h-8.0f ) continue;
|
||||
|
|
|
@ -88,7 +88,7 @@ bool CTaskManip::EventProcess(const Event &event)
|
|||
a = m_object->GetRotationY();
|
||||
g = m_angle;
|
||||
cirSpeed = Math::Direction(a, g)*1.0f;
|
||||
if ( m_physics->GetType() == TYPE_FLYING ) // flying on the ground?
|
||||
if ( m_object->Implements(ObjectInterfaceType::Flying) ) // flying on the ground?
|
||||
{
|
||||
cirSpeed *= 4.0f; // more fishing
|
||||
}
|
||||
|
|
|
@ -76,7 +76,6 @@ CPhysics::CPhysics(COldObject* object)
|
|||
m_sound = CApplication::GetInstancePointer()->GetSound();
|
||||
m_motion = nullptr;
|
||||
|
||||
m_type = TYPE_ROLLING;
|
||||
m_gravity = 9.81f; // default gravity
|
||||
m_time = 0.0f;
|
||||
m_timeUnderWater = 0.0f;
|
||||
|
@ -154,19 +153,6 @@ void CPhysics::SetMotion(CMotion* motion)
|
|||
m_motion = motion;
|
||||
}
|
||||
|
||||
// Management of the type.
|
||||
|
||||
void CPhysics::SetType(PhysicsType type)
|
||||
{
|
||||
m_type = type;
|
||||
}
|
||||
|
||||
PhysicsType CPhysics::GetType()
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Saves all parameters of the object.
|
||||
|
||||
|
@ -174,9 +160,12 @@ bool CPhysics::Write(CLevelParserLine* line)
|
|||
{
|
||||
line->AddParam("motor", MakeUnique<CLevelParserParam>(m_motorSpeed));
|
||||
|
||||
if ( m_type == TYPE_FLYING )
|
||||
if ( m_object->Implements(ObjectInterfaceType::Flying) )
|
||||
{
|
||||
line->AddParam("reactorRange", MakeUnique<CLevelParserParam>(GetReactorRange()));
|
||||
if ( m_object->Implements(ObjectInterfaceType::JetFlying) )
|
||||
{
|
||||
line->AddParam("reactorRange", MakeUnique<CLevelParserParam>(GetReactorRange()));
|
||||
}
|
||||
line->AddParam("land", MakeUnique<CLevelParserParam>(GetLand()));
|
||||
}
|
||||
|
||||
|
@ -189,9 +178,12 @@ bool CPhysics::Read(CLevelParserLine* line)
|
|||
{
|
||||
m_motorSpeed = line->GetParam("motor")->AsPoint();
|
||||
|
||||
if ( m_type == TYPE_FLYING )
|
||||
if ( m_object->Implements(ObjectInterfaceType::Flying) )
|
||||
{
|
||||
SetReactorRange(line->GetParam("reactorRange")->AsFloat());
|
||||
if ( m_object->Implements(ObjectInterfaceType::JetFlying) )
|
||||
{
|
||||
SetReactorRange(line->GetParam("reactorRange")->AsFloat());
|
||||
}
|
||||
SetLand(line->GetParam("land")->AsBool());
|
||||
}
|
||||
|
||||
|
@ -662,7 +654,7 @@ float CPhysics::GetLinStopLength(PhysicsMode sMode, PhysicsMode aMode)
|
|||
speed = GetLinMotionX(sMode); // MO_ADVSPEED/MO_RECSPEED
|
||||
accel = GetLinMotionX(aMode); // MO_ADVACCEL/MO_RECACCEL/MO_STOACCEL
|
||||
|
||||
if ( m_type == TYPE_FLYING && m_bLand ) // flying on the ground?
|
||||
if ( m_object->Implements(ObjectInterfaceType::Flying) && m_bLand ) // flying on the ground?
|
||||
{
|
||||
speed /= LANDING_SPEED;
|
||||
accel *= LANDING_ACCEL;
|
||||
|
@ -688,7 +680,7 @@ float CPhysics::GetLinMaxLength(float dir)
|
|||
if ( dir > 0.0f ) dist = m_linMotion.advanceSpeed.x;
|
||||
else dist = m_linMotion.recedeSpeed.x;
|
||||
|
||||
if ( m_type == TYPE_FLYING )
|
||||
if ( m_object->Implements(ObjectInterfaceType::Flying) )
|
||||
{
|
||||
dist /= 5.0f;
|
||||
}
|
||||
|
@ -784,21 +776,9 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
|
|||
|
||||
motorSpeed = m_motorSpeed;
|
||||
|
||||
if ( type == OBJECT_MOTHER ||
|
||||
type == OBJECT_ANT ||
|
||||
type == OBJECT_SPIDER ||
|
||||
type == OBJECT_BEE ||
|
||||
type == OBJECT_WORM ||
|
||||
type == OBJECT_APOLLO2 ||
|
||||
type == OBJECT_MOBILEdr ||
|
||||
type == OBJECT_CONTROLLER)
|
||||
if ( type == OBJECT_HUMAN ||
|
||||
type == OBJECT_TECH )
|
||||
{
|
||||
power = nullptr;
|
||||
}
|
||||
else if ( type == OBJECT_HUMAN ||
|
||||
type == OBJECT_TECH )
|
||||
{
|
||||
power = nullptr;
|
||||
if (IsObjectCarryingCargo(m_object) && // carries something?
|
||||
!m_bFreeze )
|
||||
{
|
||||
|
@ -829,26 +809,24 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (m_object->Implements(ObjectInterfaceType::Powered))
|
||||
{
|
||||
if (m_object->Implements(ObjectInterfaceType::Powered))
|
||||
power = dynamic_cast<CPowerContainerObject*>(dynamic_cast<CPoweredObject*>(m_object)->GetPower()); // searches for the object battery uses
|
||||
if ( GetObjectEnergy(m_object) == 0.0f ) // no battery or flat?
|
||||
{
|
||||
power = dynamic_cast<CPowerContainerObject*>(dynamic_cast<CPoweredObject*>(m_object)->GetPower()); // searches for the object battery uses
|
||||
if ( GetObjectEnergy(m_object) == 0.0f ) // no battery or flat?
|
||||
motorSpeed.x = 0.0f;
|
||||
motorSpeed.z = 0.0f;
|
||||
if ( m_bFreeze || m_bLand )
|
||||
{
|
||||
motorSpeed.x = 0.0f;
|
||||
motorSpeed.z = 0.0f;
|
||||
if ( m_bFreeze || m_bLand )
|
||||
{
|
||||
motorSpeed.y = 0.0f; // immobile
|
||||
}
|
||||
else
|
||||
{
|
||||
motorSpeed.y = -1.0f; // grave
|
||||
SetFalling();
|
||||
}
|
||||
SetMotor(false);
|
||||
motorSpeed.y = 0.0f; // immobile
|
||||
}
|
||||
else
|
||||
{
|
||||
motorSpeed.y = -1.0f; // grave
|
||||
SetFalling();
|
||||
}
|
||||
SetMotor(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -867,7 +845,7 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
|
|||
SetMotor(false);
|
||||
}
|
||||
|
||||
if ( m_type == TYPE_FLYING && !m_bLand && motorSpeed.y > 0.0f )
|
||||
if ( m_object->Implements(ObjectInterfaceType::Flying) && !m_bLand && motorSpeed.y > 0.0f )
|
||||
{
|
||||
pos = m_object->GetPosition();
|
||||
h = m_terrain->GetFlyingLimit(pos, type==OBJECT_BEE);
|
||||
|
@ -881,8 +859,8 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
|
|||
}
|
||||
}
|
||||
|
||||
if ( type != OBJECT_BEE &&
|
||||
m_object->GetRange() > 0.0f ) // limited flight range?
|
||||
if ( m_object->Implements(ObjectInterfaceType::JetFlying) &&
|
||||
dynamic_cast<CJetFlyingObject*>(m_object)->GetRange() > 0.0f ) // limited flight range?
|
||||
{
|
||||
if ( m_bLand || m_bSwim || m_bObstacle ) // on the ground or in the water?
|
||||
{
|
||||
|
@ -903,7 +881,7 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
|
|||
}
|
||||
else // in flight?
|
||||
{
|
||||
m_reactorRange -= rTime*(1.0f/m_object->GetRange());
|
||||
m_reactorRange -= rTime*(1.0f/dynamic_cast<CJetFlyingObject*>(m_object)->GetRange());
|
||||
if ( m_reactorRange < 0.0f ) m_reactorRange = 0.0f;
|
||||
if ( m_reactorRange < 0.5f ) m_bLowLevel = true;
|
||||
}
|
||||
|
@ -971,7 +949,7 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
|
|||
m_cirMotion.motorSpeed.y = 0.0f;
|
||||
}
|
||||
|
||||
if ( m_type == TYPE_FLYING && m_bLand ) // flying on the ground?
|
||||
if ( m_object->Implements(ObjectInterfaceType::Flying) && m_bLand ) // flying on the ground?
|
||||
{
|
||||
if ( type == OBJECT_HUMAN ||
|
||||
type == OBJECT_TECH )
|
||||
|
@ -997,7 +975,7 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
|
|||
}
|
||||
}
|
||||
|
||||
if ( m_type == TYPE_ROLLING )
|
||||
if ( !m_object->Implements(ObjectInterfaceType::Flying) )
|
||||
{
|
||||
if ( motorSpeed.x == 0.0f &&
|
||||
motorSpeed.z == 0.0f )
|
||||
|
@ -1022,7 +1000,7 @@ void CPhysics::MotorUpdate(float aTime, float rTime)
|
|||
energy -= fabs(motorSpeed.x)*rTime*factor*0.005f;
|
||||
energy -= fabs(motorSpeed.z)*rTime*factor*0.005f;
|
||||
|
||||
if ( m_type == TYPE_FLYING && motorSpeed.y > 0.0f )
|
||||
if ( m_object->Implements(ObjectInterfaceType::Flying) && motorSpeed.y > 0.0f )
|
||||
{
|
||||
energy -= motorSpeed.y*rTime*factor*0.01f;
|
||||
}
|
||||
|
@ -1550,7 +1528,7 @@ bool CPhysics::EventFrame(const Event &event)
|
|||
|
||||
m_terrain->AdjustToStandardBounds(newpos);
|
||||
|
||||
if ( m_type == TYPE_FLYING && !m_bLand )
|
||||
if ( m_object->Implements(ObjectInterfaceType::Flying) && !m_bLand )
|
||||
{
|
||||
h = m_terrain->GetFlyingLimit(newpos, type==OBJECT_BEE);
|
||||
h += m_object->GetCharacter()->height;
|
||||
|
@ -1715,7 +1693,7 @@ void CPhysics::SoundMotor(float rTime)
|
|||
}
|
||||
else // vehicle?
|
||||
{
|
||||
if ( m_type == TYPE_ROLLING )
|
||||
if ( !m_object->Implements(ObjectInterfaceType::Flying) )
|
||||
{
|
||||
if ( m_bMotor && m_object->GetActive() )
|
||||
{
|
||||
|
@ -1737,7 +1715,7 @@ void CPhysics::SoundMotor(float rTime)
|
|||
}
|
||||
}
|
||||
|
||||
if ( m_type == TYPE_FLYING )
|
||||
if ( m_object->Implements(ObjectInterfaceType::Flying) )
|
||||
{
|
||||
if ( m_bMotor && !m_bSwim &&
|
||||
m_object->GetActive() && !m_object->GetDead() )
|
||||
|
@ -2295,14 +2273,14 @@ void CPhysics::FloorAdapt(float aTime, float rTime,
|
|||
fabs(m_linMotion.realSpeed.x),
|
||||
fabs(m_cirMotion.realSpeed.y*15.0f));
|
||||
|
||||
if ( m_type == TYPE_ROLLING )
|
||||
if ( !m_object->Implements(ObjectInterfaceType::Flying) )
|
||||
{
|
||||
pos.y -= h; // plate to the ground immediately
|
||||
pos.y += character->height;
|
||||
m_floorHeight = 0.0f;
|
||||
}
|
||||
|
||||
if ( m_type == TYPE_FLYING )
|
||||
if ( m_object->Implements(ObjectInterfaceType::Flying) )
|
||||
{
|
||||
bSlopingTerrain = false; // ground as possible to land
|
||||
|
||||
|
@ -2423,7 +2401,7 @@ void CPhysics::FloorAdapt(float aTime, float rTime,
|
|||
|
||||
FloorAngle(pos, angle); // adjusts the angle at the ground
|
||||
|
||||
if ( m_type == TYPE_FLYING && !m_bLand ) // flying in the air?
|
||||
if ( m_object->Implements(ObjectInterfaceType::Flying) && !m_bLand ) // flying in the air?
|
||||
{
|
||||
f = h/1.0f;
|
||||
if ( f < 0.0f ) f = 0.0f;
|
||||
|
@ -2633,7 +2611,7 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
|
|||
m_linMotion.currentSpeed = Normalize(iPos-oPos)*force;
|
||||
Math::LoadRotationXZYMatrix(matRotate, -angle);
|
||||
m_linMotion.currentSpeed = Transform(matRotate, m_linMotion.currentSpeed);
|
||||
if ( m_type == TYPE_ROLLING )
|
||||
if ( !m_object->Implements(ObjectInterfaceType::Flying) )
|
||||
{
|
||||
m_linMotion.currentSpeed.y = 0.0f;
|
||||
}
|
||||
|
@ -2645,7 +2623,7 @@ int CPhysics::ObjectAdapt(const Math::Vector &pos, const Math::Vector &angle)
|
|||
oSpeed = Normalize(oPos-iPos)*force;
|
||||
Math::LoadRotationXZYMatrix(matRotate, -oAngle);
|
||||
oSpeed = Transform(matRotate, oSpeed);
|
||||
if ( ph->GetType() == TYPE_ROLLING )
|
||||
if ( !pObj->Implements(ObjectInterfaceType::Flying) )
|
||||
{
|
||||
oSpeed.y = 0.0f;
|
||||
}
|
||||
|
@ -3376,7 +3354,7 @@ void CPhysics::MotorParticle(float aTime, float rTime)
|
|||
m_reactorTemperature = 0.0f; // reactor cold
|
||||
}
|
||||
|
||||
if ( m_type == TYPE_FLYING &&
|
||||
if ( m_object->Implements(ObjectInterfaceType::Flying) &&
|
||||
type != OBJECT_HUMAN &&
|
||||
type != OBJECT_TECH &&
|
||||
!m_bSwim )
|
||||
|
@ -3547,10 +3525,11 @@ void CPhysics::MotorParticle(float aTime, float rTime)
|
|||
}
|
||||
}
|
||||
|
||||
if ( m_type == TYPE_ROLLING )
|
||||
if ( !m_object->Implements(ObjectInterfaceType::Flying) )
|
||||
{
|
||||
if ( type == OBJECT_APOLLO2 ) return; // electric motors!
|
||||
|
||||
// Create engine smoke
|
||||
if ( type == OBJECT_MOBILErt ||
|
||||
type == OBJECT_MOBILErc ||
|
||||
type == OBJECT_MOBILErr ||
|
||||
|
|
|
@ -53,12 +53,6 @@ class CLightManager;
|
|||
}
|
||||
|
||||
|
||||
enum PhysicsType
|
||||
{
|
||||
TYPE_ROLLING = 1,
|
||||
TYPE_FLYING = 2,
|
||||
};
|
||||
|
||||
enum PhysicsMode
|
||||
{
|
||||
MO_ADVACCEL = 0,
|
||||
|
@ -112,9 +106,6 @@ public:
|
|||
|
||||
void SetMotion(CMotion* motion);
|
||||
|
||||
void SetType(PhysicsType type);
|
||||
PhysicsType GetType();
|
||||
|
||||
bool Write(CLevelParserLine* line);
|
||||
bool Read(CLevelParserLine* line);
|
||||
|
||||
|
@ -219,7 +210,6 @@ protected:
|
|||
COldObject* m_object;
|
||||
CMotion* m_motion;
|
||||
|
||||
PhysicsType m_type; // TYPE_*
|
||||
float m_gravity; // force of gravity
|
||||
float m_time; // absolute time
|
||||
Math::Vector m_motorSpeed; // motor speed (-1..1)
|
||||
|
|
Loading…
Reference in New Issue