Gold statue: Decorative items

Can place items in the gold statue hands. In the future, it might be
actual items that get displayed correctly in the hands by themselves
(maybe I have to tinker with the model here, unless we want to have
custom transformation callbacks for every item).
install-platforms
Mark 2017-08-11 21:29:52 +02:00
parent daae41e61d
commit 22e05d7a8f
3 changed files with 126 additions and 0 deletions

View File

@ -1,6 +1,12 @@
#include Library_Ownable
static const IDOL_ITEM_LEFT = 1 << 0;
static const IDOL_ITEM_RIGHT = 1 << 1;
static const IDOL_BONE_LEFT = "Arm_L_Item";
static const IDOL_BONE_RIGHT = "Arm_R_Item";
/*-- Properties --*/
local Name = "$Name$";
@ -47,6 +53,42 @@ public func Definition(proplist type)
PushBack(type.EditorProps.IdolPoses.Options, option);
}
// Ensure that the list of items exists
if (!type.EditorProps.IdolItemL)
{
type.EditorProps.IdolItemL =
{
Type = "enum",
Name = "$ChooseItemLeft$",
EditorHelp = "$ChooseItemHelp$",
Options = [],
Set = "EditorSetItemLeft",
};
}
if (!type.EditorProps.IdolItemR)
{
type.EditorProps.IdolItemR =
{
Type = "enum",
Name = "$ChooseItemRight$",
EditorHelp = "$ChooseItemHelp$",
Options = [],
Set = "EditorSetItemRight",
};
}
// Fill the list with items - this is currently implemented here, but should be implemented in the items.
// For now, I did not want to clutter the items with code that might not be included in the long run
var rotate180 = Trans_Rotate(180, 0, 0, 1);
var scale = 1200;
EditorAddStatueItem(Axe, rotate180, scale);
EditorAddStatueItem(Club, rotate180, scale);
EditorAddStatueItem(Sword, rotate180, scale);
EditorAddStatueItem(Bow, rotate180, scale);
EditorAddStatueItem(Javelin, rotate180, 1500, "Javelin");
EditorAddStatueItem(Shield, Trans_Mul(Trans_Rotate(+90, 0, 0, 1), Trans_Rotate(+90, 1, 0, 0), Trans_Translate(0, -1000, 0)), scale, nil, IDOL_ITEM_LEFT);
EditorAddStatueItem(Shield, Trans_Mul(Trans_Rotate(-90, 0, 0, 1), Trans_Rotate(-90, 1, 0, 0), Trans_Translate(0, -1000, 0)), scale, nil, IDOL_ITEM_RIGHT);
}
public func Initialize()
@ -55,6 +97,82 @@ public func Initialize()
return _inherited(...);
}
/*-- Custom editor actions --*/
private func EditorAddStatueItem(def item, array mesh_transform, int scale, string child_bone, int hands)
{
hands = hands ?? (IDOL_ITEM_LEFT | IDOL_ITEM_RIGHT);
child_bone = child_bone ?? "main";
if (scale) mesh_transform = Trans_Mul(Trans_Scale(scale, scale, scale), mesh_transform);
var item_info = {
Type = item,
Bone = child_bone,
MeshTransformation = mesh_transform,
};
var option = {
Name = item->GetName(),
EditorHelp = item.EditorHelp ?? item->~GetEditorHelp(),
Value = item_info,
};
if (hands & IDOL_ITEM_LEFT)
{
PushBack(this.EditorProps.IdolItemL.Options, option);
}
if (hands & IDOL_ITEM_RIGHT)
{
PushBack(this.EditorProps.IdolItemR.Options, option);
}
}
private func EditorSetItemLeft(proplist item_info)
{
EditorSetItem(item_info, IDOL_BONE_LEFT, this.EditorProps.IdolItemL);
}
private func EditorSetItemRight(proplist item_info)
{
EditorSetItem(item_info, IDOL_BONE_RIGHT, this.EditorProps.IdolItemR);
}
private func EditorSetItem(proplist item_info, string parent_bone, proplist save_settings)
{
if (save_settings.AttachedMesh)
{
DetachMesh(save_settings.AttachedMesh);
}
var submesh = AttachMesh(item_info.Type, parent_bone, item_info.Bone, item_info.MeshTransformation);
save_settings.AttachedMesh = submesh;
save_settings.Choice = item_info;
}
/*-- Scenario saving --*/
public func SaveScenarioObject(props)
{
if (!inherited(props, ...)) return false;
if (this.EditorProps)
{
if (this.EditorProps.IdolItemL && this.EditorProps.IdolItemL.Choice)
{
props->AddCall("IdolItemL", this, "EditorSetItemLeft", this.EditorProps.IdolItemL.Choice);
}
if (this.EditorProps.IdolItemR && this.EditorProps.IdolItemR.Choice)
{
props->AddCall("IdolItemR", this, "EditorSetItemRight", this.EditorProps.IdolItemR.Choice);
}
}
return true;
}
/*-- Actions --*/

View File

@ -16,3 +16,7 @@ PoseItemRightHighName=Gegenstand rechts, erhoben
PoseItemRightHighHelp=Die Statue streckt mit der rechten Hand einen Gegenstand nach oben.
PoseItemCentralName=Gegenstand mittig
PoseItemCentralHelp=Die Statue trägt mit beiden Händen einen Gegenstand vor sich.
ChooseItemLeft=Linke Hand
ChooseItemRight=Rechte Hand
ChooseItemHelp=Legt einen dekorativen Gegenstand in die Hand der Statue.

View File

@ -16,3 +16,7 @@ PoseItemRightHighName=Item right hand, raised
PoseItemRightHighHelp=The statue raises an item in its right hand.
PoseItemCentralName=Item both hands
PoseItemCentralHelp=The statue carries an item in both hands, in front of its torso.
ChooseItemLeft=Left hand
ChooseItemRight=Right hand
ChooseItemHelp=Puts a decorative item into the hand of the statue.