allow disabling prop autoplacement

This commit is contained in:
2023-05-16 16:11:57 -06:00
parent 2b362cfd02
commit 3992c42c0f

View File

@@ -478,27 +478,30 @@
(var PROP_MIN_WIDTH 200)
(var PROP_MAX_WIDTH 500)
(prop &mut :Bool autoPlaceProps true)
(method :Void showProp [:FlxSprite prop :StagePosition position :Continuation cc]
(set prop.cameras [flxMovie.screenCamera])
(let [width (min (max prop.width PROP_MIN_WIDTH) PROP_MAX_WIDTH)]
(prop.setGraphicSize width)
(when autoPlaceProps
(prop.setGraphicSize width)
(prop.updateHitbox)
// if the prop is too tall, shrink it heightwise
(when (> prop.height flxMovie.DIALOG_Y)
(prop.setGraphicSize 0 (Std.int flxMovie.DIALOG_Y))
(prop.updateHitbox))
(prop.updateHitbox)
// if the prop is too tall, shrink it heightwise
(when (> prop.height flxMovie.DIALOG_Y)
(prop.setGraphicSize 0 (Std.int flxMovie.DIALOG_Y))
(prop.updateHitbox))
(set prop.x (- position.x (/ prop.width 2)))
(set prop.y (- position.y (/ prop.height 2)))
(set prop.x (- position.x (/ prop.width 2)))
(set prop.y (- position.y (/ prop.height 2)))
(let [propBottom (+ prop.y prop.height)]
// if a prop would block the dialogue box, bump it up
(when (> propBottom flxMovie.DIALOG_Y)
(-= prop.y (- propBottom flxMovie.DIALOG_Y)))
// If a prop goes below the edge, bring it up
(when (> propBottom FlxG.height)
(-= prop.y (- propBottom FlxG.height))))
(let [propBottom (+ prop.y prop.height)]
// if a prop would block the dialogue box, bump it up
(when (> propBottom flxMovie.DIALOG_Y)
(-= prop.y (- propBottom flxMovie.DIALOG_Y)))
// If a prop goes below the edge, bring it up
(when (> propBottom FlxG.height)
(-= prop.y (- propBottom FlxG.height)))))
(let [layerNum position.z]
(assertEquals layerNum (Std.int layerNum))