2016-04-19 21:25:26 +00:00
|
|
|
#include "CScriptDoor.hpp"
|
2016-04-23 00:29:55 +00:00
|
|
|
#include "CScriptDock.hpp"
|
2016-04-19 21:25:26 +00:00
|
|
|
#include "Collision/CMaterialList.hpp"
|
2016-04-22 20:22:45 +00:00
|
|
|
#include "Character/CAnimData.hpp"
|
|
|
|
#include "Character/CAnimPlaybackParms.hpp"
|
|
|
|
#include "AutoMapper/CMapWorldInfo.hpp"
|
|
|
|
#include "CStateManager.hpp"
|
2016-04-23 00:29:55 +00:00
|
|
|
#include "CWorld.hpp"
|
2016-07-28 07:33:55 +00:00
|
|
|
#include "Camera/CCameraManager.hpp"
|
|
|
|
#include "Camera/CBallCamera.hpp"
|
2017-01-15 03:07:01 +00:00
|
|
|
#include "TCastTo.hpp"
|
2016-04-19 21:25:26 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
2016-12-29 21:38:59 +00:00
|
|
|
static CMaterialList MakeDoorMaterialList(bool open)
|
2016-04-19 21:25:26 +00:00
|
|
|
{
|
|
|
|
CMaterialList ret;
|
2018-05-07 00:47:40 +00:00
|
|
|
ret.Add(EMaterialTypes::Solid);
|
2016-12-29 21:38:59 +00:00
|
|
|
ret.Add(EMaterialTypes::Immovable);
|
|
|
|
ret.Add(EMaterialTypes::Orbit);
|
|
|
|
if (!open)
|
|
|
|
ret.Add(EMaterialTypes::Occluder);
|
2016-04-22 20:22:45 +00:00
|
|
|
|
2016-04-19 21:25:26 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-11-13 06:19:18 +00:00
|
|
|
CScriptDoor::CScriptDoor(TUniqueId uid, std::string_view name, const CEntityInfo& info,
|
2016-04-22 20:22:45 +00:00
|
|
|
const zeus::CTransform& xf, CModelData&& mData, const CActorParameters& actParms,
|
2018-05-22 07:51:08 +00:00
|
|
|
const zeus::CVector3f& orbitPos, const zeus::CAABox& aabb, bool active,
|
2018-05-07 00:47:40 +00:00
|
|
|
bool open, bool projectilesCollide, float animLen, bool ballDoor)
|
2016-12-29 21:38:59 +00:00
|
|
|
: CPhysicsActor(uid, active, name, info, xf, std::move(mData), MakeDoorMaterialList(open),
|
2017-01-25 04:40:19 +00:00
|
|
|
aabb, SMoverData(1.f), actParms, 0.3f, 0.1f)
|
2016-04-19 21:25:26 +00:00
|
|
|
{
|
2018-05-02 00:43:31 +00:00
|
|
|
x258_animLen = animLen;
|
2018-05-07 00:47:40 +00:00
|
|
|
x2a8_24_closing = false;
|
|
|
|
x2a8_25_wasOpen = open;
|
2018-05-02 00:43:31 +00:00
|
|
|
x2a8_26_isOpen = open;
|
2018-05-07 00:47:40 +00:00
|
|
|
x2a8_27_conditionsMet = false;
|
|
|
|
x2a8_28_projectilesCollide = projectilesCollide;
|
2018-05-02 00:43:31 +00:00
|
|
|
x2a8_29_ballDoor = ballDoor;
|
2018-05-07 00:47:40 +00:00
|
|
|
x2a8_30_doClose = false;
|
2016-04-22 20:22:45 +00:00
|
|
|
x264_ = GetBoundingBox();
|
2016-04-23 18:04:49 +00:00
|
|
|
x284_modelBounds = x64_modelData->GetBounds(xf.getRotation());
|
2018-05-22 07:51:08 +00:00
|
|
|
x29c_orbitPos = orbitPos;
|
2016-04-23 18:04:49 +00:00
|
|
|
|
2018-05-02 00:43:31 +00:00
|
|
|
xe6_27_thermalVisorFlags = 1;
|
2016-12-29 21:38:59 +00:00
|
|
|
if (open)
|
2016-04-23 18:04:49 +00:00
|
|
|
SetDoorAnimation(EDoorAnimType::Open);
|
|
|
|
|
|
|
|
SetMass(0.f);
|
2016-04-22 20:22:45 +00:00
|
|
|
}
|
|
|
|
|
2017-01-15 03:07:01 +00:00
|
|
|
void CScriptDoor::Accept(IVisitor& visitor)
|
|
|
|
{
|
|
|
|
visitor.Visit(this);
|
|
|
|
}
|
|
|
|
|
2016-04-23 00:29:55 +00:00
|
|
|
/* ORIGINAL 0-00 OFFSET: 8007F054 */
|
2016-04-23 18:04:49 +00:00
|
|
|
zeus::CVector3f CScriptDoor::GetOrbitPosition(const CStateManager& /*mgr*/) const
|
2016-04-23 00:29:55 +00:00
|
|
|
{
|
2018-05-22 07:51:08 +00:00
|
|
|
return x34_transform.origin + x29c_orbitPos;
|
2016-04-23 00:29:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ORIGINAL 0-00 OFFSET: 8007E550 */
|
|
|
|
void CScriptDoor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager &mgr)
|
|
|
|
{
|
2018-05-19 05:16:08 +00:00
|
|
|
switch (msg)
|
2018-04-30 03:12:41 +00:00
|
|
|
{
|
|
|
|
case EScriptObjectMessage::Close:
|
|
|
|
{
|
|
|
|
if (!GetActive())
|
|
|
|
return;
|
|
|
|
|
2018-05-02 00:43:31 +00:00
|
|
|
if (x27c_partner1 != kInvalidUniqueId && x27c_partner1 != uid)
|
2018-04-30 03:12:41 +00:00
|
|
|
return;
|
|
|
|
|
2018-05-02 00:43:31 +00:00
|
|
|
if (x2a8_26_isOpen)
|
2018-04-30 03:12:41 +00:00
|
|
|
{
|
2018-05-19 05:16:08 +00:00
|
|
|
if (x27e_partner2 != kInvalidUniqueId)
|
|
|
|
if (CEntity* ent = mgr.ObjectById(x27e_partner2))
|
|
|
|
mgr.SendScriptMsg(ent, GetUniqueId(), EScriptObjectMessage::Close);
|
2018-05-02 00:43:31 +00:00
|
|
|
x2a8_26_isOpen = false;
|
2018-04-30 03:12:41 +00:00
|
|
|
SetDoorAnimation(EDoorAnimType::Close);
|
|
|
|
mgr.GetCameraManager()->GetBallCamera()->DoorClosing(GetUniqueId());
|
|
|
|
}
|
2018-05-07 00:47:40 +00:00
|
|
|
else if (x2a8_27_conditionsMet)
|
2018-04-30 03:12:41 +00:00
|
|
|
{
|
2018-05-07 00:47:40 +00:00
|
|
|
x2a8_27_conditionsMet = false;
|
2018-04-30 03:12:41 +00:00
|
|
|
SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::None);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EScriptObjectMessage::Action:
|
|
|
|
{
|
|
|
|
if (x27c_partner1 != kInvalidUniqueId)
|
|
|
|
{
|
|
|
|
if (TCastToPtr<CScriptDoor> door = mgr.ObjectById(x27c_partner1))
|
|
|
|
{
|
2018-05-19 21:14:37 +00:00
|
|
|
if (!x2a8_26_isOpen)
|
2018-04-30 03:12:41 +00:00
|
|
|
return;
|
2018-05-07 00:47:40 +00:00
|
|
|
x2a8_30_doClose = true;
|
2018-04-30 03:12:41 +00:00
|
|
|
mgr.SendScriptMsg(door, GetUniqueId(), EScriptObjectMessage::Close);
|
|
|
|
}
|
|
|
|
}
|
2018-05-02 00:43:31 +00:00
|
|
|
else if (x2a8_26_isOpen)
|
2018-04-30 03:12:41 +00:00
|
|
|
{
|
2018-05-07 00:47:40 +00:00
|
|
|
x2a8_30_doClose = true;
|
2018-04-30 03:12:41 +00:00
|
|
|
if (TCastToPtr<CScriptDoor> door = mgr.ObjectById(x27e_partner2))
|
|
|
|
{
|
|
|
|
mgr.SendScriptMsg(door, GetUniqueId(), EScriptObjectMessage::Close);
|
2018-05-07 00:47:40 +00:00
|
|
|
x2a8_30_doClose = true;
|
2018-04-30 03:12:41 +00:00
|
|
|
}
|
2018-05-02 00:43:31 +00:00
|
|
|
x2a8_26_isOpen = false;
|
2018-04-30 03:12:41 +00:00
|
|
|
SetDoorAnimation(EDoorAnimType::Close);
|
|
|
|
mgr.GetCameraManager()->GetBallCamera()->DoorClosing(GetUniqueId());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EScriptObjectMessage::Open:
|
|
|
|
{
|
2018-05-02 00:43:31 +00:00
|
|
|
if (!GetActive() || x2a8_26_isOpen)
|
2018-04-30 03:12:41 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
u32 doorCond = TCastToConstPtr<CScriptDoor>(mgr.GetObjectById(uid)) ? 2 : GetDoorOpenCondition(mgr);
|
2018-05-22 07:51:08 +00:00
|
|
|
switch (doorCond)
|
2018-04-30 03:12:41 +00:00
|
|
|
{
|
|
|
|
case 1:
|
2018-05-07 00:47:40 +00:00
|
|
|
x2a8_27_conditionsMet = true;
|
|
|
|
x280_prevDoor = uid;
|
2018-04-30 03:12:41 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
OpenDoor(uid, mgr);
|
|
|
|
break;
|
|
|
|
default:
|
2018-05-07 00:47:40 +00:00
|
|
|
x2a8_25_wasOpen= false;
|
|
|
|
x2a8_24_closing = true;
|
2018-04-30 03:12:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EScriptObjectMessage::InitializedInArea:
|
|
|
|
{
|
|
|
|
for (const SConnection& conn : x20_conns)
|
|
|
|
{
|
|
|
|
if (conn.x4_msg == EScriptObjectMessage::Increment)
|
|
|
|
{
|
|
|
|
TUniqueId dock = mgr.GetIdForScript(conn.x8_objId);
|
2018-05-07 00:47:40 +00:00
|
|
|
if (TCastToConstPtr<CScriptDock> d = mgr.GetObjectById(dock))
|
2018-05-19 21:14:37 +00:00
|
|
|
{
|
2018-05-07 00:47:40 +00:00
|
|
|
x282_dockId = d->GetUniqueId();
|
2018-05-19 21:14:37 +00:00
|
|
|
break;
|
|
|
|
}
|
2018-04-30 03:12:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EScriptObjectMessage::SetToZero:
|
|
|
|
{
|
2018-05-07 00:47:40 +00:00
|
|
|
x2a8_28_projectilesCollide = true;
|
2018-04-30 03:12:41 +00:00
|
|
|
mgr.MapWorldInfo()->SetDoorVisited(mgr.GetEditorIdForUniqueId(GetUniqueId()), true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EScriptObjectMessage::SetToMax:
|
|
|
|
{
|
2018-05-07 00:47:40 +00:00
|
|
|
x2a8_28_projectilesCollide = false;
|
2018-04-30 03:12:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
CActor::AcceptScriptMsg(msg, uid, mgr);
|
|
|
|
}
|
2016-04-23 00:29:55 +00:00
|
|
|
}
|
|
|
|
|
2018-04-30 03:12:41 +00:00
|
|
|
|
2016-04-24 02:46:13 +00:00
|
|
|
void CScriptDoor::Think(float dt, CStateManager& mgr)
|
|
|
|
{
|
|
|
|
if (!GetActive())
|
|
|
|
return;
|
|
|
|
|
2018-05-02 00:43:31 +00:00
|
|
|
if (!x2a8_26_isOpen && x25c_animTime < 0.5f)
|
|
|
|
x25c_animTime += dt;
|
2018-04-30 03:12:41 +00:00
|
|
|
|
2018-05-07 00:47:40 +00:00
|
|
|
if (x2a8_27_conditionsMet && GetDoorOpenCondition(mgr) == 2)
|
2018-04-30 03:12:41 +00:00
|
|
|
{
|
2018-05-07 00:47:40 +00:00
|
|
|
x2a8_27_conditionsMet = false;
|
|
|
|
OpenDoor(x280_prevDoor, mgr);
|
2018-04-30 03:12:41 +00:00
|
|
|
}
|
|
|
|
|
2018-05-07 00:47:40 +00:00
|
|
|
if (x2a8_24_closing)
|
2018-04-30 03:12:41 +00:00
|
|
|
{
|
2018-05-07 00:47:40 +00:00
|
|
|
x2a8_25_wasOpen = false;
|
2018-04-30 03:12:41 +00:00
|
|
|
mgr.GetCameraManager()->GetBallCamera()->DoorClosed(GetUniqueId());
|
2018-05-07 00:47:40 +00:00
|
|
|
x2a8_28_projectilesCollide = false;
|
|
|
|
x2a8_24_closing = false;
|
2018-04-30 03:12:41 +00:00
|
|
|
SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::Decrement);
|
2018-05-02 00:43:31 +00:00
|
|
|
x25c_animTime = 0.f;
|
2018-05-07 00:47:40 +00:00
|
|
|
x2a8_30_doClose = false;
|
2018-04-30 03:12:41 +00:00
|
|
|
}
|
|
|
|
|
2018-05-02 00:43:31 +00:00
|
|
|
if (x2a8_26_isOpen && !x64_modelData->IsAnimating())
|
2018-04-30 03:12:41 +00:00
|
|
|
RemoveMaterial(EMaterialTypes::Solid, EMaterialTypes::Occluder, EMaterialTypes::Orbit, EMaterialTypes::Scannable, mgr);
|
2018-05-02 00:43:31 +00:00
|
|
|
else
|
2018-04-30 03:12:41 +00:00
|
|
|
{
|
2018-05-07 00:47:40 +00:00
|
|
|
if (x2a8_25_wasOpen && !x64_modelData->IsAnimating())
|
2018-05-02 00:43:31 +00:00
|
|
|
{
|
2018-05-07 00:47:40 +00:00
|
|
|
x2a8_25_wasOpen = false;
|
2018-05-02 00:43:31 +00:00
|
|
|
mgr.GetCameraManager()->GetBallCamera()->DoorClosed(GetUniqueId());
|
2018-05-07 00:47:40 +00:00
|
|
|
x2a8_28_projectilesCollide = false;
|
|
|
|
x2a8_27_conditionsMet = false;
|
2018-05-02 00:43:31 +00:00
|
|
|
SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::None);
|
|
|
|
}
|
2018-04-30 03:12:41 +00:00
|
|
|
|
2018-05-02 00:43:31 +00:00
|
|
|
if (GetScannableObjectInfo())
|
2018-05-07 00:47:40 +00:00
|
|
|
AddMaterial(EMaterialTypes::Solid, EMaterialTypes::Metal, EMaterialTypes::Occluder, EMaterialTypes::Orbit, EMaterialTypes::Scannable, mgr);
|
2018-05-02 00:43:31 +00:00
|
|
|
else
|
2018-05-07 00:47:40 +00:00
|
|
|
AddMaterial(EMaterialTypes::Solid, EMaterialTypes::Metal, EMaterialTypes::Occluder, EMaterialTypes::Orbit, mgr);
|
2018-05-02 00:43:31 +00:00
|
|
|
}
|
2018-04-30 03:12:41 +00:00
|
|
|
|
|
|
|
if (x64_modelData->IsAnimating())
|
2018-05-07 00:47:40 +00:00
|
|
|
UpdateAnimation((x64_modelData->GetAnimationDuration(s32(x260_doorState)) / x258_animLen) * dt, mgr, true);
|
2018-04-30 03:12:41 +00:00
|
|
|
|
|
|
|
xe7_31_targetable = mgr.GetPlayerState()->GetCurrentVisor() == CPlayerState::EPlayerVisor::Scan;
|
2016-04-24 02:46:13 +00:00
|
|
|
}
|
|
|
|
|
2018-05-02 00:43:31 +00:00
|
|
|
void CScriptDoor::AddToRenderer(const zeus::CFrustum& /*frustum*/, const CStateManager &mgr) const
|
2016-04-23 10:51:53 +00:00
|
|
|
{
|
2017-08-13 07:56:35 +00:00
|
|
|
if (!xe4_30_outOfFrustum)
|
2016-04-23 10:51:53 +00:00
|
|
|
CPhysicsActor::Render(mgr);
|
|
|
|
}
|
|
|
|
|
2016-04-23 00:29:55 +00:00
|
|
|
/* ORIGINAL 0-00 OFFSET: 8007E0BC */
|
2016-04-22 20:22:45 +00:00
|
|
|
void CScriptDoor::ForceClosed(CStateManager & mgr)
|
|
|
|
{
|
2018-05-02 00:43:31 +00:00
|
|
|
if (x2a8_26_isOpen)
|
2016-04-22 20:22:45 +00:00
|
|
|
{
|
2018-05-02 00:43:31 +00:00
|
|
|
x2a8_26_isOpen = false;
|
2018-05-07 00:47:40 +00:00
|
|
|
x2a8_25_wasOpen = false;
|
2016-04-22 20:22:45 +00:00
|
|
|
|
2017-10-09 02:41:50 +00:00
|
|
|
mgr.GetCameraManager()->GetBallCamera()->DoorClosing(x8_uid);
|
|
|
|
mgr.GetCameraManager()->GetBallCamera()->DoorClosed(x8_uid);
|
2016-04-22 20:22:45 +00:00
|
|
|
|
2016-04-23 18:04:49 +00:00
|
|
|
SetDoorAnimation(EDoorAnimType::Close);
|
2016-04-22 20:22:45 +00:00
|
|
|
SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::None);
|
|
|
|
|
2018-05-02 00:43:31 +00:00
|
|
|
x25c_animTime = 0.f;
|
2018-05-07 00:47:40 +00:00
|
|
|
x2a8_27_conditionsMet = false;
|
|
|
|
x2a8_30_doClose = false;
|
2016-04-22 20:22:45 +00:00
|
|
|
}
|
2018-05-07 00:47:40 +00:00
|
|
|
else if (x2a8_27_conditionsMet)
|
2016-04-22 20:22:45 +00:00
|
|
|
{
|
2018-05-07 00:47:40 +00:00
|
|
|
x2a8_27_conditionsMet = false;
|
|
|
|
x2a8_30_doClose = false;
|
2016-04-22 20:22:45 +00:00
|
|
|
SendScriptMsgs(EScriptObjectState::Closed, mgr, EScriptObjectMessage::None);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-23 00:29:55 +00:00
|
|
|
/* ORIGINAL 0-00 OFFSET: 8007E1C4 */
|
2018-04-30 03:12:41 +00:00
|
|
|
bool CScriptDoor::IsConnectedToArea(const CStateManager& mgr, TAreaId areaId)
|
2016-04-23 00:29:55 +00:00
|
|
|
{
|
2018-05-02 00:43:31 +00:00
|
|
|
const CScriptDock* dockEnt = TCastToConstPtr<CScriptDock>(mgr.GetObjectById(x282_dockId));
|
|
|
|
if (dockEnt)
|
2016-04-23 00:29:55 +00:00
|
|
|
{
|
2018-05-02 00:43:31 +00:00
|
|
|
if (dockEnt->GetAreaId() == areaId)
|
2018-04-30 03:12:41 +00:00
|
|
|
return true;
|
|
|
|
|
2018-05-02 00:43:31 +00:00
|
|
|
const CWorld* world = mgr.GetWorld();
|
|
|
|
const CGameArea* area = world->GetAreaAlways(dockEnt->GetAreaId());
|
|
|
|
const CGameArea::Dock* dock = area->GetDock(dockEnt->GetDockId());
|
|
|
|
if (dock->GetConnectedAreaId(dockEnt->GetDockReference(mgr)) == areaId)
|
2016-04-23 00:29:55 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ORIGINAL 0-00 OFFSET: 8007EA64 */
|
2016-04-22 20:22:45 +00:00
|
|
|
void CScriptDoor::OpenDoor(TUniqueId uid, CStateManager& mgr)
|
|
|
|
{
|
|
|
|
TEditorId eid = mgr.GetEditorIdForUniqueId(uid);
|
|
|
|
mgr.MapWorldInfo()->SetDoorVisited(eid, true);
|
2018-05-02 00:43:31 +00:00
|
|
|
x2a8_26_isOpen = true;
|
2018-05-07 00:47:40 +00:00
|
|
|
x2a8_25_wasOpen = true;
|
|
|
|
x2a8_27_conditionsMet = false;
|
2018-05-20 06:14:57 +00:00
|
|
|
x27c_partner1 = kInvalidUniqueId;
|
|
|
|
x27e_partner2 = kInvalidUniqueId;
|
2016-04-22 20:22:45 +00:00
|
|
|
|
2018-05-02 00:43:31 +00:00
|
|
|
if (const CScriptDoor* door = TCastToConstPtr<CScriptDoor>(mgr.GetObjectById(uid)))
|
2018-04-30 03:12:41 +00:00
|
|
|
x27c_partner1 = door->GetUniqueId();
|
2016-04-22 20:22:45 +00:00
|
|
|
|
2016-04-23 18:04:49 +00:00
|
|
|
SetDoorAnimation(EDoorAnimType::Open);
|
2018-04-30 03:12:41 +00:00
|
|
|
if (x27c_partner1 == kInvalidUniqueId)
|
|
|
|
SendScriptMsgs(EScriptObjectState::Open, mgr, EScriptObjectMessage::None);
|
2016-04-22 20:22:45 +00:00
|
|
|
else
|
2018-04-30 03:12:41 +00:00
|
|
|
SendScriptMsgs(EScriptObjectState::MaxReached, mgr, EScriptObjectMessage::None);
|
|
|
|
|
|
|
|
if (TCastToConstPtr<CScriptDock> dock1 = mgr.GetObjectById(x282_dockId))
|
2016-04-22 20:22:45 +00:00
|
|
|
{
|
2018-04-30 03:12:41 +00:00
|
|
|
for (CEntity* ent : mgr.GetPlatformAndDoorObjectList())
|
|
|
|
{
|
|
|
|
TCastToConstPtr<CScriptDoor> door = ent;
|
2018-05-20 06:14:57 +00:00
|
|
|
if (!door || door->GetUniqueId() == uid)
|
2018-04-30 03:12:41 +00:00
|
|
|
continue;
|
|
|
|
|
2018-05-20 06:14:57 +00:00
|
|
|
if (TCastToConstPtr<CScriptDock> dock2 = mgr.GetObjectById(door->x282_dockId))
|
2018-04-30 03:12:41 +00:00
|
|
|
{
|
2018-05-20 06:14:57 +00:00
|
|
|
if (dock1->GetCurrentConnectedAreaId(mgr) == dock2->GetAreaId() &&
|
|
|
|
dock2->GetCurrentConnectedAreaId(mgr) == dock1->GetAreaId())
|
2018-04-30 03:12:41 +00:00
|
|
|
{
|
|
|
|
x27e_partner2 = door->GetUniqueId();
|
|
|
|
mgr.SendScriptMsg(ent, GetUniqueId(), EScriptObjectMessage::Open);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-04-22 20:22:45 +00:00
|
|
|
|
2018-04-30 03:12:41 +00:00
|
|
|
if (x27c_partner1 == kInvalidUniqueId && x27e_partner2 == kInvalidUniqueId)
|
|
|
|
{
|
|
|
|
for (const SConnection& conn : x20_conns)
|
|
|
|
{
|
|
|
|
if (conn.x4_msg != EScriptObjectMessage::Open)
|
|
|
|
continue;
|
|
|
|
if (TCastToConstPtr<CScriptDoor> door = mgr.GetObjectById(mgr.GetIdForScript(conn.x8_objId)))
|
2018-05-07 00:47:40 +00:00
|
|
|
{
|
2018-04-30 03:12:41 +00:00
|
|
|
x27e_partner2 = door->GetUniqueId();
|
2018-05-07 00:47:40 +00:00
|
|
|
break;
|
|
|
|
}
|
2018-04-30 03:12:41 +00:00
|
|
|
}
|
2016-04-22 20:22:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-23 00:29:55 +00:00
|
|
|
/* ORIGINAL 0-00 OFFSET: 8007ED4C */
|
|
|
|
u32 CScriptDoor::GetDoorOpenCondition(CStateManager& mgr)
|
|
|
|
{
|
2018-04-30 03:12:41 +00:00
|
|
|
const TCastToPtr<CScriptDock> dock = mgr.ObjectById(x282_dockId);
|
2016-04-23 00:29:55 +00:00
|
|
|
if (!dock)
|
|
|
|
return 2;
|
|
|
|
|
2018-05-07 00:47:40 +00:00
|
|
|
if (x25c_animTime < 0.05f || x2a8_30_doClose)
|
2018-04-30 03:12:41 +00:00
|
|
|
return 1;
|
|
|
|
|
2018-05-02 00:43:31 +00:00
|
|
|
TAreaId destArea = dock->GetAreaId();
|
|
|
|
if (destArea < 0 || destArea >= mgr.GetWorld()->GetNumAreas())
|
2018-04-30 03:12:41 +00:00
|
|
|
return 0;
|
|
|
|
|
2018-05-19 21:14:37 +00:00
|
|
|
if (!mgr.GetWorld()->GetAreaAlways(destArea)->IsPostConstructed())
|
|
|
|
return 1;
|
|
|
|
|
2018-04-30 03:12:41 +00:00
|
|
|
if (!mgr.GetWorld()->AreSkyNeedsMet())
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
TAreaId connArea = mgr.GetWorld()->GetAreaAlways(
|
2018-05-02 00:43:31 +00:00
|
|
|
dock->GetAreaId())->GetDock(
|
2018-04-30 03:12:41 +00:00
|
|
|
dock->GetDockId())->GetConnectedAreaId(dock->GetDockReference(mgr));
|
|
|
|
|
|
|
|
if (connArea == kInvalidAreaId)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
const CWorld* world = mgr.GetWorld();
|
|
|
|
const CGameArea* area = world->GetAreaAlways(connArea);
|
|
|
|
|
|
|
|
if (!area->IsPostConstructed())
|
|
|
|
{
|
|
|
|
mgr.SendScriptMsg(dock, GetUniqueId(), EScriptObjectMessage::SetToMax);
|
2016-04-23 00:29:55 +00:00
|
|
|
return 1;
|
2018-04-30 03:12:41 +00:00
|
|
|
}
|
|
|
|
|
2018-05-14 04:38:58 +00:00
|
|
|
if (area->GetPostConstructed()->x113c_playerActorsLoading != 0)
|
2018-04-30 03:12:41 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
for (CEntity* ent : mgr.GetPlatformAndDoorObjectList())
|
|
|
|
{
|
|
|
|
TCastToPtr<CScriptDoor> door(ent);
|
|
|
|
if (!door || door->GetUniqueId() == GetUniqueId())
|
|
|
|
continue;
|
|
|
|
|
2018-05-07 00:47:40 +00:00
|
|
|
if (door->GetAreaIdAlways() == GetAreaIdAlways() && door->x2a8_25_wasOpen)
|
2018-04-30 03:12:41 +00:00
|
|
|
{
|
|
|
|
if (door->x282_dockId != kInvalidUniqueId)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-07 00:47:40 +00:00
|
|
|
for (const CGameArea& aliveArea : *world)
|
2018-04-30 03:12:41 +00:00
|
|
|
{
|
2018-05-07 00:47:40 +00:00
|
|
|
if (aliveArea.GetAreaId() == area->GetAreaId())
|
2018-04-30 03:12:41 +00:00
|
|
|
continue;
|
|
|
|
|
2018-05-07 00:47:40 +00:00
|
|
|
if (!aliveArea.IsFinishedOccluding())
|
2018-04-30 03:12:41 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//if (area->TryTakingOutOfARAM())
|
|
|
|
{
|
|
|
|
if (world->GetMapWorld()->IsMapAreasStreaming())
|
|
|
|
return 1;
|
|
|
|
}
|
2016-04-23 00:29:55 +00:00
|
|
|
|
2018-04-30 03:12:41 +00:00
|
|
|
return 2;
|
2016-04-23 00:29:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ORIGINAL 0-00 OFFSET: 8007E9D0 */
|
2016-04-22 20:22:45 +00:00
|
|
|
void CScriptDoor::SetDoorAnimation(CScriptDoor::EDoorAnimType type)
|
|
|
|
{
|
2016-04-23 18:04:49 +00:00
|
|
|
x260_doorState = type;
|
2016-04-22 20:22:45 +00:00
|
|
|
CModelData* modelData = x64_modelData.get();
|
2016-04-23 18:04:49 +00:00
|
|
|
if (modelData && modelData->AnimationData())
|
|
|
|
modelData->AnimationData()->SetAnimation(CAnimPlaybackParms(s32(type), -1, 1.f, true), false);
|
2016-04-19 21:25:26 +00:00
|
|
|
}
|
|
|
|
|
2018-06-28 06:47:34 +00:00
|
|
|
std::experimental::optional<zeus::CAABox> CScriptDoor::GetTouchBounds() const
|
|
|
|
{
|
|
|
|
if (GetActive() && GetMaterialList().HasMaterial(EMaterialTypes::Solid))
|
|
|
|
return {CPhysicsActor::GetBoundingBox()};
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2018-04-30 03:12:41 +00:00
|
|
|
std::experimental::optional<zeus::CAABox> CScriptDoor::GetProjectileBounds() const
|
2018-02-09 07:12:26 +00:00
|
|
|
{
|
2018-05-07 00:47:40 +00:00
|
|
|
if (x2a8_28_projectilesCollide)
|
2018-02-09 07:12:26 +00:00
|
|
|
return {{x284_modelBounds.min + GetTranslation(), x284_modelBounds.max + GetTranslation()}};
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2016-04-19 21:25:26 +00:00
|
|
|
}
|