I'm a bit stuck in this:
Let's say I want to have 45 items of something, but the maximum stack I can have of that item is 10. So I want a collection that returns me [10, 10, 10, 10, 5] based on that.
This is what I currently have. (yes, I have to use unsigned int16 for my project, but it doesn't matter if your example is regular integer).
ushort Ceiling = (ushort)Math.Ceiling((double)Amount / (double)MaxStackSize);
ushort[] Sizes = new ushort[Ceiling];
for (ushort i = 0; i < Ceiling; i++)
{
if (Amount != MaxStackSize && i == Ceiling - 1)
{
Sizes[i] = (ushort)(Amount % MaxStackSize);
}
else
{
Sizes[i] = MaxStackSize;
}
}
It works to a certain degree, but sometimes the module will return 0. (for example 10 % 10 or 30 % 10). Or maybe there's a better way to do this instead of what I'm doing. I'll appreciate the help!