2010-03-26 11:42:05 +00:00
|
|
|
/*
|
|
|
|
Chest
|
|
|
|
Author: Maikel
|
|
|
|
|
|
|
|
Storage for items.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-05-10 19:20:06 +00:00
|
|
|
#include Library_Structure
|
|
|
|
|
2012-05-07 18:27:46 +00:00
|
|
|
local is_open;
|
2011-10-01 15:39:59 +00:00
|
|
|
|
2010-06-24 19:55:01 +00:00
|
|
|
protected func Construction()
|
2010-06-01 01:52:57 +00:00
|
|
|
{
|
2012-05-07 18:27:46 +00:00
|
|
|
PlayAnimation("Open", 1, Anim_Linear(0, 0, 1, 20, ANIM_Hold), Anim_Const(1000));
|
2010-06-24 19:55:01 +00:00
|
|
|
SetProperty("MeshTransformation",Trans_Rotate(RandomX(20,80),0,1,0));
|
2012-05-07 18:27:46 +00:00
|
|
|
is_open = false;
|
2011-10-14 06:22:10 +00:00
|
|
|
return _inherited(...);
|
2010-06-01 01:52:57 +00:00
|
|
|
}
|
|
|
|
|
2010-06-30 11:09:53 +00:00
|
|
|
/*-- Contents --*/
|
|
|
|
|
2011-12-28 10:49:38 +00:00
|
|
|
public func IsContainer() { return true; }
|
2012-04-29 13:29:10 +00:00
|
|
|
public func IsInteractable() { return true; }
|
2011-12-28 10:49:38 +00:00
|
|
|
|
2010-06-30 11:09:53 +00:00
|
|
|
private func MaxContentsCount()
|
2010-03-26 11:42:05 +00:00
|
|
|
{
|
2014-10-18 09:47:23 +00:00
|
|
|
return 50;
|
2010-03-26 11:42:05 +00:00
|
|
|
}
|
|
|
|
|
2015-05-21 20:26:59 +00:00
|
|
|
public func GetInteractionMetaInfo(object clonk, int num)
|
|
|
|
{
|
|
|
|
if (!is_open)
|
|
|
|
return { Description = "$MsgOpen$" };
|
|
|
|
return { Description = "$MsgClose$" };
|
|
|
|
}
|
2012-04-29 13:29:10 +00:00
|
|
|
|
|
|
|
// Open contentsmenu via interaction
|
|
|
|
public func Interact(object clonk, int mode)
|
|
|
|
{
|
2012-05-07 18:27:46 +00:00
|
|
|
// Interaction does the same as the content control.
|
|
|
|
clonk->ObjectControl(clonk->GetOwner(), CON_Contents);
|
2012-04-29 13:29:10 +00:00
|
|
|
}
|
|
|
|
|
2011-12-28 18:25:00 +00:00
|
|
|
protected func RejectCollect()
|
2010-06-01 01:52:57 +00:00
|
|
|
{
|
2013-12-30 12:46:34 +00:00
|
|
|
if (ContentsCount() >= this->MaxContentsCount())
|
2011-12-28 18:25:00 +00:00
|
|
|
return true;
|
|
|
|
return false;
|
2010-06-24 19:55:01 +00:00
|
|
|
}
|
2010-06-01 01:52:57 +00:00
|
|
|
|
2012-03-31 15:34:03 +00:00
|
|
|
public func OnContentMenuOpened()
|
|
|
|
{
|
|
|
|
return Open();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public func OnContentMenuClosed()
|
|
|
|
{
|
|
|
|
return Close();
|
|
|
|
}
|
|
|
|
|
2010-06-24 19:55:01 +00:00
|
|
|
private func Open()
|
|
|
|
{
|
2012-05-07 18:27:46 +00:00
|
|
|
if (is_open)
|
|
|
|
return;
|
|
|
|
is_open = true;
|
|
|
|
PlayAnimation("Open", 5, Anim_Linear(0, 0, GetAnimationLength("Open"), 22, ANIM_Hold), Anim_Const(1000));
|
2011-10-12 21:09:22 +00:00
|
|
|
Sound("ChestOpen");
|
2010-06-24 19:55:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private func Close()
|
|
|
|
{
|
2012-05-07 18:27:46 +00:00
|
|
|
if (!is_open)
|
|
|
|
return;
|
|
|
|
is_open = false;
|
2011-10-01 15:39:59 +00:00
|
|
|
PlayAnimation("Close", 5, Anim_Linear(0, 0, GetAnimationLength("Close"), 15, ANIM_Hold), Anim_Const(1000));
|
2011-10-12 21:09:22 +00:00
|
|
|
Sound("ChestClose");
|
2010-06-01 01:52:57 +00:00
|
|
|
}
|
|
|
|
|
2012-04-16 15:31:38 +00:00
|
|
|
public func NoConstructionFlip() { return true; }
|
|
|
|
|
2010-09-13 15:27:48 +00:00
|
|
|
protected func Definition(def)
|
2010-03-26 11:42:05 +00:00
|
|
|
{
|
2012-05-07 18:27:46 +00:00
|
|
|
SetProperty("PictureTransformation", Trans_Mul(Trans_Translate(0,-3000,-5000), Trans_Rotate(-30,1,0,0), Trans_Rotate(30,0,1,0), Trans_Translate(1000,1,0)),def);
|
2010-07-21 20:23:34 +00:00
|
|
|
}
|
2010-09-09 21:29:11 +00:00
|
|
|
|
|
|
|
local Name = "$Name$";
|
2015-04-05 15:51:39 +00:00
|
|
|
local Description = "$Description$";
|
2015-01-14 19:30:55 +00:00
|
|
|
local ContainBlast = true;
|
2012-05-10 19:20:06 +00:00
|
|
|
local HitPoints = 50;
|