summaryrefslogtreecommitdiffstats
path: root/src/peds/PedAttractor.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/peds/PedAttractor.h')
-rw-r--r--src/peds/PedAttractor.h145
1 files changed, 80 insertions, 65 deletions
diff --git a/src/peds/PedAttractor.h b/src/peds/PedAttractor.h
index 3e7e53df..3171d228 100644
--- a/src/peds/PedAttractor.h
+++ b/src/peds/PedAttractor.h
@@ -7,6 +7,64 @@
#define NUM_ATTRACTORS_FOR_ICECREAM_VAN 4
+class CPedAttractor;
+
+class CVehicleToEffect
+{
+ CVehicle* m_pVehicle;
+ C2dEffect m_effects[NUM_ATTRACTORS_FOR_ICECREAM_VAN];
+
+public:
+ CVehicleToEffect(CVehicle* pVehicle);
+ const C2dEffect* ChooseEffect(const CVector& pos) const;
+ CVehicleToEffect& From(const CVehicleToEffect& other);
+ CVehicleToEffect& operator=(const CVehicleToEffect& other) { return From(other); }
+ ~CVehicleToEffect() { m_pVehicle = nil; }
+ CVehicle* GetVehicle() const { return m_pVehicle; }
+ bool HasThisEffect(C2dEffect* pEffect) const;
+ const C2dEffect* GetEffect(int32 i) const { return &m_effects[i]; }
+};
+
+class CPedAttractorManager
+{
+ std::vector<CPedAttractor*> vAtmAttractors;
+ std::vector<CPedAttractor*> vSeatAttractors;
+ std::vector<CPedAttractor*> vStopAttractors;
+ std::vector<CPedAttractor*> vPizzaAttractors;
+ std::vector<CPedAttractor*> vShelterAttractors;
+ std::vector<CPedAttractor*> vIceCreamAttractors;
+ std::vector<CVehicleToEffect> vVehicleToEffect;
+
+public:
+ CPedAttractor* RegisterPedWithAttractor(CPed* pPed, C2dEffect* pEffect, const CMatrix& matrix);
+ CPedAttractor* RegisterPed(CPed* pPed, C2dEffect* pEffect, const CMatrix& matrix, std::vector<CPedAttractor*>& vecAttractors);
+ bool BroadcastArrival(CPed* pPed, CPedAttractor* pAttractor);
+ bool BroadcastArrival(CPed* pPed, CPedAttractor* pAttractor, std::vector<CPedAttractor*>& vecAttractors);
+ const C2dEffect* GetEffectForIceCreamVan(CVehicle* pVehicle, const CVector& pos);
+ bool IsApproachable(C2dEffect* pEffect, const CMatrix& matrix, int32, CPed* pPed);
+ void RemoveIceCreamVanEffects(C2dEffect* pEffect);
+ bool HasEmptySlot(const C2dEffect* pEffect);
+ const CPedAttractor* FindAssociatedAttractor(const C2dEffect* pEffect, std::vector<CPedAttractor*>& vecAttractors);
+ bool IsInQueue(CPed* pPed, CPedAttractor* pAttractor);
+ bool IsInQueue(CPed* pPed, CPedAttractor* pAttractor, std::vector<CPedAttractor*>& vecAttractors);
+ bool IsAtHeadOfQueue(CPed* pPed, CPedAttractor* pAttractor);
+ bool IsAtHeadOfQueue(CPed* pPed, CPedAttractor* pAttractor, std::vector<CPedAttractor*>& vecAttractors);
+ bool BroadcastDeparture(CPed* pPed, CPedAttractor* pAttractor);
+ bool BroadcastDeparture(CPed* pPed, CPedAttractor* pAttractor, std::vector<CPedAttractor*>& vecAttractors);
+ bool DeRegisterPed(CPed* pPed, CPedAttractor* pAttractor);
+ bool DeRegisterPed(CPed* pPed, CPedAttractor* pAttractor, std::vector<CPedAttractor*>& vecAttractors);
+ bool IsPedRegisteredWithEffect(CPed* pPed);
+ bool IsPedRegistered(CPed* pPed, std::vector<CPedAttractor*>& vecAttractors);
+ CVehicle* GetIceCreamVanForEffect(C2dEffect* pEffect);
+
+ static void ComputeEffectPos(const C2dEffect* pEffect, const CMatrix& matrix, CVector& pos);
+ static void ComputeEffectQueueDir(const C2dEffect* pEffect, const CMatrix& matrix, CVector& pos);
+ static void ComputeEffectUseDir(const C2dEffect* pEffect, const CMatrix& matrix, CVector& pos);
+
+};
+
+CPedAttractorManager* GetPedAttractorManager();
+
enum ePedAttractorType
{
ATTRACTOR_ATM = 0,
@@ -27,8 +85,8 @@ protected:
float m_fQueueDistance;
float m_fTimeInWaitQueue;
float m_fTimeInApproachingQueue;
- float field_30;
- float field_34;
+ float m_fDistanceToUseAttractor;
+ float m_fAcceptableHeading;
float m_fMaxPositionDisplacement;
float m_fMaxHeadingDisplacement;
CVector vecEffectPos;
@@ -39,7 +97,7 @@ public:
virtual float GetHeadOfQueueWaitTime() { return 0.0f; }
virtual ~CPedAttractor() {};
virtual ePedAttractorType GetType() const = 0;
- virtual void UpdatePedStateOnDeparture() const = 0;
+ virtual void UpdatePedStateOnDeparture(CPed* pPed) const = 0;
virtual bool IsAtHeadOfQueue(CPed* pPed) const { return vWaitingQueue.front() == pPed; }
virtual void ComputeAttractPos(int32 id, CVector& pos) const;
virtual void ComputeAttractHeading(int32 id, float& pHeading) const;
@@ -60,13 +118,16 @@ public:
C2dEffect* GetEffect() const { return p2dEffect; }
const CVector& GetEffectPos() const { return vecEffectPos; }
+ int32 GetMaxPedsInAttractor() const { return m_nMaxPedsInAttractor; }
+ float GetDistanceToCountSeekDone() const { return m_fDistanceToUseAttractor; }
+ float GetAcceptableHeading() const { return m_fAcceptableHeading; }
};
class CPedAtmAttractor : public CPedAttractor
{
public:
virtual ePedAttractorType GetType() const override { return ATTRACTOR_ATM; };
- virtual void UpdatePedStateOnDeparture() const override;
+ virtual void UpdatePedStateOnDeparture(CPed* pPed) const override { /* pPed->m_money += 20 * CGeneral::GetRandomNumberInRange(1, 51); */ };
CPedAtmAttractor(C2dEffect* pEffect, const CMatrix& matrix, int32 maxpeds, float qdist, float waitTime, float approachTime, float unk8, float unk9, float posdisp, float headdisp) :
CPedAttractor(pEffect, matrix, maxpeds, qdist, waitTime, approachTime, unk8, unk9, posdisp, headdisp)
{};
@@ -75,8 +136,9 @@ public:
class CPedIceCreamAttractor : public CPedAttractor
{
public:
+ virtual ~CPedIceCreamAttractor() override { GetPedAttractorManager()->RemoveIceCreamVanEffects(p2dEffect); }
virtual ePedAttractorType GetType() const override { return ATTRACTOR_ICECREAM; }
- virtual void UpdatePedStateOnDeparture() const override;
+ virtual void UpdatePedStateOnDeparture(CPed* pPed) const override {};
CPedIceCreamAttractor(C2dEffect* pEffect, const CMatrix& matrix, int32 maxpeds, float qdist, float waitTime, float approachTime, float unk8, float unk9, float posdisp, float headdisp) :
CPedAttractor(pEffect, matrix, maxpeds, qdist, waitTime, approachTime, unk8, unk9, posdisp, headdisp)
{};
@@ -87,7 +149,14 @@ class CPedPizzaAttractor : public CPedAttractor
public:
virtual float GetHeadOfQueueWaitTime() override { return 2000.0f; }
virtual ePedAttractorType GetType() const override { return ATTRACTOR_PIZZA; }
- virtual void UpdatePedStateOnDeparture() const override;
+ virtual void UpdatePedStateOnDeparture(CPed* pPed) const override
+ { /*
+ if (pPed->m_money > 10)
+ pPed->m_money = 0;
+ else
+ pPed->m_money -= 10;
+ */
+ }
CPedPizzaAttractor(C2dEffect* pEffect, const CMatrix& matrix, int32 maxpeds, float qdist, float waitTime, float approachTime, float unk8, float unk9, float posdisp, float headdisp) :
CPedAttractor(pEffect, matrix, maxpeds, qdist, waitTime, approachTime, unk8, unk9, posdisp, headdisp)
{};
@@ -97,7 +166,7 @@ class CPedSeatAttractor : public CPedAttractor
{
public:
virtual ePedAttractorType GetType() const override { return ATTRACTOR_SEAT; }
- virtual void UpdatePedStateOnDeparture() const override;
+ virtual void UpdatePedStateOnDeparture(CPed* pPed) const override {};
CPedSeatAttractor(C2dEffect* pEffect, const CMatrix& matrix, int32 maxpeds, float qdist, float waitTime, float approachTime, float unk8, float unk9, float posdisp, float headdisp) :
CPedAttractor(pEffect, matrix, maxpeds, qdist, waitTime, approachTime, unk8, unk9, posdisp, headdisp)
{};
@@ -109,7 +178,7 @@ class CPedShelterAttractor : public CPedAttractor
public:
virtual ePedAttractorType GetType() const override { return ATTRACTOR_SHELTER; }
virtual bool BroadcastDeparture(CPed*) override;
- virtual void UpdatePedStateOnDeparture() const override;
+ virtual void UpdatePedStateOnDeparture(CPed* pPed) const override {};
virtual bool IsAtHeadOfQueue(CPed* pPed) const override { return true; }
virtual void ComputeAttractPos(int qid, CVector& pos) const override;
virtual void ComputeAttractHeading(int qid, float& heading) const override;
@@ -119,70 +188,16 @@ public:
{};
- CVector GetDisplacement(int32 qid);
+ CVector GetDisplacement(int32 qid) const;
};
class CPedStopAttractor : public CPedAttractor
{
public:
virtual ePedAttractorType GetType() const override { return ATTRACTOR_STOP; }
- virtual void UpdatePedStateOnDeparture() const override;
+ virtual void UpdatePedStateOnDeparture(CPed* pPed) const override {};
CPedStopAttractor(C2dEffect* pEffect, const CMatrix& matrix, int32 maxpeds, float qdist, float waitTime, float approachTime, float unk8, float unk9, float posdisp, float headdisp) :
CPedAttractor(pEffect, matrix, maxpeds, qdist, waitTime, approachTime, unk8, unk9, posdisp, headdisp)
{};
-};
-
-class CVehicleToEffect
-{
- CVehicle* m_pVehicle;
- C2dEffect m_effects[NUM_ATTRACTORS_FOR_ICECREAM_VAN];
-
-public:
- CVehicleToEffect(CVehicle* pVehicle);
- const C2dEffect* ChooseEffect(const CVector& pos) const;
- CVehicleToEffect& From(const CVehicleToEffect& other);
- CVehicleToEffect& operator=(const CVehicleToEffect& other) { return From(other); }
- ~CVehicleToEffect() { m_pVehicle = nil; }
- CVehicle* GetVehicle() const { return m_pVehicle; }
- bool HasThisEffect(C2dEffect* pEffect) const;
- const C2dEffect* GetEffect(int32 i) const { return &m_effects[i]; }
-};
-
-class CPedAttractorManager
-{
- std::vector<CPedAttractor*> vAtmAttractors;
- std::vector<CPedAttractor*> vSeatAttractors;
- std::vector<CPedAttractor*> vStopAttractors;
- std::vector<CPedAttractor*> vPizzaAttractors;
- std::vector<CPedAttractor*> vShelterAttractors;
- std::vector<CPedAttractor*> vIceCreamAttractors;
- std::vector<CVehicleToEffect> vVehicleToEffect;
-
-public:
- CPedAttractor* RegisterPedWithAttractor(CPed* pPed, C2dEffect* pEffect, const CMatrix& matrix);
- CPedAttractor* RegisterPed(CPed* pPed, C2dEffect* pEffect, const CMatrix& matrix, std::vector<CPedAttractor*>& vecAttractors);
- bool BroadcastArrival(CPed* pPed, CPedAttractor* pAttractor);
- bool BroadcastArrival(CPed* pPed, CPedAttractor* pAttractor, std::vector<CPedAttractor*>& vecAttractors);
- const C2dEffect* GetEffectForIceCreamVan(CVehicle* pVehicle, const CVector& pos);
- void ComputeEffectQueueDir(const C2dEffect* pEffect, const CMatrix& matrix, CVector& dir);
- bool IsApproachable(C2dEffect* pEffect, const CMatrix& matrix, int32, CPed* pPed);
- void ComputeEffectUseDir(const C2dEffect* pEffect, const CMatrix& matrix, CVector& dir);
- void ComputeEffectPos(const C2dEffect* pEffect, const CMatrix& matrix, CVector& pos);
- void RemoveIceCreamVanEffects(C2dEffect* pEffect);
- bool HasEmptySlot(const C2dEffect* pEffect);
- const CPedAttractor* FindAssociatedAttractor(const C2dEffect* pEffect, std::vector<CPedAttractor*> vecAttractors);
- bool IsInQueue(CPed* pPed, CPedAttractor* pAttractor);
- bool IsInQueue(CPed* pPed, CPedAttractor* pAttractor, std::vector<CPedAttractor*> vecAttractors);
- bool IsAtHeadOfQueue(CPed* pPed, CPedAttractor* pAttractor);
- bool IsAtHeadOfQueue(CPed* pPed, CPedAttractor* pAttractor, std::vector<CPedAttractor*> vecAttractors);
- bool BroadcastDeparture(CPed* pPed, CPedAttractor* pAttractor);
- bool BroadcastDeparture(CPed* pPed, CPedAttractor* pAttractor, std::vector<CPedAttractor*> vecAttractors);
- bool DeRegisterPed(CPed* pPed, CPedAttractor* pAttractor);
- bool DeRegisterPed(CPed* pPed, CPedAttractor* pAttractor, std::vector<CPedAttractor*> vecAttractors);
- bool IsPedRegisteredWithEffect(CPed* pPed);
- bool IsPedRegistered(CPed* pPed, std::vector<CPedAttractor*> vecAttractors);
- CVehicle* GetIceCreamVanForEffect(C2dEffect* pEffect);
-};
-
-CPedAttractorManager* GetPedAttractorManager(); \ No newline at end of file
+}; \ No newline at end of file