mirror of
https://github.com/CHOMPstation/CHOMPstation.git
synced 2026-08-27 05:56:28 +01:00
Adds direction arg for area/move_contents_to()
Attempts to fix shuttle corner transition effect Fixes bad ETAs appearing on status displays
This commit is contained in:
@@ -1,162 +1,3 @@
|
||||
#define IDLE_STATE 0
|
||||
#define WAIT_LAUNCH 1
|
||||
#define WAIT_ARRIVE 2
|
||||
#define WAIT_FINISH 3
|
||||
|
||||
|
||||
/datum/shuttle/ferry
|
||||
var/location = 0 //0 = at area_station, 1 = at area_offsite
|
||||
var/direction = 0 //0 = going to station, 1 = going to offsite.
|
||||
var/process_state = IDLE_STATE
|
||||
|
||||
var/in_use = null //tells the controller whether this shuttle needs processing
|
||||
|
||||
var/area_transition
|
||||
var/travel_time = 0
|
||||
|
||||
var/area_station
|
||||
var/area_offsite
|
||||
//TODO: change location to a string and use a mapping for area and dock targets.
|
||||
var/dock_target_station
|
||||
var/dock_target_offsite
|
||||
|
||||
/datum/shuttle/ferry/short_jump(var/area/origin,var/area/destination)
|
||||
if(isnull(location))
|
||||
return
|
||||
|
||||
if(!destination)
|
||||
destination = get_location_area(!location)
|
||||
if(!origin)
|
||||
origin = get_location_area(location)
|
||||
|
||||
direction = !location
|
||||
..(origin, destination)
|
||||
|
||||
/datum/shuttle/ferry/long_jump(var/area/departing,var/area/destination,var/area/interim,var/travel_time)
|
||||
if(isnull(location))
|
||||
return
|
||||
|
||||
if(!destination)
|
||||
destination = get_location_area(!location)
|
||||
if(!departing)
|
||||
departing = get_location_area(location)
|
||||
|
||||
direction = !location
|
||||
..(departing, destination, interim, travel_time)
|
||||
|
||||
/datum/shuttle/ferry/move(var/area/origin,var/area/destination)
|
||||
if(!destination)
|
||||
destination = get_location_area(!location)
|
||||
if(!origin)
|
||||
origin = get_location_area(location)
|
||||
|
||||
if (docking_controller && !docking_controller.undocked())
|
||||
docking_controller.force_undock()
|
||||
..(origin, destination)
|
||||
|
||||
|
||||
if (destination == area_station) location = 0
|
||||
if (destination == area_offsite) location = 1
|
||||
//if this is a long_jump retain the location we were last at until we get to the new one
|
||||
|
||||
/datum/shuttle/ferry/proc/get_location_area(location_id = null)
|
||||
if (isnull(location_id))
|
||||
location_id = location
|
||||
|
||||
if (!location_id)
|
||||
return area_station
|
||||
return area_offsite
|
||||
|
||||
/datum/shuttle/ferry/proc/process()
|
||||
switch(process_state)
|
||||
if (WAIT_LAUNCH)
|
||||
if (skip_docking_checks() || docking_controller.can_launch())
|
||||
|
||||
if (travel_time && area_transition)
|
||||
long_jump(interim=area_transition, travel_time=travel_time)
|
||||
else
|
||||
short_jump()
|
||||
|
||||
process_state = WAIT_ARRIVE
|
||||
if (WAIT_ARRIVE)
|
||||
if (moving_status == SHUTTLE_IDLE)
|
||||
dock()
|
||||
process_state = WAIT_FINISH
|
||||
if (WAIT_FINISH)
|
||||
if (skip_docking_checks() || docking_controller.docked())
|
||||
process_state = IDLE_STATE
|
||||
in_use = null //release lock
|
||||
arrived()
|
||||
|
||||
/datum/shuttle/ferry/current_dock_target()
|
||||
var/dock_target
|
||||
if (!location) //station
|
||||
dock_target = dock_target_station
|
||||
else
|
||||
dock_target = dock_target_offsite
|
||||
return dock_target
|
||||
|
||||
|
||||
/datum/shuttle/ferry/proc/launch(var/user)
|
||||
if (!can_launch()) return
|
||||
|
||||
in_use = user //obtain an exclusive lock on the shuttle
|
||||
|
||||
process_state = WAIT_LAUNCH
|
||||
undock()
|
||||
|
||||
/datum/shuttle/ferry/proc/force_launch(var/user)
|
||||
if (!can_force()) return
|
||||
|
||||
in_use = user //obtain an exclusive lock on the shuttle
|
||||
|
||||
if (travel_time && area_transition)
|
||||
long_jump(null, null, area_transition, travel_time)
|
||||
else
|
||||
short_jump()
|
||||
|
||||
|
||||
process_state = WAIT_ARRIVE
|
||||
|
||||
/datum/shuttle/ferry/proc/cancel_launch(var/user)
|
||||
if (!can_cancel()) return
|
||||
|
||||
moving_status = SHUTTLE_IDLE
|
||||
process_state = WAIT_FINISH
|
||||
|
||||
if (docking_controller && !docking_controller.undocked())
|
||||
docking_controller.force_undock()
|
||||
|
||||
spawn(10)
|
||||
dock()
|
||||
|
||||
return
|
||||
|
||||
/datum/shuttle/ferry/proc/can_launch()
|
||||
if (moving_status != SHUTTLE_IDLE)
|
||||
return 0
|
||||
|
||||
if (in_use)
|
||||
return 0
|
||||
|
||||
return 1
|
||||
|
||||
/datum/shuttle/ferry/proc/can_force()
|
||||
if (moving_status == SHUTTLE_IDLE && process_state == WAIT_LAUNCH)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/datum/shuttle/ferry/proc/can_cancel()
|
||||
if (moving_status == SHUTTLE_WARMUP || process_state == WAIT_LAUNCH)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
//This gets called when the shuttle finishes arriving at it's destination
|
||||
//This can be used by subtypes to do things when the shuttle arrives.
|
||||
/datum/shuttle/ferry/proc/arrived()
|
||||
return //do nothing for now
|
||||
|
||||
|
||||
/obj/machinery/computer/shuttle_control
|
||||
name = "shuttle control console"
|
||||
icon = 'icons/obj/computer.dmi'
|
||||
@@ -252,4 +93,3 @@
|
||||
|
||||
/obj/machinery/computer/shuttle_control/bullet_act(var/obj/item/projectile/Proj)
|
||||
visible_message("[Proj] ricochets off [src]!")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user