And to balance a higher capability, why not making their weight growing based on the percentage they are filled, regardless of the object to avoid needing adding mass to each object.
It just have to be based on the percentage of stack size for each objects.
So some sort of :
Code: Select all
declare temp variable
if validation_boolean = false
{
if selected_slot_item_count > 0
{
For each inventory_slot
{
temp = temp + (maximum_stack_size_item.item_on_selected_slot \ number_of_items_on_selected_slot)
}
}
wagon_weight = wagon_empty_weight + (temp \ slot_number_for_wagons)
}
Of course this loop is heavy, it is only an example, just doing a simpler calculation each time an object is removed/added might actually be better resources wise.
This way, just before the train leave, the calculation is done once and the weight is stored in a variable, which mean no need for heavy calculations too often, and a boolean which validate the wagon as an optimisation, so only the wagons who had change in their inventory would need to recalculate the weight.
It would be better to see a completely filled train accelerate slowly than one with empty wagons.