DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ ThrowEntityFromInventory()

static void ThrowEntityFromInventory ( notnull EntityAI entity,
vector position,
float direction[4],
vector force,
int flags )
staticprotected

См. определение в файле MiscGameplayFunctions.c строка 1154

1155 {
1156 InventoryMode invMode = InventoryMode.SERVER;
1157 if ( !GetGame().IsMultiplayer() )
1158 invMode = InventoryMode.LOCAL;
1159
1160 ItemBase entityIB;
1161 if (CastTo(entityIB, entity))
1162 {
1164 dst.SetGroundEx(entity, position, direction);
1165
1166 if ( (flags & ThrowEntityFlags.SPLIT) && entityIB.CanBeSplit() )
1167 {
1168 for (int l = 0; l < entityIB.GetQuantity(); ++l)
1169 {
1170 ItemBase new_item = ItemBase.Cast( GameInventory.LocationCreateEntity( dst, entityIB.GetType(), ECE_NONE, RF_DEFAULT ) );
1171
1172 if ( new_item )
1173 {
1174 MiscGameplayFunctions.TransferItemProperties(entityIB, new_item);
1175 entityIB.AddQuantity( -1 );
1176 new_item.SetQuantity( 1 );
1177 new_item.ThrowPhysically(null, force, false);
1178 }
1179 }
1180 }
1181 else
1182 {
1183 float stackable = entityIB.GetTargetQuantityMax();
1184 if ( !(stackable == 0 || stackable >= entityIB.GetQuantity()) )
1185 {
1186 while (entityIB.GetQuantity() > stackable)
1187 {
1189 position[1] = position[1] + 0.1;
1190 spltDst.SetGroundEx(entity, position, direction);
1191
1192 ItemBase splitItem = entityIB.SplitIntoStackMaxToInventoryLocationEx( spltDst );
1193 splitItem.ThrowPhysically(null, force, false);
1194 }
1195 }
1196
1198 entity.GetInventory().GetCurrentInventoryLocation(src);
1199
1200 entity.GetInventory().TakeToDst(invMode, src, dst);
1201 entityIB.ThrowPhysically(null, force, false);
1202 }
1203 }
1204 else
1205 {
1206 entity.GetInventory().DropEntity(invMode, entity.GetHierarchyRoot(), entity);
1207 dBodyApplyImpulse(entity, force);
1208 }
1209 }
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Определения Inventory.c:22
const int ECE_NONE
Определения CentralEconomy.c:7
const int RF_DEFAULT
Определения CentralEconomy.c:65
ThrowEntityFlags
Определения MiscGameplayFunctions.c:208
static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new item directly at location
script counterpart to engine's class Inventory
Определения Inventory.c:79
proto native void SetGroundEx(EntityAI e, vector pos, float dir[4])
sets current inventory location type to Ground with transformation mat
InventoryLocation.
Определения InventoryLocation.c:29
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
Определения PileOfWoodenPlanks.c:88
override bool CanBeSplit()
Определения Rag.c:34
Определения InventoryItem.c:731
proto native CGame GetGame()
proto void dBodyApplyImpulse(notnull IEntity body, vector impulse)
Applies impuls on a rigidbody (origin)

Перекрестные ссылки ItemBase::CanBeSplit(), dBodyApplyImpulse(), ECE_NONE, GetGame(), GameInventory::LocationCreateEntity(), RF_DEFAULT, InventoryLocation::SetGroundEx() и ItemBase::SetQuantity().

Используется в ThrowAllItemsInInventory().