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

◆ SpawnEntityInInventory()

EntityAI PluginBase::SpawnEntityInInventory ( notnull EntityAI target,
string className,
float health,
float quantity,
bool special = false,
string presetName = "",
FindInventoryLocationType locationType = FindInventoryLocationType.ANY )
inlineprotected

tries to spawn item somewhere in inventory

SpawnEntityInInventory queries future parent about free inventory location of the future item

Аргументы
[in]healthhealth of the item
[in]quantityquantity to set if item.HasQuantity() (-1 == set to max)
Возвращает
entity if ok, null otherwise

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

503 {
504 if (target.IsPlayer())
505 {
506 return SpawnEntityInPlayerInventory(PlayerBase.Cast(target), className, health, quantity, special, presetName, locationType);
507 }
508 if ( GetGame().IsServer() )
509 {
510 InventoryLocation il = new InventoryLocation;
511 if (target.GetInventory() && target.GetInventory().FindFirstFreeLocationForNewEntity(className, FindInventoryLocationType.ANY, il))
512 {
513 EntityAI eai = SpawnEntity(className, il, ECE_IN_INVENTORY, RF_DEFAULT);
514 if ( eai && eai.IsInherited(ItemBase) )
515 {
516 if ( health < 0 )//check for default (-1)
517 {
518 health = eai.GetMaxHealth();
519 }
520 ItemBase i = ItemBase.Cast( eai );
521 SetupSpawnedItem(i, health, quantity);
522 if ( special )
523 {
524 auto debugParams = DebugSpawnParams.WithPlayer(null);
525 eai.OnDebugSpawnEx(debugParams);
526 }
527 }
528 return eai;
529 }
530 }
531 else
532 {
533 DevSpawnItemParams params = new DevSpawnItemParams(target, className, health, quantity, special, presetName, 0 );
534 GetGame().GetPlayer().RPCSingleParam(ERPCs.DEV_RPC_SPAWN_ITEM_IN_INVENTORY, params, true, GetGame().GetPlayer().GetIdentity());
535 }
536 return null;
537 }
class LogManager EntityAI
proto native void SpawnEntity(string sClassName, vector vPos, float fRange, int iCount)
Spawn an entity through CE.
const int ECE_IN_INVENTORY
Определения CentralEconomy.c:36
const int RF_DEFAULT
Определения CentralEconomy.c:65
ERPCs
Определения ERPCs.c:2
class GP5GasMask extends MaskBase ItemBase
FindInventoryLocationType
flags for searching locations in inventory
Определения InventoryLocation.c:17
void SetupSpawnedItem(ItemBase item, float health, float quantity)
Определения ItemBase.c:4803
PlayerBase GetPlayer()
Определения ModifierBase.c:51
Param7< EntityAI, string, float, float, bool, string, FindInventoryLocationType > DevSpawnItemParams
Определения PluginDeveloper.c:1
proto native DayZPlayer GetPlayer()
EntityAI SpawnEntityInPlayerInventory(PlayerBase player, string item_name, float health, float quantity, bool special=false, string presetName="", FindInventoryLocationType locationType=FindInventoryLocationType.ANY)
Определения PluginDeveloper.c:539
proto native CGame GetGame()

Перекрестные ссылки ECE_IN_INVENTORY, GetGame(), CGame::GetPlayer(), GetPlayer(), RF_DEFAULT, SetupSpawnedItem(), SpawnEntity() и SpawnEntityInPlayerInventory().

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