1 #appendto Chest
2
IsContainer()3 public func IsContainer() { return false; }
RejectCollect()4 public func RejectCollect() { return true; }
5
6 // Start the chest closed.
Construction()7 public func Construction()
8 {
9 inherited(...);
10
11 PlayAnimation("Close", 5, Anim_Linear(0, 0, GetAnimationLength("Close"), 1, ANIM_Hold));
12 is_open = false;
13 }
14
15 // Never automatically open/close the chest.
OnShownInInteractionMenuStart(bool last)16 public func OnShownInInteractionMenuStart(bool last) { }
OnShownInInteractionMenuStop(bool last)17 public func OnShownInInteractionMenuStop(bool last) { }
18
19 // Open chests with space here so that you can actually see the confetti effect
GetInteractionMetaInfo(object clonk)20 public func GetInteractionMetaInfo(object clonk)
21 {
22 return { Description = Format("$OpenChest$", GetName()) };
23 }
24
IsInteractable(object clonk)25 public func IsInteractable(object clonk)
26 {
27 return !is_open;
28 }
29
Interact(object clonk)30 public func Interact(object clonk)
31 {
32 if (!is_open) return Open(clonk);
33 }
34
Open(clonk)35 public func Open(clonk)
36 {
37 GameCall("OnChestOpened", clonk);
38 Sound("Toot");
39 ScheduleCall(this, "DoTheConfetti", 2, 20);
40 return inherited();
41 }
42
DoTheConfetti()43 public func DoTheConfetti()
44 {
45 if (!this.confetti)
46 {
47 this.confetti =
48 {
49 CollisionVertex = 500,
50 OnCollision = PC_Stop(),
51 ForceX = PV_Random(-5, 5, 10),
52 ForceY = PV_Gravity(100),
53 Size = 1,
54 R = PV_Random(100,255),
55 G = PV_Random(100,255),
56 B = PV_Random(100,255),
57 DampingX = 900, DampingY = 900
58 };
59 }
60 CreateParticle("Confetti", PV_Random(-5, 5), PV_Random(0, 2), PV_Random(-30, 30), PV_Random(-80,-20), PV_Random(100, 150), this.confetti, 15);
61 }