Added Bucket object. Water pump now fills bucket (then cycles to empty and repeats)
parent
80840b7c95
commit
d7cf54c55b
|
@ -369,6 +369,7 @@ set(BASE_SOURCES
|
||||||
object/interface/flying_object.h
|
object/interface/flying_object.h
|
||||||
object/interface/fragile_object.h
|
object/interface/fragile_object.h
|
||||||
object/interface/interactive_object.h
|
object/interface/interactive_object.h
|
||||||
|
object/interface/liquid_container_object.h
|
||||||
object/interface/jet_flying_object.h
|
object/interface/jet_flying_object.h
|
||||||
object/interface/jostleable_object.h
|
object/interface/jostleable_object.h
|
||||||
object/interface/movable_object.h
|
object/interface/movable_object.h
|
||||||
|
@ -426,6 +427,7 @@ set(BASE_SOURCES
|
||||||
object/subclass/base_robot.h
|
object/subclass/base_robot.h
|
||||||
object/subclass/base_vehicle.cpp
|
object/subclass/base_vehicle.cpp
|
||||||
object/subclass/base_vehicle.h
|
object/subclass/base_vehicle.h
|
||||||
|
object/subclass/bucket.cpp
|
||||||
object/subclass/exchange_post.cpp
|
object/subclass/exchange_post.cpp
|
||||||
object/subclass/exchange_post.h
|
object/subclass/exchange_post.h
|
||||||
object/subclass/shielder.cpp
|
object/subclass/shielder.cpp
|
||||||
|
|
|
@ -924,7 +924,8 @@ void CCamera::IsCollisionFix(Math::Vector &eye, Math::Vector lookat)
|
||||||
type == OBJECT_ANT ||
|
type == OBJECT_ANT ||
|
||||||
type == OBJECT_SPIDER ||
|
type == OBJECT_SPIDER ||
|
||||||
type == OBJECT_BEE ||
|
type == OBJECT_BEE ||
|
||||||
type == OBJECT_WORM ) continue;
|
type == OBJECT_WORM ||
|
||||||
|
type == OBJECT_BUCKET ) continue;
|
||||||
|
|
||||||
Math::Sphere objSphere = obj->GetCameraCollisionSphere();
|
Math::Sphere objSphere = obj->GetCameraCollisionSphere();
|
||||||
Math::Vector objPos = objSphere.pos;
|
Math::Vector objPos = objSphere.pos;
|
||||||
|
|
|
@ -534,6 +534,7 @@ ObjectType CLevelParserParam::ToObjectType(std::string value)
|
||||||
if (value == "Tech" ) return OBJECT_TECH;
|
if (value == "Tech" ) return OBJECT_TECH;
|
||||||
if (value == "MissionController" ) return OBJECT_CONTROLLER;
|
if (value == "MissionController" ) return OBJECT_CONTROLLER;
|
||||||
if (value == "WaterPump" ) return OBJECT_WATERPUMP;
|
if (value == "WaterPump" ) return OBJECT_WATERPUMP;
|
||||||
|
if (value == "Bucket" ) return OBJECT_BUCKET;
|
||||||
return static_cast<ObjectType>(Cast<int>(value, "object"));
|
return static_cast<ObjectType>(Cast<int>(value, "object"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -732,6 +733,7 @@ const std::string CLevelParserParam::FromObjectType(ObjectType value)
|
||||||
if (value == OBJECT_TECH ) return "Tech";
|
if (value == OBJECT_TECH ) return "Tech";
|
||||||
if (value == OBJECT_CONTROLLER ) return "MissionController";
|
if (value == OBJECT_CONTROLLER ) return "MissionController";
|
||||||
if (value == OBJECT_WATERPUMP ) return "WaterPump";
|
if (value == OBJECT_WATERPUMP ) return "WaterPump";
|
||||||
|
if (value == OBJECT_BUCKET ) return "Bucket";
|
||||||
return boost::lexical_cast<std::string>(static_cast<int>(value));
|
return boost::lexical_cast<std::string>(static_cast<int>(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,10 @@ CObjectUPtr CObjectFactory::CreateObject(const ObjectCreateParams& params)
|
||||||
case OBJECT_WATERPUMP:
|
case OBJECT_WATERPUMP:
|
||||||
return CreateObjectWaterPump(params, m_oldModelManager, m_modelManager, m_engine);
|
return CreateObjectWaterPump(params, m_oldModelManager, m_modelManager, m_engine);
|
||||||
|
|
||||||
|
case OBJECT_BUCKET:
|
||||||
|
std::unique_ptr<CObject> CreateObjectBucket(const ObjectCreateParams&, Gfx::COldModelManager*, Gfx::CEngine*);
|
||||||
|
return CreateObjectBucket(params, m_oldModelManager, m_engine);
|
||||||
|
|
||||||
case OBJECT_PORTICO:
|
case OBJECT_PORTICO:
|
||||||
case OBJECT_BASE:
|
case OBJECT_BASE:
|
||||||
case OBJECT_DERRICK:
|
case OBJECT_DERRICK:
|
||||||
|
|
|
@ -45,6 +45,8 @@ struct ObjectCreateParams;
|
||||||
|
|
||||||
using CObjectUPtr = std::unique_ptr<CObject>;
|
using CObjectUPtr = std::unique_ptr<CObject>;
|
||||||
|
|
||||||
|
std::unique_ptr<CObject> CreateObjectBucket(const ObjectCreateParams ¶ms, Gfx::COldModelManager *modelManager, Gfx::CEngine *graphicsEngine);
|
||||||
|
|
||||||
class CObjectFactory
|
class CObjectFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -54,6 +54,7 @@ enum class ObjectInterfaceType
|
||||||
Shielded, //!< objects that can be destroyed after the shield goes down to 0
|
Shielded, //!< objects that can be destroyed after the shield goes down to 0
|
||||||
ShieldedAutoRegen, //!< shielded objects with auto shield regeneration
|
ShieldedAutoRegen, //!< shielded objects with auto shield regeneration
|
||||||
Old, //!< old objects, TODO: remove once no longer necessary
|
Old, //!< old objects, TODO: remove once no longer necessary
|
||||||
|
LiquidContainer, //!< liquid container
|
||||||
Max //!< maximum value (for getting number of items in enum)
|
Max //!< maximum value (for getting number of items in enum)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -231,6 +231,7 @@ enum ObjectType
|
||||||
OBJECT_APOLLO5 = 904, //!< ApolloAntenna
|
OBJECT_APOLLO5 = 904, //!< ApolloAntenna
|
||||||
OBJECT_HOME1 = 910, //!< Home
|
OBJECT_HOME1 = 910, //!< Home
|
||||||
OBJECT_WATERPUMP = 920, //!< WaterPump
|
OBJECT_WATERPUMP = 920, //!< WaterPump
|
||||||
|
OBJECT_BUCKET = 921, //!< Bucket
|
||||||
|
|
||||||
OBJECT_MAX = 1000 //!< number of values
|
OBJECT_MAX = 1000 //!< number of values
|
||||||
};
|
};
|
||||||
|
|
|
@ -773,6 +773,7 @@ void COldObject::SetType(ObjectType type)
|
||||||
m_type == OBJECT_SPIDER ||
|
m_type == OBJECT_SPIDER ||
|
||||||
m_type == OBJECT_BEE ||
|
m_type == OBJECT_BEE ||
|
||||||
m_type == OBJECT_TEEN28 )
|
m_type == OBJECT_TEEN28 )
|
||||||
|
// TODO OBJECT_BUCKET
|
||||||
{
|
{
|
||||||
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::Damageable)] = true;
|
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::Damageable)] = true;
|
||||||
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::Destroyable)] = true;
|
m_implementedInterfaces[static_cast<int>(ObjectInterfaceType::Destroyable)] = true;
|
||||||
|
@ -3205,13 +3206,15 @@ float COldObject::GetLightningHitProbability()
|
||||||
m_type == OBJECT_NUCLEAR ||
|
m_type == OBJECT_NUCLEAR ||
|
||||||
m_type == OBJECT_PARA ||
|
m_type == OBJECT_PARA ||
|
||||||
m_type == OBJECT_SAFE ||
|
m_type == OBJECT_SAFE ||
|
||||||
m_type == OBJECT_HUSTON ) // building?
|
m_type == OBJECT_HUSTON ||
|
||||||
|
m_type == OBJECT_WATERPUMP) // building?
|
||||||
{
|
{
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
}
|
}
|
||||||
if ( m_type == OBJECT_METAL ||
|
if ( m_type == OBJECT_METAL ||
|
||||||
m_type == OBJECT_POWER ||
|
m_type == OBJECT_POWER ||
|
||||||
m_type == OBJECT_ATOMIC ) // resource?
|
m_type == OBJECT_ATOMIC ||
|
||||||
|
m_type == OBJECT_BUCKET ) // resource?
|
||||||
{
|
{
|
||||||
return 0.3f;
|
return 0.3f;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "object/subclass/water_pump.h"
|
#include "object/subclass/water_pump.h"
|
||||||
|
#include "object/interface/liquid_container_object.h"
|
||||||
|
|
||||||
#include "common/make_unique.h"
|
#include "common/make_unique.h"
|
||||||
#include "common/regex_utils.h"
|
#include "common/regex_utils.h"
|
||||||
|
@ -67,18 +68,21 @@ struct CAutoWaterPump : public CAuto
|
||||||
CObject *powerCell = m_object->GetPower();
|
CObject *powerCell = m_object->GetPower();
|
||||||
if (powerCell != nullptr) {
|
if (powerCell != nullptr) {
|
||||||
|
|
||||||
if (powerCell->Implements(ObjectInterfaceType::PowerContainer)) {
|
if (powerCell->Implements(ObjectInterfaceType::LiquidContainer)) {
|
||||||
CPowerContainerObject *asPC = dynamic_cast<CPowerContainerObject*>(powerCell);
|
// test code
|
||||||
float energy = asPC->GetEnergyLevel();
|
CLiquidContainerObject *asPC = dynamic_cast<CLiquidContainerObject*>(powerCell);
|
||||||
energy += (0.2f * event.rTime) / asPC->GetCapacity();
|
float energy = asPC->GetLiquidAmount();
|
||||||
asPC->SetEnergyLevel(energy);
|
energy += (0.2f * event.rTime);
|
||||||
}
|
if(energy > 1.0f) energy = 0.0f;
|
||||||
|
asPC->SetLiquid(LiquidType::WATER, energy);
|
||||||
|
|
||||||
cycle = fmodf(cycle + event.rTime, 1.0f);
|
// animation
|
||||||
if (cycle < 0.5f)
|
cycle = fmodf(cycle + event.rTime, 1.0f);
|
||||||
m_object->SetPartPosition(1, Math::Vector(0.0f, 4.0f * cycle + 1.5f, 0.0f));
|
if (cycle < 0.5f)
|
||||||
else
|
m_object->SetPartPosition(1, Math::Vector(0.0f, 4.0f * cycle + 1.5f, 0.0f));
|
||||||
m_object->SetPartPosition(1, Math::Vector(0.0f, 4.0f - (4.0f * cycle) + 1.5f, 0.0f));
|
else
|
||||||
|
m_object->SetPartPosition(1, Math::Vector(0.0f, 4.0f - (4.0f * cycle) + 1.5f, 0.0f));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true; // XXX what does this mean?
|
return true; // XXX what does this mean?
|
||||||
|
|
|
@ -116,6 +116,7 @@ const char* GetObjectName(ObjectType type)
|
||||||
if ( type == OBJECT_WORM ) return "AlienWorm";
|
if ( type == OBJECT_WORM ) return "AlienWorm";
|
||||||
if ( type == OBJECT_RUINmobilew1) return "Wreck";
|
if ( type == OBJECT_RUINmobilew1) return "Wreck";
|
||||||
if ( type == OBJECT_WATERPUMP ) return "WaterPump";
|
if ( type == OBJECT_WATERPUMP ) return "WaterPump";
|
||||||
|
if ( type == OBJECT_BUCKET ) return "Bucket";
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue