File size: 5,597 Bytes
24b81cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/**@class	CargoBase
 * @brief	represents base for cargo storage for entities
 *
 * @NOTE: rows == y axis
 **/
class CargoBase : Managed
{
	/**@fn			GetCargoOwner
	 * @brief		get the entity that owns the cargo
	 * @return		cargo owner
	 **/
	proto native EntityAI GetCargoOwner ();

	/**@fn			GetCargoOwnerIndex
	 * @brief		get index of this cargo in the entity that owns the cargo
	 * @return		owner's index of this cargo
	 **/
	proto native int GetOwnerCargoIndex ();

	/**@fn			IsProxyCargo
	 * @return		true if cargo is in proxy object
	 **/	
	proto native bool IsProxyCargo ();
	
	/**@fn			GetItemCount
	 * @return		number of items in cargo
	 **/
	proto native int GetItemCount ();
	/**@fn			GetItem
	 * @return		get item at specific index
	 **/
	proto native EntityAI GetItem (int index);

	/**@fn			GetWidth
	 * @return		width of the cargo
	 **/
	proto native int GetWidth ();
	/**@fn			GetHeight
	 * @return		height of the cargo
	 **/
	proto native int GetHeight ();
	/**@fn			GetItemRowCol
	 * @param[out]	row			returned row of the item at internal index
	 * @param[out]	col			returned col. 0 on xbox
	 **/
	proto bool GetItemRowCol (int index, out int row, out int col);
	/**@fn			GetItemSize
	 * @param[out]	w			returned width of the item at internal index
	 * @param[out]	h			returned height of the item at internal index
	 **/
	proto bool GetItemSize (int index, out int w, out int h);

	/**@fn			FindEntityInCargo
	 * @return		find internal index of the entity in cargo or -1 if not found
	 **/
	proto native int FindEntityInCargo (notnull EntityAI e);

	private void CargoBase ();
	private void ~CargoBase ();
	
	/**@fn			CanReceiveItemIntoCargo
	 * @brief		condition EntityAI::CanReceiveItemIntoCargo for Cargo.
	 * @return		true if cargo can be added, false otherwise
	 **/
	bool CanReceiveItemIntoCargo (EntityAI item) { return true; }

	/**@fn			CanSwapItemInCargo
	 * @brief		condition EntityAI::CanSwapItemInCargo for Cargo.
	 * @return		true if cargo can be added, false otherwise
	 **/
	bool CanSwapItemInCargo (EntityAI child_entity, EntityAI new_entity) { return true; }
	
	proto native int GetUserReservedLocationCount ();
	/**@fn			GetUserReservedLocation
	 * @param[in]	idx			index of the user reserved location
	 * @param[out]	eai			returned entity of the user reservation at internal index
	 * @param[out]	row			returned row of the user reservation at internal index
	 * @param[out]	col			returned col
	 * @param[out]	w			returned width of the user reservation at internal index
	 * @param[out]	h			returned height of the user reservation at internal index
	 * @param[out]	flp			returned flip
	 * @return		true if record found, false otherwise
	 **/
	proto bool GetUserReservedLocation (int index, out EntityAI eai, out int row, out int col, out int w, out int h, out int flp);
	proto native void SetUserReservedLocation (notnull EntityAI eai);
	proto native void ClearUserReservedLocation (notnull EntityAI eai);
};


#ifdef PLATFORM_CONSOLE
	class CargoList : CargoBase
	{
		/**@fn			GetMaxWeight
		 * @return		maximum weight that the cargo can hold
		 **/
		proto native int GetMaxWeight ();
	
		/**@fn			GetTotalWeight
		 * @brief		sums weight of all items in cargo and adds weight of item if item != null
		 * @return		sum of weights plus weight of item (if !null)
		 **/
		proto native int GetTotalWeight (EntityAI item);

		/**@fn			CanFitItemIntoCargo
		 * @return		true if adding item does not exceed GetMaxWeight, false otherwise
		 **/		
		proto native bool CanFitItemIntoCargo (EntityAI cargo);
	
		/**@fn			CanReceiveItemIntoCargo
		 * @return		true if adding item does not exceed GetMaxWeight, false otherwise
		 **/
		override bool CanReceiveItemIntoCargo (EntityAI item)
		{
			return true;
			//return CanFitItemIntoCargo(item);
		}
	
		/**@fn			CanFitSwappedItemInCargo
		 * @return		true if swapping item does not exceed GetMaxWeight, false otherwise
		 **/		
		proto native bool CanFitSwappedItemInCargo (EntityAI child_entity, EntityAI new_entity);
	
		override bool CanSwapItemInCargo (EntityAI child_entity, EntityAI new_entity)
		{
			return CanFitSwappedItemInCargo(child_entity, new_entity);
		}
	};
#else
#ifdef SERVER_FOR_CONSOLE
	class CargoList : CargoBase
	{
		/**@fn			GetMaxWeight
		 * @return		maximum weight that the cargo can hold
		 **/
		proto native int GetMaxWeight ();
	
		/**@fn			GetTotalWeight
		 * @brief		sums weight of all items in cargo and adds weight of item if item != null
		 * @return		sum of weights plus weight of item (if !null)
		 **/
		proto native int GetTotalWeight (EntityAI item);

		/**@fn			CanFitItemIntoCargo
		 * @return		true if adding item does not exceed GetMaxWeight, false otherwise
		 **/		
		proto native bool CanFitItemIntoCargo (EntityAI cargo);
	
		/**@fn			CanReceiveItemIntoCargo
		 * @return		true if adding item does not exceed GetMaxWeight, false otherwise
		 **/
		override bool CanReceiveItemIntoCargo (EntityAI item)
		{
			return true; 
			//return CanFitItemIntoCargo(item);
		}
	
		/**@fn			CanFitSwappedItemInCargo
		 * @return		true if swapping item does not exceed GetMaxWeight, false otherwise
		 **/		
		proto native bool CanFitSwappedItemInCargo (EntityAI child_entity, EntityAI new_entity);
	
		override bool CanSwapItemInCargo (EntityAI child_entity, EntityAI new_entity)
		{
			return CanFitSwappedItemInCargo(child_entity, new_entity);
		}
	};
#else
	class CargoGrid : CargoBase
	{
		/**@fn			FindEntityInCargoOn
		 * @return		get item at coordinates (row, col). col is 0 on xbox.
		 **/
		proto native EntityAI FindEntityInCargoOn (int row, int col);
	};
#endif
#endif