This seems that it will work to figure out that the unit got destroyed by timeout,
Also if you cancel a unit from a factory (by rightclick the buildicon again) actually I thought thats what you meant.
For nano timeout use Google_Frog's idea.
it won't solve the fact that the resources would just flow back in the metal and/or energy bar
You could then do something like
Code: Select all
m = MetalCostOfUnity (unitID)
m = m * buildprogress
TakeMetalFromTeam (teamID, m)
Though there might be ways to cheat around it. (ie the share slider in resource bar, would have to disable that) Hm, there might also be problems with in which frames resources are used/spent.
Maybe it is possible to intercept the "cancel unit" order from the factory and destroy the unit in progress before the engine does it?
It would still be great if this problem could be solved by calling some kind of method that overrides the engines default behaviour :)
There were some threads about that before, I think the plan for the engine resource system is to make it more flexible in every way, ie allow more then 2 resources. Don't know if somebody is working on it.