Fix aliens being selectable by default (#900)

Broken in 6a382830a9
This change also allows you to make selectable insects with selectable=1 in scene file
dev-buzzingcars
krzys-h 2017-01-28 12:53:28 +01:00
parent 967fb9e30f
commit 7fadf7bad5
2 changed files with 21 additions and 1 deletions

View File

@ -1041,7 +1041,7 @@ void COldObject::Read(CLevelParserLine* line)
SetAnimateOnReset(line->GetParam("reset")->AsBool(false));
if (Implements(ObjectInterfaceType::Controllable))
{
SetSelectable(line->GetParam("selectable")->AsBool(true));
SetSelectable(line->GetParam("selectable")->AsBool(IsSelectableByDefault(m_type)));
}
if (Implements(ObjectInterfaceType::JetFlying))
{
@ -3174,3 +3174,17 @@ float COldObject::GetLightningHitProbability()
}
return 0.0f;
}
bool COldObject::IsSelectableByDefault(ObjectType type)
{
if ( type == OBJECT_MOTHER ||
type == OBJECT_ANT ||
type == OBJECT_SPIDER ||
type == OBJECT_BEE ||
type == OBJECT_WORM ||
type == OBJECT_MOBILEtg )
{
return false;
}
return true;
}

View File

@ -302,6 +302,12 @@ protected:
void TransformCrashSphere(Math::Sphere &crashSphere) override;
void TransformCameraCollisionSphere(Math::Sphere& collisionSphere) override;
/**
* \brief Check if given object type should be selectable by default
* \note This is a default value for the selectable= parameter and can still be overriden in the scene file or using the \a selectinsect cheat
*/
static bool IsSelectableByDefault(ObjectType type);
protected:
Gfx::CEngine* m_engine;
Gfx::CLightManager* m_lightMan;