File size: 6,911 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 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
/*!
Base native class of all vehicles in game.
*/
class Transport extends EntityAI
{
ref TIntArray m_SingleUseActions;
ref TIntArray m_ContinuousActions;
ref TIntArray m_InteractActions;
void Transport()
{
}
override int GetMeleeTargetType()
{
return EMeleeTargetType.NONALIGNABLE;
}
//! Synchronizes car's state in case the simulation is not running.
proto native void Synchronize();
//! Returns crew capacity of this vehicle.
proto native int CrewSize();
//! Returns crew member index based on action component index.
//! -1 is returned when no crew position corresponds to given component index.
proto native int CrewPositionIndex( int componentIdx );
//! Returns crew member index based on player's instance.
//! -1 is returned when the player is not isnide.
proto native int CrewMemberIndex( Human player );
//! Returns crew member based on position index.
//! Null can be returned if no Human is present on the given position.
proto native Human CrewMember( int posIdx );
//! Reads entry point and direction into vehicle on given position in model space.
proto void CrewEntry( int posIdx, out vector pos, out vector dir );
//! Reads entry point and direction into vehicle on given position in world space.
proto void CrewEntryWS( int posIdx, out vector pos, out vector dir );
//! Returns crew transformation indside vehicle in model space
proto void CrewTransform( int posIdx, out vector mat[4] );
//! Returns crew transformation indside vehicle in world space
proto void CrewTransformWS( int posIdx, out vector mat[4] );
//! Performs transfer of player from world into vehicle on given position.
proto native void CrewGetIn( Human player, int posIdx );
//! Performs transfer of player from vehicle into world from given position.
proto native Human CrewGetOut( int posIdx );
//! Handles death of player in vehicle and awakes its physics if needed
proto native void CrewDeath( int posIdx );
override bool IsTransport()
{
return true;
}
override bool IsIgnoredByConstruction()
{
return false;
}
override bool IsHealthVisible()
{
return true;
}
override bool ShowZonesHealth()
{
return true;
}
bool IsAnyCrewPresent()
{
for (int index = 0; index < CrewSize(); ++index)
{
if (CrewMember(index) != null)
return true;
}
return false;
}
float GetTransportCameraDistance()
{
return 4.0;
}
void MarkCrewMemberUnconscious(int crewMemberIndex);
void MarkCrewMemberDead(int crewMemberIndex);
protected void HandleByCrewMemberState(ECrewMemberState state);
vector GetTransportCameraOffset()
{
return "0 1.3 0";
}
int GetAnimInstance()
{
#ifndef CFGMODS_DEFINE_TEST
Error("GetAnimInstance() not implemented");
return 0;
#else
return 2;
#endif
}
int GetSeatAnimationType( int posIdx )
{
#ifndef CFGMODS_DEFINE_TEST
Error("GetSeatAnimationType() not implemented");
#endif
return 0;
}
int Get3rdPersonCameraType()
{
#ifndef CFGMODS_DEFINE_TEST
Error("Get3rdPersonCameraType() not implemented");
return 0;
#else
return 31;
#endif
}
bool CrewCanGetThrough( int posIdx )
{
#ifndef CFGMODS_DEFINE_TEST
return false;
#else
return true;
#endif
}
bool CanReachSeatFromSeat( int currentSeat, int nextSeat )
{
#ifndef CFGMODS_DEFINE_TEST
return false;
#else
return true;
#endif
}
bool CanReachSeatFromDoors( string pSeatSelection, vector pFromPos, float pDistance = 1.0 )
{
#ifndef CFGMODS_DEFINE_TEST
return false;
#else
return true;
#endif
}
bool CanReachDoorsFromSeat( string pDoorsSelection, int pCurrentSeat )
{
#ifndef CFGMODS_DEFINE_TEST
return false;
#else
return true;
#endif
}
int GetSeatIndexFromDoor( string pDoorSelection )
{
//Potientially could be fixed some other way, currently follows the unfortunate pattern that CanReachDoorsFromSeat has created
switch (pDoorSelection)
{
case "DoorsDriver":
return 0;
break;
case "DoorsCoDriver":
return 1;
break;
case "DoorsCargo1":
return 2;
break;
case "DoorsCargo2":
return 3;
break;
}
return -1;
}
bool IsIgnoredObject( Object o )
{
if (!o)
return false;
//! If the player can't interact (hint: collide) with the object, then it is ignored
int layer = dBodyGetInteractionLayer(o);
bool interacts = dGetInteractionLayer(this, PhxInteractionLayers.CHARACTER, layer);
if (!interacts)
{
return true;
}
DayZPlayer player;
if (Class.CastTo(player, o))
{
//! Ignore any player that is currently in this vehicle
HumanCommandVehicle hcv = player.GetCommand_Vehicle();
if (hcv && hcv.GetTransport() == this)
{
return true;
}
}
EntityAI e = EntityAI.Cast(o);
// CanBeSkinned means it is a dead entity which should not block the door
return ( ( e && (e.IsZombie() || e.IsHologram()) ) || o.CanBeSkinned() || o.IsBush() || o.IsTree() );
}
bool IsAreaAtDoorFree( int currentSeat, float maxAllowedObjHeight, inout vector extents, out vector transform[4] )
{
GetTransform(transform);
vector crewPos;
vector crewDir;
CrewEntry( currentSeat, crewPos, crewDir );
vector entry[4];
entry[2] = crewDir;
entry[0] = vector.Up * crewDir;
entry[1] = entry[2] * entry[0];
entry[3] = crewPos;
Math3D.MatrixMultiply4( transform, entry, transform );
vector position = transform[3];
vector orientation = Math3D.MatrixToAngles(transform);
position[1] = position[1] + maxAllowedObjHeight + (extents[1] * 0.5);
array<Object> excluded = new array<Object>;
array<Object> collided = new array<Object>;
excluded.Insert(this);
GetGame().IsBoxColliding(position, orientation, extents, excluded, collided);
orientation.RotationMatrixFromAngles(transform);
transform[3] = position;
foreach (Object o : collided)
{
EntityAI e = EntityAI.Cast(o);
if (IsIgnoredObject(o))
continue;
vector minmax[2];
if (o.GetCollisionBox(minmax))
return false;
}
return true;
}
bool IsAreaAtDoorFree( int currentSeat, float maxAllowedObjHeight = 0.5, float horizontalExtents = 0.5, float playerHeight = 1.7 )
{
vector transform[4];
vector extents;
extents[0] = horizontalExtents;
extents[1] = playerHeight;
extents[2] = horizontalExtents;
return IsAreaAtDoorFree( currentSeat, maxAllowedObjHeight, extents, transform );
}
Shape DebugFreeAreaAtDoor( int currentSeat, float maxAllowedObjHeight = 0.5, float horizontalExtents = 0.5, float playerHeight = 1.7 )
{
int color = ARGB(20, 0, 255, 0);
vector transform[4];
vector extents;
extents[0] = horizontalExtents;
extents[1] = playerHeight;
extents[2] = horizontalExtents;
if (!IsAreaAtDoorFree( currentSeat, maxAllowedObjHeight, extents, transform ))
{
color = ARGB(20, 255, 0, 0);
}
Shape shape = Debug.DrawBox(-extents * 0.5, extents * 0.5, color);
shape.SetMatrix(transform);
return shape;
}
};
|