1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
|
/*-- Scaffold --*/
#include Library_Structure
local walls;
/* Initialization */
public func Construction()
{
walls = [nil, nil, nil, nil, nil, nil, nil, nil];
return _inherited(...);
}
public func IsHammerBuildable() { return true; }
func Initialize()
{
return _inherited(...);
}
func Destruction()
{
RemoveWalls();
return _inherited(...);
}
func Incineration()
{
RemoveWalls();
return _inherited(...);
}
func RemoveWalls()
{
for (var wall in walls)
{
if (wall) wall->RemoveObject();
}
return true;
}
/*-- Interaction --*/
public func HasInteractionMenu() { return true; }
public func GetExtensionMenuEntries(object clonk)
{
// Add one menu entry that consists of a whole sub-menu.
var control_entry_prototype =
{
Style = GUI_NoCrop,
BackgroundColor = {Std = 0, Hover = RGB(0, 100, 0)},
OnMouseIn = GuiAction_SetTag("Hover"),
OnMouseOut = GuiAction_SetTag("Std"),
icon =
{
Style = GUI_NoCrop,
Symbol = ScaffoldWall
}
};
var menu_entry =
{
Left = "50% - 6em", Right = "50% + 6em",
Top = "0em", Bottom = "12em",
center_icon =
{
Left = "4em", Right = "8em", Top = "4em", Bottom = "8em",
Margin = "1em",
Symbol = GetID()
},
reinforce_top =
{
Left = "4em", Right = "8em", Top = "0em", Bottom = "4em",
Prototype = control_entry_prototype,
Tooltip = "$Reinforcement$: $Top$",
icon =
{
Prototype = control_entry_prototype.icon,
GraphicsName = "Top",
Top = "3.5em", Bottom = "7.5em"
},
OnClick = GuiAction_Call(this, "Reinforce", 0)
},
reinforce_bottom =
{
Left = "4em", Right = "8em", Top = "8em", Bottom = "12em",
Prototype = control_entry_prototype,
Tooltip = "$Reinforcement$: $Bottom$",
icon = {Prototype = control_entry_prototype.icon, GraphicsName = "Bottom"},
OnClick = GuiAction_Call(this, "Reinforce", 1)
},
reinforce_left =
{
Left = "0em", Right = "4em", Top = "4em", Bottom = "8em",
Prototype = control_entry_prototype,
Tooltip = "$Reinforcement$: $Left$",
icon =
{
Prototype = control_entry_prototype.icon,
GraphicsName = "Left",
Left = "3.5em", Right = "7.5em",
},
OnClick = GuiAction_Call(this, "Reinforce", 2)
},
reinforce_right =
{
Left = "8em", Right = "12em", Top = "4em", Bottom = "8em",
Prototype = control_entry_prototype,
Tooltip = "$Reinforcement$: $Right$",
icon = {Prototype = control_entry_prototype.icon, GraphicsName = "Right"},
OnClick = GuiAction_Call(this, "Reinforce", 3)
},
extend_left =
{
Left = "0em", Right = "4em", Top = "8em", Bottom = "12em",
Prototype = control_entry_prototype,
Tooltip = "$Extension$: $Left$",
icon = { Prototype = control_entry_prototype.icon, GraphicsName = "Bottom" },
OnClick = GuiAction_Call(this, "Reinforce", 4)
},
extend_right =
{
Left = "8em", Right = "12em", Top = "8em", Bottom = "12em",
Prototype = control_entry_prototype,
Tooltip = "$Extension$: $Right$",
icon = { Prototype = control_entry_prototype.icon, GraphicsName = "Bottom" },
OnClick = GuiAction_Call(this, "Reinforce", 5)
},
extend_topleft =
{
Left = "0em", Right = "4em", Top = "0em", Bottom = "4em",
Prototype = control_entry_prototype,
Tooltip = "$Extension$: $Top$ $Left$",
icon =
{
Prototype = control_entry_prototype.icon,
GraphicsName = "Left",
Left = "3.5em", Right = "7.5em",
},
OnClick = GuiAction_Call(this, "Reinforce", 6)
},
extend_topright =
{
Left = "8em", Right = "12em", Top = "0em", Bottom = "4em",
Prototype = control_entry_prototype,
Tooltip = "$Extension$: $Top$ $Right$",
icon =
{
Prototype = control_entry_prototype.icon,
GraphicsName = "Right"
},
OnClick = GuiAction_Call(this, "Reinforce", 7)
},
};
// Replace arrows with real symbols if the wall is already built in that direction.
var subentries = [menu_entry.reinforce_top, menu_entry.reinforce_bottom,
menu_entry.reinforce_left, menu_entry.reinforce_right,
menu_entry.extend_left, menu_entry.extend_right,
menu_entry.extend_topleft, menu_entry.extend_topright];
for (var direction = 0; direction < 8; ++ direction)
{
if (!walls[direction]) continue;
var entry = subentries[direction];
entry.Tooltip = "$TearDown$";
entry.cancel =
{
Margin = "1em",
Symbol = Icon_Cancel,
};
}
return [{symbol = GetID(), custom = menu_entry}];
}
public func GetInteractionMenus(object clonk)
{
var menus = _inherited(clonk, ...) ?? [];
var menu =
{
title = "$ReinforceScaffold$",
entries_callback = this.GetExtensionMenuEntries,
//callback = "OnPumpControl",
callback_hover = "OnExtensionMenuHover",
callback_target = this,
BackgroundColor = RGB(0, 50, 50),
Priority = 20
};
PushBack(menus, menu);
return menus;
}
public func OnExtensionMenuHover(id symbol, string action, desc_menu_target, menu_id)
{
GuiUpdateText("$DescExtend$", menu_id, 1, desc_menu_target);
}
public func Reinforce(int direction)
{
if (walls[direction])
{
walls[direction]->RemoveObject();
}
else
{
var new_wall = CreateObject(ScaffoldWall, 0, 0, GetOwner());
walls[direction] = new_wall;
var callbacks = ["SetTop", "SetBottom", "SetLeft", "SetRight", "SetLeftExtension", "SetRightExtension", "SetTopLeftExtension", "SetTopRightExtension"];
new_wall->Call(callbacks[direction], this);
}
UpdateInteractionMenus(this.GetExtensionMenuEntries);
Sound("Hits::Materials::Wood::DullWoodHit1");
}
/* Destruction */
local ActMap = {
Default = {
Prototype = Action,
Name = "Default",
Procedure = DFA_NONE,
Directions = 1,
Length = 1,
Delay = 0,
FacetBase = 1,
NextAction = "Default",
},
};
public func Definition(proplist def)
{
return _inherited(def, ...);
}
local Name = "$Name$";
local Description = "$Description$";
local ContainBlast = true;
local BlastIncinerate = 100;
local HitPoints = 30;
local Plane = 120;
local Components = {Wood = 1};
|