ReadRequirement
Pushes the given requirements to a CBitStream, to be read by other requirement methods.
This is primarily for use in conjunction with other requirement-handling methods. It will regularly be used with CInventory for checking whether a player has the required materials to do something. In addition, you will use it with things like workshops to set requirements for actions that can be performed at them.
The first parameter is the CBitStream you're adding the requirements to. The requirements string is the type of requirement - the standard ones are "blob", "tech", "coin", "shop" and "time", though you may be able to define your own. The blobName string is the name of the blob that is required, if the requirement is for a kind of blob - leave it blank ("") if it not a kind of blob, for example if it is time. The friendlyName string is what should be displayed to the player as text.
void AddRequirement( CBitStream@ bs, std::string &requirement, std::string &blobName, std::string &friendlyName, u16 &quantity)
Example from Entities/Characters/Scripts/BuilderInventory.as:
void SetButtonRequirementsText( CGridButton @button, CBitStream@ bs, bool missing ) { string text, requiredType, name, friendlyName; u16 quantity = 0; while (!bs.isBufferEnd()) { ReadRequirement( bs, requiredType, name, friendlyName, quantity ); string quantityColor; if (missing) quantityColor = "$RED$"; else quantityColor = "$GREEN$"; if (requiredType == "blob") { text += quantityColor; text += quantity; text += quantityColor; text += " $"; text += name; text += "$"; text += " "; text += quantityColor; text += friendlyName; text += quantityColor; text += " required.\n\n"; } else if (requiredType == "tech") { text += " $"; text += name; text += "$ "; text += quantityColor; text += friendlyName; text += quantityColor; text += " technology required.\n\n"; } else if (requiredType == "coin") { text += quantity; text += " $coin$ required\n\n"; } else if (requiredType == "shop") { } else if (requiredType == "time") { text += "$TIME$ "; text += friendlyName; text += " "; text += quantityColor; text += quantity; text += quantityColor; text += "\n\n"; } } button.SetHoverText( text ); }