Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

CT: Made place effect fire *before* we actually calculate any of the …

…things we have to do, since that can take a second in bad cases. It doesn't make it more responsive, it makes it /appear/ more responsive. As a side-effect, it now does the place effect regardless of how placeable the piece actually is.
  • Loading branch information...
commit 00043dce9f3c81b0c297a7f72f912528d32d1ab7 1 parent 59e5029
@DDR0 DDR0 authored
View
25 modules/cube_trains/data/object_prototypes/ct-cursor.cfg
@@ -164,7 +164,12 @@ foo()
] where deltaRemove = unique(delta['remove'])
where tmpAdd = delta['add'] // This must be where-defined, because it doesn't work here. ^----^. :(
where tmpDelta = delta",
-
+
+ place_piece_effect: "[
+ vars.preview.do_place_effect,
+ sound('Track-Clink${1d4}.wav', 0.15),
+ ]",
+
place_piece: "def(position_in) if(((not pieces[piece_selected] in
meta_placers(
map(at_coord(position), value.type)))
@@ -172,9 +177,6 @@ foo()
if(size(filter(pd['add'], 'pds', not pds.consts.meta)) > 0, [
clearRedo(),
apply_placement_delta(pd, position_in),
- vars.preview.do_place_effect,
- //sound('laying-track-b-2.wav', 0.7),
- sound('Track-Clink${1d4}.wav', 0.15),
],[
vars.message.add_text(head(pd.error)), //Although we may have more than one error message, we'll take take one at a time for simplicity's sake. To display all the error messages, just remove the head function.. In addition, we only display the error messages when we couldn't place a piece. This way, we'll not get pointless errors.
]),
@@ -630,7 +632,18 @@ on_render_depth_slowly: "render_depth(vars.location, 10)",
on_disable_undo_and_redo_buttons: "[set(self.vars.undoButton.animation, 'disabled'), set(self.vars.redoButton.animation, 'disabled')]",
-on_place: "place_piece(self.vars.location)",
+on_place_: "place_piece(self.vars.location)",
+on_place: "[
+ schedule(2, fire_event('place_')),
+ place_piece_effect,
+ ]",
+
+on_place_at: "[
+ place_piece_effect,
+ schedule(2, fire_event('place_at_', {'target_location':target_location})),
+ ]",
+on_place_at_: "place_piece(target_location)",
+
on_unplace: "remove_piece(self.vars.location)",
on_rebuild_all_pathing_nodes: "[
@@ -766,7 +779,7 @@ on_process: "[
if(not tmp.dragging or tmp.scrolling,
if((not handled) and vars.preview.setToGrid,
switch(mouse_button,
- 1, [if(not erase_button.pressed, place_piece(selectedGrid([mouse_x, mouse_y])),
+ 1, [if(not erase_button.pressed, fire_event('place_at', {'target_location':selectedGrid([mouse_x, mouse_y])}),
remove_piece(selectedGrid([mouse_x, mouse_y]))),
set(tmp.monitor_for_drag, null)],
2, null,
View
8 modules/cube_trains/data/objects/ct-preview.cfg
@@ -10,7 +10,13 @@ properties: {
set_bright: "def(val) null",
- do_place_effect: "[schedule(2, set(self.alpha, 0)), schedule(10, set(self.alpha, self.vars.max_alpha))]",
+ do_place_effect: "[
+ schedule(3, set(self.alpha, 0)),
+ schedule(5, set(self.alpha, self.vars.max_alpha)),
+ set(self.y, self.y+10),
+ schedule(2, set(self.y, self.y+10)),
+ schedule(3, self.setToGrid(self.location)),
+ ]",
warn_colour: "def(enabled) if(not self.vars.erasing, map(all_preview_objects, set(value.blue, if(not enabled, 0, 255))))",
Please sign in to comment.
Something went wrong with that request. Please try again.