DayZ 1.29
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 строка 131

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

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

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