2017-01-21 06:03:37 +00:00
|
|
|
#include "World/CGameLight.hpp"
|
|
|
|
#include "World/CActorParameters.hpp"
|
2016-10-01 19:00:16 +00:00
|
|
|
#include "CStateManager.hpp"
|
2017-01-21 06:03:37 +00:00
|
|
|
#include "TCastTo.hpp"
|
2016-10-01 19:00:16 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
|
|
|
CGameLight::CGameLight(TUniqueId uid, TAreaId aid, bool active, const std::string& name, const zeus::CTransform& xf,
|
|
|
|
TUniqueId parentId, const CLight& light, u32 w1, u32 w2, float f1)
|
2016-10-09 17:07:09 +00:00
|
|
|
: CActor(uid, active, name, CEntityInfo(aid, CEntity::NullConnectionList), xf,
|
2016-10-01 19:00:16 +00:00
|
|
|
CModelData::CModelDataNull(), CMaterialList(), CActorParameters::None(), kInvalidUniqueId),
|
2017-05-18 10:58:15 +00:00
|
|
|
xe8_parentId(parentId), xec_light(light), x13c_loadedIdx(w1), x140_priority(w2), x144_lifeTime(f1)
|
2016-10-01 19:00:16 +00:00
|
|
|
{
|
|
|
|
xec_light.GetRadius();
|
|
|
|
xec_light.GetIntensity();
|
|
|
|
SetLightPriorityAndId();
|
|
|
|
}
|
|
|
|
|
2017-01-21 06:03:37 +00:00
|
|
|
void CGameLight::Accept(IVisitor &visitor)
|
|
|
|
{
|
|
|
|
visitor.Visit(this);
|
|
|
|
}
|
|
|
|
|
2016-10-01 19:00:16 +00:00
|
|
|
void CGameLight::Think(float dt, CStateManager& mgr)
|
|
|
|
{
|
2017-01-21 06:03:37 +00:00
|
|
|
if (x144_lifeTime <= 0.f)
|
2016-10-01 19:00:16 +00:00
|
|
|
return;
|
2017-01-21 06:03:37 +00:00
|
|
|
x144_lifeTime -= dt;
|
2016-10-01 19:00:16 +00:00
|
|
|
|
2017-01-21 06:03:37 +00:00
|
|
|
if (x144_lifeTime <= 0.f)
|
2017-03-26 05:53:04 +00:00
|
|
|
mgr.FreeScriptObject(GetUniqueId());
|
2016-10-01 19:00:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CGameLight::SetLightPriorityAndId()
|
|
|
|
{
|
2017-05-18 10:58:15 +00:00
|
|
|
xec_light.x3c_priority = x140_priority;
|
|
|
|
xec_light.x40_loadedIdx = x13c_loadedIdx;
|
2016-10-01 19:00:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CGameLight::SetLight(const CLight& light)
|
|
|
|
{
|
|
|
|
xec_light = light;
|
|
|
|
xec_light.GetRadius();
|
|
|
|
xec_light.GetIntensity();
|
|
|
|
SetLightPriorityAndId();
|
|
|
|
}
|
|
|
|
|
|
|
|
CLight CGameLight::GetLight() const
|
|
|
|
{
|
|
|
|
CLight ret = xec_light;
|
|
|
|
ret.SetPosition(x34_transform * xec_light.GetPosition());
|
|
|
|
|
|
|
|
if (ret.GetType() != ELightType::Point)
|
|
|
|
ret.SetDirection(x34_transform.rotate(xec_light.GetDirection()).normalized());
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|