Structure: Callback for too much damage

Added callback OnNoHitPointsRemaining() that is called if whenever the
structure is about to be removed because it took too much damage. Should
the callback return true, then the damage counts as handled and the
structure will not be removed.
install-platforms
Mark 2017-07-22 23:41:49 +02:00
parent efe7dcf251
commit ee4ac9e825
1 changed files with 7 additions and 3 deletions

View File

@ -53,11 +53,15 @@ public func Damage(int change, int cause, int cause_plr)
if (this && this.HitPoints != nil)
{
if (GetDamage() >= this.HitPoints)
{
{
// Remove contents from the building depending on the type of damage.
EjectContentsOnDestruction(cause, cause_plr);
// Destruction callback is made by the engine.
return RemoveObject();
// Handle detruction with a custom callback? If not, remove the object.
if (!this->~OnNoHitPointsRemaining(cause, cause_plr))
{
// Destruction callback is made by the engine.
return RemoveObject();
}
}
// Update all interaction menus with the new hitpoints.
UpdateInteractionMenus(this.GetDamageMenuEntries);