2016-04-27 19:59:38 +00:00
|
|
|
#include "CScriptSpecialFunction.hpp"
|
|
|
|
#include "Character/CModelData.hpp"
|
|
|
|
#include "CActorParameters.hpp"
|
2016-12-19 18:27:58 +00:00
|
|
|
#include "Audio/CSfxManager.hpp"
|
2017-01-15 03:07:01 +00:00
|
|
|
#include "TCastTo.hpp"
|
2017-02-18 02:19:50 +00:00
|
|
|
#include "GameGlobalObjects.hpp"
|
|
|
|
#include "CGameState.hpp"
|
|
|
|
#include "CStateManager.hpp"
|
2016-04-27 19:59:38 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
2017-11-13 06:19:18 +00:00
|
|
|
CScriptSpecialFunction::CScriptSpecialFunction(TUniqueId uid, std::string_view name, const CEntityInfo& info,
|
2016-12-19 18:27:58 +00:00
|
|
|
const zeus::CTransform& xf, ESpecialFunction func,
|
2017-11-13 06:19:18 +00:00
|
|
|
std::string_view lcName, float f1, float f2, float f3, float f4,
|
2016-12-19 18:27:58 +00:00
|
|
|
const zeus::CVector3f& vec, const zeus::CColor& col, bool active,
|
2017-08-29 13:17:52 +00:00
|
|
|
const CDamageInfo& dInfo, CAssetId aId1, CAssetId aId2, CAssetId aId3,
|
|
|
|
s16 sId1, s16 sId2, s16 sId3)
|
2016-09-02 15:26:29 +00:00
|
|
|
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(), CActorParameters::None(),
|
|
|
|
kInvalidUniqueId)
|
2016-12-19 18:27:58 +00:00
|
|
|
, xe8_function(func)
|
|
|
|
, xec_locatorName(lcName)
|
2017-08-29 13:17:52 +00:00
|
|
|
, xfc_(f1)
|
2016-12-19 18:27:58 +00:00
|
|
|
, x100_(f2)
|
|
|
|
, x104_(f3)
|
|
|
|
, x108_(f4)
|
|
|
|
, x10c_(vec)
|
|
|
|
, x118_(col)
|
|
|
|
, x11c_damageInfo(dInfo)
|
|
|
|
, x170_(CSfxManager::TranslateSFXID(sId1))
|
|
|
|
, x172_(CSfxManager::TranslateSFXID(sId2))
|
|
|
|
, x174_(CSfxManager::TranslateSFXID(sId3))
|
|
|
|
, x1bc_(aId1)
|
|
|
|
, x1c0_(aId2)
|
|
|
|
, x1c4_(aId3)
|
2016-04-27 19:59:38 +00:00
|
|
|
{
|
2017-01-25 04:40:19 +00:00
|
|
|
x1e4_26_ = true;
|
2016-12-19 18:27:58 +00:00
|
|
|
if (xe8_function == ESpecialFunction::HUDTarget)
|
|
|
|
x1c8_ = {{zeus::CVector3f(-1.f), zeus::CVector3f(1.f)}};
|
|
|
|
}
|
|
|
|
|
2017-08-29 13:17:52 +00:00
|
|
|
void CScriptSpecialFunction::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
2017-01-15 03:07:01 +00:00
|
|
|
|
2017-08-29 13:17:52 +00:00
|
|
|
void CScriptSpecialFunction::Think(float, CStateManager&) {}
|
2016-12-19 18:27:58 +00:00
|
|
|
|
2017-08-29 13:17:52 +00:00
|
|
|
void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
|
2016-12-19 18:27:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-08-29 13:17:52 +00:00
|
|
|
void CScriptSpecialFunction::PreRender(CStateManager&, const zeus::CFrustum&) {}
|
2016-12-19 18:27:58 +00:00
|
|
|
|
2017-08-29 13:17:52 +00:00
|
|
|
void CScriptSpecialFunction::AddToRenderer(const zeus::CFrustum&, const CStateManager&) const {}
|
2016-12-19 18:27:58 +00:00
|
|
|
|
2017-08-29 13:17:52 +00:00
|
|
|
void CScriptSpecialFunction::Render(const CStateManager&) const {}
|
2016-12-19 18:27:58 +00:00
|
|
|
|
2017-08-29 13:17:52 +00:00
|
|
|
void CScriptSpecialFunction::SkipCinematic(CStateManager& stateMgr)
|
|
|
|
{
|
|
|
|
SendScriptMsgs(EScriptObjectState::Zero, stateMgr, EScriptObjectMessage::None);
|
|
|
|
stateMgr.SetSkipCinematicSpecialFunction(kInvalidUniqueId);
|
2016-12-19 18:27:58 +00:00
|
|
|
}
|
|
|
|
|
2017-08-29 13:17:52 +00:00
|
|
|
void CScriptSpecialFunction::ThinkActorScale(float dt, CStateManager& mgr)
|
2016-12-19 18:27:58 +00:00
|
|
|
{
|
2017-08-29 13:17:52 +00:00
|
|
|
float deltaScale = dt * xfc_;
|
|
|
|
|
|
|
|
for (const SConnection& conn : x20_conns)
|
|
|
|
{
|
|
|
|
if (conn.x0_state != EScriptObjectState::Play || conn.x4_msg != EScriptObjectMessage::Activate)
|
|
|
|
continue;
|
|
|
|
if (TCastToPtr<CActor> act = mgr.ObjectById(mgr.GetIdForScript(conn.x8_objId)))
|
|
|
|
{
|
|
|
|
CModelData* mData = act->ModelData();
|
|
|
|
if (mData && (mData->HasAnimData() || mData->HasNormalModel()))
|
|
|
|
{
|
|
|
|
zeus::CVector3f scale = mData->GetScale();
|
|
|
|
|
|
|
|
if (deltaScale > 0.f)
|
2017-12-18 02:54:50 +00:00
|
|
|
scale = zeus::min(zeus::CVector3f(deltaScale) + scale, zeus::CVector3f(x100_));
|
2017-08-29 13:17:52 +00:00
|
|
|
else
|
2017-12-18 02:54:50 +00:00
|
|
|
scale = zeus::max(zeus::CVector3f(deltaScale) + scale, zeus::CVector3f(x100_));
|
2017-08-29 13:17:52 +00:00
|
|
|
|
|
|
|
mData->SetScale(scale);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-04-27 19:59:38 +00:00
|
|
|
}
|
2017-02-18 02:19:50 +00:00
|
|
|
|
2017-08-29 13:17:52 +00:00
|
|
|
void CScriptSpecialFunction::ThinkSaveStation(float, CStateManager& mgr)
|
2017-02-18 02:19:50 +00:00
|
|
|
{
|
2017-08-29 13:17:52 +00:00
|
|
|
if (x1e5_24_doSave && mgr.GetDeferredStateTransition() != EStateManagerTransition::SaveGame)
|
|
|
|
{
|
|
|
|
x1e5_24_doSave = false;
|
|
|
|
if (mgr.GetInSaveUI())
|
|
|
|
SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None);
|
|
|
|
else
|
|
|
|
SendScriptMsgs(EScriptObjectState::Zero, mgr, EScriptObjectMessage::None);
|
|
|
|
}
|
2017-02-18 02:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CScriptSpecialFunction::ShouldSkipCinematic(CStateManager& stateMgr) const
|
|
|
|
{
|
|
|
|
return g_GameState->SystemOptions().GetCinematicState(stateMgr.GetWorld()->IGetWorldAssetId(), GetEditorId());
|
|
|
|
}
|
2016-04-27 19:59:38 +00:00
|
|
|
}
|