changes for stuff
This commit is contained in:
38
SetPiece_.gd
38
SetPiece_.gd
@@ -41,6 +41,44 @@ signal exited(lab)
|
||||
points_resource = value
|
||||
_update_polygon_from_resource()
|
||||
|
||||
func sample_polygon_point() -> Vector2:
|
||||
if polygon.is_empty():
|
||||
return position
|
||||
var sum_x = 0.0
|
||||
var sum_y = 0.0
|
||||
for p in polygon:
|
||||
sum_x += p.x
|
||||
sum_y += p.y
|
||||
return to_global(Vector2(sum_x / polygon.size(), sum_y / polygon.size()))
|
||||
|
||||
func get_screen_click_point() -> Vector2i:
|
||||
var world_pt = sample_polygon_point()
|
||||
var vp = get_viewport()
|
||||
var screen_pt = vp.get_canvas_transform() * world_pt
|
||||
return Vector2i(int(screen_pt.x), int(screen_pt.y))
|
||||
|
||||
func mock_interact(action = 0) -> void:
|
||||
action = int(action)
|
||||
var script_builder = get_node_or_null("/root/Node2D/GameScript")
|
||||
if script_builder and script_builder.current_script and not script_builder.current_script.can_interrupt:
|
||||
return
|
||||
if interacted.get_connections().size() > 0:
|
||||
emit_signal("interacted")
|
||||
return
|
||||
match action:
|
||||
ActionState.Action.WALK:
|
||||
if walked.get_connections().size() > 0:
|
||||
emit_signal("walked")
|
||||
ActionState.Action.LOOK:
|
||||
if looked.get_connections().size() > 0:
|
||||
emit_signal("looked")
|
||||
ActionState.Action.TOUCH:
|
||||
if touched.get_connections().size() > 0:
|
||||
emit_signal("touched")
|
||||
ActionState.Action.TALK:
|
||||
if talked.get_connections().size() > 0:
|
||||
emit_signal("talked")
|
||||
|
||||
func _input(event):
|
||||
if not Engine.is_editor_hint():
|
||||
if event is InputEventMouseButton and Input.is_action_just_released("interact"):
|
||||
|
||||
Reference in New Issue
Block a user