From aea27f87587d380e3bfa41e72b392c1cd4dba3e4 Mon Sep 17 00:00:00 2001 From: Mark Date: Sun, 18 Mar 2018 19:53:57 +0100 Subject: [PATCH] Construction site: Take missing materials as interaction --- .../ConstructionSite.ocd/Script.c | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/planet/Objects.ocd/Structures.ocd/ConstructionSite.ocd/Script.c b/planet/Objects.ocd/Structures.ocd/ConstructionSite.ocd/Script.c index 9706f00ce..0076200e4 100644 --- a/planet/Objects.ocd/Structures.ocd/ConstructionSite.ocd/Script.c +++ b/planet/Objects.ocd/Structures.ocd/ConstructionSite.ocd/Script.c @@ -117,6 +117,32 @@ public func OnInteractionControl(id symbol, string action, object clonk) } +// Players can put materials into the construction site via space-key +private func IsInteractable(object clonk) +{ + if (clonk) return !Hostile(GetOwner(), clonk->GetOwner()); + return true; +} + + +// Adapt appearance in the interaction bar. +private func GetInteractionMetaInfo(object clonk) +{ + return { Description = "$TxtMissingMaterial$", IconName = nil, IconID = Hammer }; +} + + +// Called on player interaction. +public func Interact(object clonk) +{ + if (clonk && IsInteractable(clonk)) + { + TakeConstructionMaterials(clonk); + } + return true; +} + + /*-- Engine callbacks --*/ public func Deconstruct()