2019-08-11 17:11:54 +00:00
|
|
|
#pragma once
|
|
|
|
#include "common.h"
|
|
|
|
|
2020-04-05 09:35:51 +00:00
|
|
|
#include "World.h"
|
|
|
|
|
2019-08-11 17:11:54 +00:00
|
|
|
class CVehicle;
|
2020-02-24 19:40:39 +00:00
|
|
|
class CEntity;
|
|
|
|
class CObject;
|
2020-04-05 23:01:03 +00:00
|
|
|
class CBuilding;
|
2020-02-24 19:40:39 +00:00
|
|
|
|
|
|
|
class CCrane
|
|
|
|
{
|
|
|
|
public:
|
2020-12-07 00:59:17 +00:00
|
|
|
enum CraneState {
|
2020-04-05 09:35:51 +00:00
|
|
|
IDLE = 0,
|
|
|
|
GOING_TOWARDS_TARGET = 1,
|
|
|
|
LIFTING_TARGET = 2,
|
2020-04-05 23:01:03 +00:00
|
|
|
GOING_TOWARDS_TARGET_ONLY_HEIGHT = 3,
|
2020-04-05 09:35:51 +00:00
|
|
|
ROTATING_TARGET = 4,
|
|
|
|
DROPPING_TARGET = 5
|
|
|
|
};
|
2020-12-07 00:59:17 +00:00
|
|
|
enum CraneStatus {
|
2020-04-05 09:35:51 +00:00
|
|
|
NONE = 0,
|
|
|
|
ACTIVATED = 1,
|
|
|
|
DEACTIVATED = 2
|
|
|
|
};
|
2020-04-05 23:01:03 +00:00
|
|
|
CBuilding *m_pCraneEntity;
|
|
|
|
CObject *m_pHook;
|
2020-02-24 19:40:39 +00:00
|
|
|
float m_fPickupX1;
|
|
|
|
float m_fPickupX2;
|
|
|
|
float m_fPickupY1;
|
|
|
|
float m_fPickupY2;
|
|
|
|
CVector m_vecDropoffTarget;
|
|
|
|
float m_fDropoffHeading;
|
|
|
|
float m_fPickupAngle;
|
|
|
|
float m_fDropoffAngle;
|
|
|
|
float m_fPickupDistance;
|
|
|
|
float m_fDropoffDistance;
|
2020-04-05 23:01:03 +00:00
|
|
|
float m_fPickupHeight;
|
|
|
|
float m_fDropoffHeight;
|
|
|
|
float m_fHookAngle;
|
2020-02-24 19:40:39 +00:00
|
|
|
float m_fHookOffset;
|
|
|
|
float m_fHookHeight;
|
|
|
|
CVector m_vecHookInitPos;
|
|
|
|
CVector m_vecHookCurPos;
|
2020-04-05 23:01:03 +00:00
|
|
|
CVector2D m_vecHookVelocity;
|
2020-02-24 19:40:39 +00:00
|
|
|
CVehicle *m_pVehiclePickedUp;
|
2020-04-05 23:01:03 +00:00
|
|
|
uint32 m_nTimeForNextCheck;
|
2020-12-07 00:59:17 +00:00
|
|
|
uint8 m_nCraneStatus;
|
|
|
|
uint8 m_nCraneState;
|
2020-04-05 23:01:03 +00:00
|
|
|
uint8 m_nVehiclesCollected;
|
2020-04-05 09:35:51 +00:00
|
|
|
bool m_bIsCrusher;
|
|
|
|
bool m_bIsMilitaryCrane;
|
|
|
|
bool m_bWasMilitaryCrane;
|
|
|
|
bool m_bIsTop;
|
|
|
|
|
|
|
|
void Init(void) { memset(this, 0, sizeof(*this)); }
|
|
|
|
void Update(void);
|
2020-04-05 23:01:03 +00:00
|
|
|
bool RotateCarriedCarProperly(void);
|
|
|
|
void FindCarInSectorList(CPtrList* pList);
|
|
|
|
bool DoesCranePickUpThisCarType(uint32 mi);
|
|
|
|
bool GoTowardsTarget(float fAngleToTarget, float fDistanceToTarget, float fTargetHeight, float fSpeedMultiplier = 1.0f);
|
|
|
|
bool GoTowardsHeightTarget(float fTargetHeight, float fSpeedMultiplier = 1.0f);
|
|
|
|
void FindParametersForTarget(float X, float Y, float Z, float* pAngle, float* pDistance, float* pHeight);
|
|
|
|
void CalcHookCoordinates(float* pX, float* pY, float* pZ);
|
|
|
|
void SetHookMatrix(void);
|
|
|
|
|
|
|
|
float GetHeightToPickup() { return 4.0f + m_fPickupHeight + (m_bIsCrusher ? 4.5f : 0.0f); };
|
|
|
|
float GetHeightToDropoff() { return m_bIsCrusher ? (2.0f + m_fDropoffHeight + 3.0f) : (2.0f + m_fDropoffHeight); }
|
|
|
|
float GetHeightToPickupHeight() { return m_fPickupHeight + (m_bIsCrusher ? 7.0f : 4.0f); }
|
|
|
|
float GetHeightToDropoffHeight() { return m_fDropoffHeight + (m_bIsCrusher ? 7.0f : 2.0f); }
|
2020-02-24 19:40:39 +00:00
|
|
|
};
|
|
|
|
|
2020-05-10 15:49:33 +00:00
|
|
|
VALIDATE_SIZE(CCrane, 128);
|
2019-08-11 17:11:54 +00:00
|
|
|
|
|
|
|
class CCranes
|
|
|
|
{
|
|
|
|
public:
|
2020-04-05 09:35:51 +00:00
|
|
|
static void InitCranes(void);
|
2020-04-05 23:01:03 +00:00
|
|
|
static void AddThisOneCrane(CEntity* pCraneEntity);
|
|
|
|
static void ActivateCrane(float fInfX, float fSupX, float fInfY, float fSupY, float fDropOffX, float fDropOffY, float fDropOffZ, float fHeading, bool bIsCrusher, bool bIsMilitary, float fPosX, float fPosY);
|
|
|
|
static void DeActivateCrane(float fX, float fY);
|
|
|
|
static bool IsThisCarPickedUp(float fX, float fY, CVehicle* pVehicle);
|
2019-10-18 22:23:40 +00:00
|
|
|
static void UpdateCranes(void);
|
2020-04-05 23:01:03 +00:00
|
|
|
static bool DoesMilitaryCraneHaveThisOneAlready(uint32 mi);
|
|
|
|
static void RegisterCarForMilitaryCrane(uint32 mi);
|
|
|
|
static bool HaveAllCarsBeenCollectedByMilitaryCrane(void);
|
|
|
|
static bool IsThisCarBeingCarriedByAnyCrane(CVehicle* pVehicle);
|
|
|
|
static bool IsThisCarBeingTargettedByAnyCrane(CVehicle* pVehicle);
|
|
|
|
static void Save(uint8* buf, uint32* size);
|
2020-04-14 10:08:03 +00:00
|
|
|
static void Load(uint8* buf, uint32 size); // on mobile it's CranesLoad outside of the class
|
2020-04-05 09:35:51 +00:00
|
|
|
|
2020-04-14 10:08:03 +00:00
|
|
|
static uint32 CarsCollectedMilitaryCrane;
|
|
|
|
static int32 NumCranes;
|
|
|
|
static CCrane aCranes[NUM_CRANES];
|
2019-08-11 17:11:54 +00:00
|
|
|
};
|