forked from Mirrors/openclonk
Refactoring: Stackable: Moved HUD notifications to a separate function.
It should be OK that the new function calls OnInventoryChange() in Clonks on destruction now.liquid_container
parent
a61eac6ff3
commit
176856e276
|
@ -68,13 +68,7 @@ protected func Construction()
|
|||
|
||||
func Destruction()
|
||||
{
|
||||
var container = Contained();
|
||||
if (container)
|
||||
{
|
||||
// has an extra slot
|
||||
if (container->~HasExtraSlot())
|
||||
container->~NotifyHUD();
|
||||
}
|
||||
NotifyContainer();
|
||||
return _inherited(...);
|
||||
}
|
||||
|
||||
|
@ -162,21 +156,7 @@ public func UpdateStackDisplay()
|
|||
UpdatePicture();
|
||||
UpdateMass();
|
||||
UpdateName();
|
||||
// notify hud
|
||||
var container = Contained();
|
||||
if (container)
|
||||
{
|
||||
// has an extra slot
|
||||
if (container->~HasExtraSlot())
|
||||
{
|
||||
container->~NotifyHUD();
|
||||
}
|
||||
// is a clonk with new inventory system
|
||||
else
|
||||
{
|
||||
container->~OnInventoryChange();
|
||||
}
|
||||
}
|
||||
NotifyContainer();
|
||||
}
|
||||
|
||||
private func UpdatePicture()
|
||||
|
@ -198,6 +178,25 @@ private func UpdateMass()
|
|||
SetMass(GetID()->GetMass() * Max(GetStackCount(), 1) / InitialStackCount());
|
||||
}
|
||||
|
||||
private func NotifyContainer()
|
||||
{
|
||||
// notify hud
|
||||
var container = Contained();
|
||||
if (container)
|
||||
{
|
||||
// has an extra slot
|
||||
if (container->~HasExtraSlot())
|
||||
{
|
||||
container->~NotifyHUD();
|
||||
}
|
||||
// is a clonk with new inventory system
|
||||
else
|
||||
{
|
||||
container->~OnInventoryChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Try to merge packs BEFORE entering the container.
|
||||
That means that a container can not prevent objects stacking into it.
|
||||
|
|
Loading…
Reference in New Issue