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

◆ CreateNewEntity()

EntityAI ReplaceItemWithNewLambdaBase::CreateNewEntity ( )
inlineprotected

Step D. - create new entity (LOCAL) with specified type.

@NOTE: if (!m_NewLocation || m_NewItemType.Empty) ==> this function does not create a new entity

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

124 {
126 {
128 EntityAI new_item;
129
130 switch (m_NewLocation.GetType())
131 {
132 case InventoryLocationType.GROUND:
133 new_item = EntityAI.Cast(GetGame().CreateObjectEx(m_NewItemType,m_NewLocation.GetPos(),ECE_PLACE_ON_SURFACE|ECE_LOCAL));
134 string path = "" + CFG_VEHICLESPATH + " " + m_NewItemType + " inherit_rotation";
135 bool keep_rotation = GetGame().ConfigIsExisting(path) && GetGame().ConfigGetInt(path) > 0;
136 if (keep_rotation)
137 {
138 new_item.SetOrientation(m_OldItem.GetOrientation()); //this one actually works...debug InventoryLocation
139 }
140 break;
141 case InventoryLocationType.ATTACHMENT:
142 // forces rawlocation in C++ to make location Valid
143 m_NewLocation.SetAttachment(m_NewLocation.GetParent(), null, m_NewLocation.GetSlot());
144 new_item = GameInventory.LocationCreateEntity(m_NewLocation, m_NewItemType, ECE_OBJECT_SWAP, RF_NONE);
145 break;
146 default:
147 new_item = GameInventory.LocationCreateLocalEntity(m_NewLocation, m_NewItemType, ECE_OBJECT_SWAP, RF_NONE);
148 break;
149 }
150
151 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[inv] ReplaceItemWithNewLambdaBase Step D) Created new new_item=" + new_item);
152 if (new_item)
153 {
154 return new_item;
155 }
156 else
157 {
158 return null;
159
160 /*InventoryLocation backupLocation = new InventoryLocation;
161 vector mtx[4];
162 Math3D.MatrixIdentity4(mtx);
163 mtx[3] = m_OldItem.GetPosition();
164 backupLocation.SetGround(null, mtx);
165 if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[inv] ReplaceItemWithNewLambdaBase Step D) plan B - creating=" + m_NewItemType + " at bkp loc=" + backupLocation.DumpToString() + ", but failed");
166 new_item = GameInventory.LocationCreateLocalEntity(backupLocation, m_NewItemType,ECE_OBJECT_SWAP,RF_NONE); // create LOCAL new one on ground
167 if (!new_item)
168 {
169 Error("[inv] ReplaceItemWithNewLambdaBase Step D) plan B - wanted to create=" + m_NewItemType + " at bkp loc=" + backupLocation.DumpToString() + ", but failed");
170 return null;
171 }
172 return new_item;*/
173 }
174 }
175
176 // user did not asked for new entity
177 return null;
178 }
class LogManager EntityAI
const int RF_NONE
Определения CentralEconomy.c:45
const int ECE_OBJECT_SWAP
Определения CentralEconomy.c:38
const int ECE_LOCAL
Определения CentralEconomy.c:24
const int ECE_PLACE_ON_SURFACE
Определения CentralEconomy.c:37
void hndDebugPrint(string s)
Определения HandFSM.c:1
InventoryLocationType
types of Inventory Location
Определения InventoryLocation.c:4
string path
Определения OptionSelectorMultistate.c:142
proto native bool ConfigIsExisting(string path)
proto native int ConfigGetInt(string path)
Get int value from config on path.
ref InventoryLocation m_NewLocation
Определения ReplaceItemWithNewLambdaBase.c:9
proto native CGame GetGame()
const string CFG_VEHICLESPATH
Определения constants.c:220

Перекрестные ссылки CFG_VEHICLESPATH, CGame::ConfigGetInt(), CGame::ConfigIsExisting(), ECE_LOCAL, ECE_OBJECT_SWAP, ECE_PLACE_ON_SURFACE, GetGame(), hndDebugPrint(), LogManager::IsInventoryHFSMLogEnable(), GameInventory::LocationCreateEntity(), GameInventory::LocationCreateLocalEntity(), m_NewItemType, m_NewLocation, m_OldItem, path, RF_NONE, VerifyItemTypeBySlotType() и WantCreateNewEntity().

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