﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	resolution	keywords	cc	phab_field
3132	Return proportional amount of resources when deleting buildings	elexis		"Currently 100% of the resources are returned when a building is deleted or destroyed.

The source code actually says that a proportional amount should be returned. Only because of a programming mistake or bug 100% are returned.

See function ''Foundation.prototype.OnDestroy'' in file ''trunk/binaries/data/mods/public/simulation/components/Foundation.js''


{{{
Foundation.prototype.OnDestroy = function()
{
	// Refund a portion of the construction cost, proportional to the amount of build progress remaining
        // ...

	for (var r in this.costs)
	{
		var scaled = Math.floor(this.costs[r] * (1.0 - this.GetBuildProgress()));
                // ...
	}
};


/**
 * Returns the current build progress in a [0,1] range.
 */
Foundation.prototype.GetBuildProgress = function()
{
	var cmpHealth = Engine.QueryInterface(this.entity, IID_Health)
	var hitpoints = cmpHealth.GetHitpoints();
	var maxHitpoints = cmpHealth.GetMaxHitpoints();
	return (hitpoints / maxHitpoints);
};
}}}


[http://svn.wildfiregames.com/public/ps/trunk/binaries/data/mods/public/simulation/components/Foundation.js]


The GetBuildProgress() function always returns 0 because the hitpoint count in this function equates to 0."	defect	new	Should Have	Backlog	Core engine				
