Imagine a world where gadgets can alter what the widgets see:
1) event happens
2) gadget sees event (gets callin)
3) gadget alters (or blocks) the event
4) the altered event is passed to widget (if it was not blocked)
5) the widget sees the altered event
Sometimes one does not want widgets to know too much about what is happening.
Potential uses:
widgets like "ghost radar" can atm cheat:
When a unit leaves radar coverage and comes back into radar, the same unitID gets reported. See http://springrts.com/mantis/view.php?id=1002
Now what if there was a callin whatWidgetWillSeeUnitEnteredRadar (unitID, team) that returns the unitID that the widget will see? One could make something like:
Code: Select all
gadget:whatWidgetWillSeeUnitEnteredRadar (unitID, team)
return unique_random_number
end
Or could always return the same number to completly make radar-widgets unuseable, if that is wanted.
Different use:
Units that transform/morph into different unit types. Generally that is done by destroying the unit then spawning a new unit. (of different type)
This triggers UnitDestroyed and UnitCreated callins and widgets could potentially use this information.
But maybe one does not want widgets to know whenever a Commander has upgraded or a terran Viking has switched to airmode?
So one would return nil which means this event never reaches the widget:
Code: Select all
gadget:whatWidgetWillSeeUnitDestroyed (unitID,...)
if isCommander (unitID) return nil end
end
gadget:whatWidgetWillSeeUnitCreated (unitID,...)
if isCommander (unitID) return nil end
end