diff --git a/source/match/handlers/SelectionHandler.gd b/source/match/handlers/SelectionHandler.gd index d72eda5..52ccf1d 100644 --- a/source/match/handlers/SelectionHandler.gd +++ b/source/match/handlers/SelectionHandler.gd @@ -24,6 +24,8 @@ func _force_highlight(units_to_highlight): func _unforce_highlight(units_not_to_highlight_anymore): for unit in units_not_to_highlight_anymore.iterate(): + if unit == null: + continue var highlight = unit.find_child("Highlight") if highlight != null: highlight.unforce() diff --git a/source/match/hud/unit-menus/CommandCenterMenu.gd b/source/match/hud/unit-menus/CommandCenterMenu.gd index 0ac6799..4f10ea6 100644 --- a/source/match/hud/unit-menus/CommandCenterMenu.gd +++ b/source/match/hud/unit-menus/CommandCenterMenu.gd @@ -23,5 +23,5 @@ func _ready(): func _on_produce_worker_button_pressed(): - if unit.action != null and unit.action is ManagingProductionAction: + if unit != null and unit.action != null and unit.action is ManagingProductionAction: unit.action.produce(WorkerUnit) diff --git a/source/match/players/simple-clairvoyant-ai/EconomyController.gd b/source/match/players/simple-clairvoyant-ai/EconomyController.gd index 3c6b430..a7149ac 100644 --- a/source/match/players/simple-clairvoyant-ai/EconomyController.gd +++ b/source/match/players/simple-clairvoyant-ai/EconomyController.gd @@ -39,8 +39,12 @@ func provision(resources, metadata): _number_of_pending_worker_resource_requests -= 1 if _ccs.is_empty(): return - _ccs[0].action.produce(WorkerScene) - _number_of_pending_workers += 1 + var action = _ccs[0].action + if action != null: + action.produce(WorkerScene) + _number_of_pending_workers += 1 + else: + print("Tried to call `produce` on a null-action") elif metadata == "cc": assert( resources == Constants.Match.Units.CONSTRUCTION_COSTS[CommandCenterScene.resource_path], diff --git a/source/match/units/actions/FollowingToReachDistance.gd b/source/match/units/actions/FollowingToReachDistance.gd index 528128a..1a0f436 100644 --- a/source/match/units/actions/FollowingToReachDistance.gd +++ b/source/match/units/actions/FollowingToReachDistance.gd @@ -21,7 +21,8 @@ func _ready(): _timer.timeout.connect(_refresh) add_child(_timer) _timer.start(REFRESH_INTERVAL) - _movement_trait.movement_finished.connect(_on_movement_finished) + if _movement_trait != null: + _movement_trait.movement_finished.connect(_on_movement_finished) _refresh() @@ -51,7 +52,8 @@ func _align_movement_if_needed(): _last_known_target_unit_position == null or not _last_known_target_unit_position.is_equal_approx(_target_unit.global_position) ): - _movement_trait.move(_target_unit.global_position) + if _movement_trait != null: + _movement_trait.move(_target_unit.global_position) _last_known_target_unit_position = _target_unit.global_position