forked from Mirrors/openclonk
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
parent
efe7dcf251
commit
ee4ac9e825
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue