Skip to content

Instantly share code, notes, and snippets.

CREATE OR REPLACE RULE ship_control_update AS
ON UPDATE TO my_ships DO INSTEAD ( UPDATE ship_control SET target_speed = new.target_speed,
target_direction = new.target_direction,
destination_x = COALESCE(new.destination_x, new.destination[0]),
destination_y = coalesce(new.destination_y, new.destination[1]),
destination = COALESCE(new.destination,POINT(new.destination_x, new.destination_y)), repair_priority = new.repair_priority, action = new.action, action_target_id = new.action_target_id
WHERE ship_control.ship_id = new.id;
UPDATE ship SET name = new.name, fleet_id = new.fleet_id
WHERE ship.id = new.id;
);
CREATE OR REPLACE FUNCTION move_ships()
RETURNS boolean AS
$BODY$
DECLARE
ship_control_ record;
velocity point;
new_velocity point;
vector point;