chest: stay open when empty (#1699)

This is debatable. Let's see how this feels ingame and revert it in case we don't like it.
I like it because I think it gives valuable feedback to the players (and thus can reduce frustration coming from unnecessary actions). But it might also feel like a bug to players.
qteditor
David Dormagen 2016-05-30 10:19:49 +02:00
parent 6696ee679c
commit 092b012430
2 changed files with 42 additions and 2 deletions

View File

@ -10,12 +10,15 @@
#include Library_Ownable
local is_open;
local has_interaction_menu_open = false;
protected func Construction()
{
PlayAnimation("Open", 1, Anim_Linear(0, 0, 1, 20, ANIM_Hold));
// On Construction, the object does not contain anything, so we default to keeping the chest open.
PlayAnimation("Open", 5, Anim_Linear(0, 0, GetAnimationLength("Open"), 1, ANIM_Hold));
is_open = true;
SetProperty("MeshTransformation",Trans_Rotate(RandomX(20,80),0,1,0));
is_open = false;
return _inherited(...);
}
@ -35,13 +38,41 @@ protected func RejectCollect()
public func OnShownInInteractionMenuStart(bool first)
{
if (first)
{
Open();
has_interaction_menu_open = true;
}
}
public func OnShownInInteractionMenuStop(bool last)
{
if (last)
{
if (ContentsCount() > 0)
Close();
has_interaction_menu_open = false;
}
}
public func Collection2(object obj)
{
if (is_open && !has_interaction_menu_open)
Close();
return _inherited(obj, ...);
}
public func Ejection(object obj)
{
if (ContentsCount() == 0 && !has_interaction_menu_open)
Open();
return _inherited(obj, ...);
}
public func ContentsDestruction(object destroyed)
{
if (ContentsCount() <= 1 && !has_interaction_menu_open)
Open();
return _inherited(destroyed, ...);
}
private func Open()

View File

@ -3,6 +3,15 @@
public func IsContainer() { return false; }
public func RejectCollect() { return true; }
// Start the chest closed.
public func Construction()
{
inherited(...);
PlayAnimation("Close", 5, Anim_Linear(0, 0, GetAnimationLength("Close"), 1, ANIM_Hold));
is_open = false;
}
// Never automatically open/close the chest.
public func OnShownInInteractionMenuStart(bool last) { }
public func OnShownInInteractionMenuStop(bool last) { }