Merge commit '0795d088d1f82e8d4158e4fa859bbe69e0c4c875' into liquid_container

Conflicts:
	planet/Objects.ocd/Libraries.ocd/Stackable.ocd/Script.c

Unit tests still pass!
liquid_container
Mark 2016-04-05 06:27:55 +02:00
commit c607e3e4c2
2 changed files with 17 additions and 4 deletions

View File

@ -25,10 +25,17 @@ func NotifyHUD()
// This object is a container that can be inspected further in the interaction menu.
func IsContainer() { return true; }
// Disallow stacking if this object is not empty.
// Disallow stacking if the extra slots of both objects do not contain items that can stack.
// An empty extra slot does not stack with a filled one either.
public func CanBeStackedWith(object other)
{
return !ContentsCount() && inherited(other, ...);
if (Contents())
{
if (!other->Contents())
return false;
return Contents()->CanBeStackedWith(other->Contents()) && inherited(other, ...);
}
return !other->Contents() && inherited(other, ...);
}
local Name = "ExtraSlot";

View File

@ -379,7 +379,13 @@ public func MergeWithStacksIn(object into, bool ignore_extra_slot_containers)
*/
public func CanBeStackedWith(object other)
{
if (other->~IsInfiniteStackCount() != this->IsInfiniteStackCount()) return false;
// Infinite stacks can only be stacked on top of others.
if (this->IsInfiniteStackCount() != other->~IsInfiniteStackCount())
return false;
// If this and other are contained in extra slots stack count must be the same for the parents to be stackable.
if (this->Contained() && other->Contained())
if (this->Contained()->~HasExtraSlot() && other->Contained()->~HasExtraSlot())
return this->GetStackCount() == other->~GetStackCount() && _inherited(other, ...);
return _inherited(other, ...);
}
@ -390,7 +396,7 @@ public func CanBeStackedWith(object other)
public func GetInventoryIconOverlay()
{
if (!(this->IsInfiniteStackCount())) return nil;
return {Left = "50%", Bottom="50%", Symbol=Icon_Number, GraphicsName="Inf"};
return {Left = "50%", Bottom = "50%", Symbol = Icon_Number, GraphicsName = "Inf"};
}