Difference between revisions of "HasRequirements"
From King Arthur's Gold Wiki
Shadlington (Talk | contribs) (Created page with "<onlyinclude> Reads requirements from the given CBitStream into variables you provide. </onlyinclude> This is primarily for use in conjunction with other requirement-handlin...") |
(No difference)
|
Revision as of 20:26, 18 August 2012
Reads requirements from the given CBitStream into variables you provide.
This is primarily for use in conjunction with other requirement-handling methods.
The requirements parameter is the CBitStream you're reading the requirements from.
The missing parameter is a CBitStream that any missing requirements will be read into.
bool hasRequirements( CInventory@ inventory1, CInventory@ inventory2, CBitStream@ requirements, CBitStream@ missing )
Example from Entities/Workshops/Scripts/WorkshopTasks.as:
void AddWorkshopTasksButtons( CBlob@ this, CBlob@ caller, CGridMenu@ menu ) { int tasksCount = this.getProperties().getScriptObjectGroupSize( "tasks" ); if (menu !is null) { for (int i = 0; i < tasksCount; i++) { WorkshopTask @wt = cast<WorkshopTask@>(this.getProperties().getScriptObject( "tasks", i)); CBitStream bsMissing; CBitStream combinedReqs; if (hasRequirements( this.getInventory(), caller.getInventory(), wt.requirements, bsMissing )) { CBitStream params; params.write_u16(caller.getNetworkID()); CGridButton@ button = menu.AddButton( wt.iconName, wt.name, WshpTasks::make_task + i, params ); SetButtonRequirementsText( button, wt.requirements, false ); } else { CGridButton@ button = menu.AddButton( "$NONE$", wt.name, WshpTasks::nil ); SetButtonRequirementsText( button, bsMissing, true ); } } } }