#WW# Looms and Spinning wheels now process entire stacks.

This commit is contained in:
WarrentyExpired 2026-08-07 19:37:23 -04:00
parent f0bb877f6a
commit d07e5931a8
4 changed files with 116 additions and 31 deletions

View file

@ -77,7 +77,7 @@ namespace Server.Items
m_Wool = wool;
}
protected override void OnTarget( Mobile from, object targeted )
protected override void OnTarget( Mobile from, object targeted )
{
if ( m_Wool.Deleted )
return;
@ -101,9 +101,34 @@ namespace Server.Items
}
else
{
m_Wool.Consume();
if ( m_Wool is TaintedWool ) wheel.BeginSpin( new SpinCallback( TaintedWool.OnSpun ), from, m_Wool.Hue );
else wheel.BeginSpin( new SpinCallback( Wool.OnSpun ), from, m_Wool.Hue );
// 1. Capture the total stack amount and its hue
int amount = m_Wool.Amount;
int hue = m_Wool.Hue;
// 2. Destroy the entire pile of wool at once
m_Wool.Delete();
// 3. Start the spin cycle and use a lambda for the multiplied yield
wheel.BeginSpin( ( w, m, h ) =>
{
// 1 wool = 3 balls of yarn. Calculate total yield.
int totalYarn = 3 * amount;
// 4. Safely loop the creation to prevent going over the 60,000 item limit
while ( totalYarn > 0 )
{
int yarnToGive = Math.Min( totalYarn, 60000 );
// In RunUO, "DarkYarn" is the core class used for all balls of yarn
Item yarn = new DarkYarn( yarnToGive );
yarn.Hue = h;
m.AddToBackpack( yarn );
totalYarn -= yarnToGive;
}
m.SendLocalizedMessage( 1010576 ); // You put the balls of yarn in your backpack.
}, from, hue );
}
}
else
@ -155,4 +180,4 @@ namespace Server.Items
from.SendLocalizedMessage( 1010574 ); // You put a ball of yarn in your backpack.
}
}
}
}