The method does not care about the amount of materials that should be returned based on the cached quantity in the ConstructionMaterialData struct. If we start using this method for e.g. drop of materials that are not attached and locked to the construction parent then we need to change the method to handle the quantity accordingly
1281 {
1282
1284 bool hasMemPoint = parent.MemoryPointExists(partName + "_materials");
1285 if (hasMemPoint)
1286 basePos =
g_Game.ObjectModelToWorld(parent, parent.GetMemoryPointPos(partName +
"_materials"));
1287 else if (player)
1288 basePos = player.GetPosition();
1289 else
1290 basePos = attachment.GetPosition();
1291
1292
1293 string itemType = attachment.GetType();
1294 float health = attachment.GetHealth("", "Health");
1295 int total = attachment.GetQuantity();
1296 int stackMax = attachment.GetTargetQuantityMax(-1);
1297 if (stackMax <= 0)
1298 stackMax = 1;
1299
1300
1301 int pileCount =
Math.
Ceil((
float)total / stackMax);
1303 {
1306 }
1307
1308
1309 int remaining = total;
1310 for (int i = 0; i < pileCount; ++i)
1311 {
1312 int thisQty = stackMax;
1313 if (remaining < stackMax)
1314 thisQty = remaining;
1315
1318
1320 if (!newItem)
1321 {
1322 ErrorEx(
"MoveMaterialAttachmentToGround: failed to create '" + itemType +
"' on part " + partName +
", aborting drop!");
1323 return;
1324 }
1325
1327 newItem.SetHealth("", "Health", health);
1328 newItem.PlaceOnSurface();
1329
1330 remaining -= thisQty;
1331 }
1332
1333
1334 attachment.Delete();
1335 }
const int ECE_PLACE_ON_SURFACE
enum ConstructionMaterialType MAX_MATERIAL_PILES
override bool SetQuantity(float value, bool destroy_config=true, bool destroy_forced=false, bool allow_client=false, bool clamp_to_stack_max=true)
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float Cos(float angle)
Returns cosinus of angle in radians.
static proto float Sin(float angle)
Returns sinus of angle in radians.
static proto float Ceil(float f)
Returns ceil of value.
static const float DEG2RAD