summaryrefslogtreecommitdiffstats
path: root/src/control/Phones.h
blob: 35389f3fdac096ecfafc5a0ac0835fc30e279b36 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#pragma once

#include "Physical.h"

class CPed;
class CAnimBlendAssociation;

enum {
	PHONE_STATE_FREE,
	PHONE_STATE_1,
	PHONE_STATE_2,
	PHONE_STATE_MESSAGE_REMOVED,
	PHONE_STATE_ONETIME_MESSAGE_SET,
	PHONE_STATE_REPEATED_MESSAGE_SET,
	PHONE_STATE_REPEATED_MESSAGE_SHOWN_ONCE,
	PHONE_STATE_ONETIME_MESSAGE_SHOWN,
	PHONE_STATE_REPEATED_MESSAGE_SHOWN,
	PHONE_STATE_9
};

struct CPhone
{
	CVector m_vecPos;
	wchar *m_apMessages[6];
	uint32 m_lastTimeRepeatedMsgShown;
	CEntity *m_pEntity; // it's building pool index in save files
	int32 m_nState;
	uint8 field_30;
};

static_assert(sizeof(CPhone) == 0x34, "CPhone: error");

class CPhoneInfo {
public:
	static bool &isPhonePickedUp;
	static uint32 &phoneMessagesTimer;
	static CPhone *&pickedUpPhone;
	static bool &isPhoneBeingPickedUp;
	static CPed *&pedWhoPickingUpPhone;

	int32 m_nMax;
	int32 m_nNum;
	CPhone m_aPhones[50];

	CPhoneInfo() { }
	~CPhoneInfo() { }

	int FindNearestFreePhone(CVector*);
	bool PhoneAtThisPosition(CVector);
	bool HasMessageBeenDisplayed(int);
	bool IsMessageBeingDisplayed(int);
	void Load(CPhoneInfo *source, uint8 buffer);
	void SetPhoneMessage_JustOnce(int phoneId, wchar *msg1, wchar *msg2, wchar *msg3, wchar *msg4, wchar *msg5, wchar *msg6);
	void SetPhoneMessage_Repeatedly(int phoneId, wchar *msg1, wchar *msg2, wchar *msg3, wchar *msg4, wchar *msg5, wchar *msg6);
	int GrabPhone(float, float);
	void Initialise(void);
	void Save(CPhoneInfo*, uint32*);
	void Shutdown(void);
};

extern CPhoneInfo &gPhoneInfo;

void PhonePutDownCB(CAnimBlendAssociation *assoc, void *arg);
void PhonePickUpCB(CAnimBlendAssociation *assoc, void *arg);