RoomDoor: Add editor props, user actions and scenario saving

alut-include-path
Sven Eberhardt 2017-03-07 22:43:04 -05:00
parent 7ffc1c5ffb
commit 3b90a0bf10
3 changed files with 91 additions and 7 deletions

View File

@ -9,6 +9,8 @@
// Door opens and closes by use of the door library.
#include Library_DoorControl
local target_door; // Anything that enters is transferred to the connected door
local entrance_action; // Action to be performed when something/someone enters the door
/*-- Door Control --*/
@ -31,6 +33,19 @@ private func OnCloseDoor()
local door_key;
public func SetKey(object set_key)
{
// Set or clear key
if (set_key)
{
MakeLockedDoor(set_key);
}
else
{
door_key = nil;
}
}
public func MakeLockedDoor(object set_key)
{
if (!set_key->~IsKey())
@ -46,16 +61,56 @@ public func MakeLockedDoor(object set_key)
public func ActivateEntrance(object entering_obj)
{
// Block the entrance if this door needs a key and the key is not carried.
if (door_key && door_key->Contained() != entering_obj)
if (door_key)
{
entering_obj->~PlaySoundDecline();
PlayerMessage(entering_obj->GetOwner(), "$MsgDoorLocked$");
return false;
if (door_key->Contained() != entering_obj)
{
entering_obj->~PlaySoundDecline();
PlayerMessage(entering_obj->GetOwner(), "$MsgDoorLocked$");
return false;
}
// Use key
Sound("Structures::DoorUnlock");
Message("$KeyUsed$");
door_key->RemoveObject(); // Will reset door_key to nil
}
return _inherited(entering_obj, ...);
}
/* Entrance actions */
public func SetTargetDoor(object ntd) { target_door = ntd; }
public func SetEntranceAction(proplist nea) { entrance_action = nea; }
local ignore_collection;
public func Collection2(object entering_object, ...)
{
// Ignore if transferring from another door
if (!ignore_collection)
{
// Handle target transfer
if (target_door)
{
++target_door.ignore_collection;
entering_object->Enter(target_door);
if (target_door)
{
--target_door.ignore_collection;
if (!entering_object) return;
entering_object->SetCommand("Exit");
}
}
// Handle entrance action
UserAction->EvaluateAction(entrance_action, this, entering_object);
}
return _inherited(entering_object, ...);
}
/*-- ActMap --*/
local ActMap = {
@ -89,10 +144,25 @@ local ActMap = {
}
};
/* Editor definitions */
public func Definition(def, ...)
{
if (!def.EditorProps) def.EditorProps = {};
def.EditorProps.door_key = { Name = "$Key$", EditorHelp="$KeyHelp$", Type = "object", Filter = "IsKey", Set="SetKey", Save="Key" };
def.EditorProps.target_door = { Name = "$ConnectedDoor$", EditorHelp="$ConnectedDoorHelp$", Type = "object", Filter = "IsDoorTarget", Set="SetTargetDoor", Save="TargetDoor" };
def.EditorProps.entrance_action = new UserAction.Prop { Name="$EntranceAction$", EditorHelp="$EntranceActionHelp$", Set="SetEntranceAction", Save="EntranceAction" };
return _inherited(def, ...);
}
/*-- Properties --*/
local Name = "$Name$";
local Description = "$Description$";
local Plane = 200;
local MeshTransformation = [1050, 0, 0, -550, 0, 1050, 0, -400, 0, 0, 1050, 0]; // Trans_Mul(Trans_Translate(-550, -400, 0), Trans_Scale(1050))
local MeshTransformation = [1050, 0, 0, -550, 0, 1050, 0, -400, 0, 0, 1050, 0]; // Trans_Mul(Trans_Translate(-550, -400, 0), Trans_Scale(1050))
public func IsDoorTarget() { return true; }
public func IsDoor() { return true; }

View File

@ -1,3 +1,10 @@
Name=Tür
Description=Eine Tür wo man reingehen kann.
MsgDoorLocked=Diese Tür ist geschlossen, bringe den richtigen Schlüssel mit.
MsgDoorLocked=Diese Tür ist geschlossen, bringe den richtigen Schlüssel mit.
Key=Schluessel
KeyHelp=Ein Clonk muss diesen Schluessel tragen, um die Tuer zu betreten. Danach ist die Tuer entriegelt und kann auch ohne Schluessel betreten werden.
ConnectedDoor=Zieltuer
ConnectedDoorHelp=Wenn ein Clonk die Tuer betritt, wird er in die Zieltuer verschoben.
EntranceAction=Aktion beim Betreten
EntranceActionHelp=Aktion, die beim Betreten der Tuer ausgeloest wird.
KeyUsed=Schluessel benutzt

View File

@ -1,3 +1,10 @@
Name=Door
Description=A door which can be entered.
MsgDoorLocked=This door is locked, bring the right key.
MsgDoorLocked=This door is locked, bring the right key.
Key=Key
KeyHelp=A clonk must carry this key in order to enter the door. After successful entry, the door is unlocked and can be entered by anyone without a key.
ConnectedDoor=Target door
ConnectedDoorHelp=If a clonk enters the door, it will be transferred to this target door.
EntranceAction=Action on entrance
EntranceActionHelp=Action to be executed when a clonk enters the door.
KeyUsed=Key used