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

◆ DropNonUsableMaterialsServer()

void DropNonUsableMaterialsServer ( Man player,
string part_name )
protected

We only care about base parts with locked materials/attachments here. Refund of materials that where used to construct the part are refunded by the ReceiveMaterialsServer method

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

1222 {
1223 ConstructionPart part = GetConstructionPart(part_name);
1224
1227 if (!part.IsBase())
1228 return;
1229
1231 if (!materials)
1232 return;
1233
1234 GameInventory parentInv = m_EntityParent.GetInventory();
1235 foreach (ConstructionMaterialData dta : materials)
1236 {
1237 if (dta.m_SkipOnDismantle)
1238 continue;
1239
1240 int slotId = dta.m_MaterialSlotID;
1241 if (slotId == InventorySlots.INVALID)
1242 {
1243 ErrorEx(string.Format("DropNonUsableMaterialsServer: invalid cached slot id for '%1' on part %2", dta.m_MaterialSlotName, part_name));
1244 continue;
1245 }
1246
1247 ItemBase attachment = ItemBase.Cast(parentInv.FindAttachment(slotId));
1248 if (!attachment)
1249 {
1250 ErrorEx(string.Format("Attachment is not present for material type '%1' on part %2", dta.m_MaterialType, part_name));
1251 continue;
1252 }
1253
1255 bsbDebugPrint("[bsb] " + Object.GetDebugName(m_EntityParent) + " DropNonUsableMaterials UNlocking slot=" + slotId + " (" + dta.m_MaterialSlotName + ")");
1256
1257 parentInv.SetSlotLock(slotId, false);
1258
1259 //-1 => consumed by construction. Lockable materials are NEVER consumed
1260 //(TakeMaterialsServer locks them instead) so they must be returned.
1261 //Example: Fence wall_gate: MetalWire quantity=-1 lockable=1
1262 if (dta.m_MaterialQuantity == -1.0 && !dta.m_MaterialLockable)
1263 {
1265 bsbDebugPrint("[bsb] " + Object.GetDebugName(m_EntityParent) + " DropNonUsableMaterials DELETING (qty==-1, non-lockable) slot=" + slotId);
1266
1267 g_Game.ObjectDelete(attachment);
1268 continue;
1269 }
1270
1271 InventoryLocation invloc = new InventoryLocation();
1272 attachment.GetInventory().GetCurrentInventoryLocation(invloc);
1273
1274 MoveMaterialAttachmentToGround(m_EntityParent, player, attachment, invloc, part_name);
1275 }
1276 }
ConstructionPart GetConstructionPart()
Определения ActionPartInfo.c:235
class BaseBuildingBase extends ItemBase bsbDebugPrint(string s)
Определения BaseBuildingBase.c:1291
void MoveMaterialAttachmentToGround(notnull EntityAI parent, Man player, notnull ItemBase attachment, notnull InventoryLocation invloc, string partName)
Определения ConstructionBase.c:1280
EntityAI m_EntityParent
Определения ConstructionBase.c:45
DayZGame g_Game
Определения DayZGame.c:4074
instanced data holder for single construction material
Определения ConstructionMaterials.c:3
bool IsBase()
Определения ConstructionPart.c:273
array< ref ConstructionMaterialData > GetMaterialsData()
Определения ConstructionPart.c:346
Instanced construction part data classes for dynamic data, statics now stored on EntityType level in ...
Определения ConstructionPart.c:4
proto native bool SetSlotLock(int slot, bool locked)
proto native EntityAI FindAttachment(int slot)
Returns attached entity in slot (you can use InventorySlots.GetSlotIdFromString(name) to get slot id)
script counterpart to engine's class Inventory
InventoryLocation.
Определения InventoryLocation.c:30
const int INVALID
Invalid slot (-1)
Определения InventorySlots.c:17
provides access to slot configuration
Определения InventorySlots.c:6
static bool IsBaseBuildingLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:809
Определения ObjectTyped.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
enum ShapeType ErrorEx

Перекрестные ссылки bsbDebugPrint(), ErrorEx, GameInventory::FindAttachment(), g_Game, GetConstructionPart(), ConstructionPart::GetMaterialsData(), InventorySlots::INVALID, ConstructionPart::IsBase(), LogManager::IsBaseBuildingLogEnable(), m_EntityParent, MoveMaterialAttachmentToGround() и GameInventory::SetSlotLock().

Используется в DestroyPartServer() и DismantlePartServerEx().