#W# Crafting queue fix/tweak.
This commit is contained in:
parent
ad9521ebb9
commit
abee6aa3eb
1 changed files with 6 additions and 18 deletions
|
|
@ -38,7 +38,7 @@ namespace Server.Engines.Craft
|
|||
public CraftQueue()
|
||||
{
|
||||
Entries = new List<CraftQueueEntry>();
|
||||
IsPaused = true; // Now defaults to Paused so the first click says "START"
|
||||
IsPaused = true;
|
||||
}
|
||||
|
||||
public static CraftQueue GetQueue( Mobile m )
|
||||
|
|
@ -61,7 +61,7 @@ namespace Server.Engines.Craft
|
|||
if ( !queue.IsPaused )
|
||||
{
|
||||
queue.IsPaused = true;
|
||||
m.SendMessage( 0x20, $"Crafting queue paused: {reason}" );
|
||||
m.SendMessage( $"Crafting queue paused: {reason}" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -72,7 +72,6 @@ namespace Server.Engines.Craft
|
|||
if ( queue.IsPaused || queue.Entries.Count == 0 )
|
||||
return;
|
||||
|
||||
// Find the first item that still needs crafting
|
||||
CraftQueueEntry entry = null;
|
||||
foreach ( var e in queue.Entries )
|
||||
{
|
||||
|
|
@ -85,7 +84,6 @@ namespace Server.Engines.Craft
|
|||
|
||||
if ( entry == null ) return;
|
||||
|
||||
// Tally the stats
|
||||
if ( success )
|
||||
{
|
||||
entry.Made++;
|
||||
|
|
@ -97,10 +95,9 @@ namespace Server.Engines.Craft
|
|||
entry.Failed++;
|
||||
}
|
||||
|
||||
// Decrement the remaining amount
|
||||
entry.Amount--;
|
||||
from.SendGump( new CraftQueueGump( from, entry.System, entry.Tool ) );
|
||||
|
||||
// Fire the next craft automatically!
|
||||
Timer.DelayCall( TimeSpan.FromSeconds( 1.5 ), new TimerStateCallback( ProcessQueue ), from );
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +109,6 @@ namespace Server.Engines.Craft
|
|||
if ( queue.IsPaused )
|
||||
return;
|
||||
|
||||
// Find the active item
|
||||
CraftQueueEntry entry = null;
|
||||
foreach ( var e in queue.Entries )
|
||||
{
|
||||
|
|
@ -125,18 +121,16 @@ namespace Server.Engines.Craft
|
|||
|
||||
if ( entry == null )
|
||||
{
|
||||
from.SendMessage( 0x480, "Your crafting queue is complete!" );
|
||||
queue.IsPaused = true; // Auto-pause for the next time they use it
|
||||
from.SendMessage( "Your crafting queue is complete!" );
|
||||
queue.IsPaused = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Safety Check: Did the tool break?
|
||||
if ( entry.Tool == null || entry.Tool.Deleted || entry.Tool.UsesRemaining <= 0 )
|
||||
{
|
||||
Type toolType = entry.Tool != null ? entry.Tool.GetType() : null;
|
||||
BaseTool newTool = null;
|
||||
|
||||
// Search the player's backpack for a valid replacement tool
|
||||
if ( toolType != null && from.Backpack != null )
|
||||
{
|
||||
Item[] tools = from.Backpack.FindItemsByType( toolType );
|
||||
|
|
@ -153,19 +147,16 @@ namespace Server.Engines.Craft
|
|||
|
||||
if ( newTool != null )
|
||||
{
|
||||
// Swap the broken tool out for the spare and keep going!
|
||||
entry.Tool = newTool;
|
||||
from.SendMessage( 0x480, "A broken tool was replaced with a spare from your backpack." );
|
||||
from.SendMessage( "A broken tool was replaced with a spare from your backpack." );
|
||||
}
|
||||
else
|
||||
{
|
||||
// No spares found. Pause so they can go get one.
|
||||
Pause( from, "Tool broken. Please place a new one in your backpack and hit Start." );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Figure out what resource (wood, ingot type, etc) they had selected
|
||||
CraftContext context = entry.System.GetContext( from );
|
||||
Type typeRes = null;
|
||||
if ( context != null )
|
||||
|
|
@ -176,12 +167,9 @@ namespace Server.Engines.Craft
|
|||
typeRes = res.GetAt( resIndex ).ItemType;
|
||||
}
|
||||
|
||||
// Close existing gumps so the screen doesn't spam
|
||||
from.CloseGump( typeof( CraftGump ) );
|
||||
from.CloseGump( typeof( CraftQueueGump ) );
|
||||
from.CloseGump( typeof( CraftGumpItem ) );
|
||||
|
||||
// Start the next craft!
|
||||
entry.Item.Craft( from, entry.System, typeRes, entry.Tool );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue