Adds supply shuttle datum

This commit is contained in:
mwerezak
2014-06-18 12:37:09 -04:00
committed by ZomgPonies
parent 6b692feff0
commit bc2fa7940a
8 changed files with 210 additions and 83 deletions
+2 -4
View File
@@ -1,9 +1,7 @@
//These lists are populated in /datum/shuttle_controller/New()
//Shuttle controller is instantiated in master_controller.dm.
#define SHUTTLE_IDLE 0
#define SHUTTLE_WARMUP 1
#define SHUTTLE_INTRANSIT 2
//shuttle moving state defines are in setup.dm
var/global/list/shuttles
@@ -128,7 +126,7 @@ var/global/list/shuttles
var/datum/shuttle/ferry/shuttle
//Supply and escape shuttles.
shuttle = new()
shuttle = new/datum/shuttle/ferry/supply()
shuttle.location = 1
shuttle.area_offsite = locate(/area/supply/dock)
shuttle.area_station = locate(/area/supply/station)
+15 -7
View File
@@ -22,9 +22,9 @@
return
if(!destination)
destination = (location == 1 ? area_station : area_offsite)
destination = get_location_area(!location)
if(!origin)
origin = (location == 1 ? area_offsite : area_station)
origin = get_location_area(location)
..(origin, destination)
@@ -33,23 +33,31 @@
return
if(!destination)
destination = (location == 1 ? area_station : area_offsite)
destination = get_location_area(!location)
if(!departing)
departing = (location == 1 ? area_offsite : area_station)
departing = get_location_area(location)
..(departing, destination, interim, travel_time)
/datum/shuttle/ferry/move(var/area/origin,var/area/destination)
if(!destination)
destination = (location == 1 ? area_station : area_offsite)
destination = get_location_area(!location)
if(!origin)
origin = (location == 1 ? area_offsite : area_station)
origin = get_location_area(location)
if (docking_controller && !docking_controller.undocked())
docking_controller.force_undock()
..(origin, destination)
location = !location
/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_shuttle()
switch(process_state)
if (WAIT_LAUNCH)
+76
View File
@@ -0,0 +1,76 @@
/datum/shuttle/ferry/supply
var/away_location = 1 //the location to hide at while pretending to be in-transit
var/arrive_time = 0
/datum/shuttle/ferry/supply/short_jump(var/area/origin,var/area/destination)
if(moving_status != SHUTTLE_IDLE)
return
if(isnull(location))
return
if(!destination)
destination = get_location_area(!location)
if(!origin)
origin = get_location_area(location)
if (!at_station()) //at centcom
supply_shuttle.buy()
//it would be cool to play a sound here
moving_status = SHUTTLE_WARMUP
spawn(warmup_time*10)
if (moving_status == SHUTTLE_IDLE)
return //someone cancelled the launch
if (at_station() && forbidden_atoms_check())
//cancel the launch because of forbidden atoms. announce over supply channel?
return
//We pretend it's a long_jump by making the shuttle stay at centcom for the "in-transit" period.
var/area/away_area = get_location_area(away_location)
if (origin == away_area)
moving_status = SHUTTLE_INTRANSIT //pretend
else
move(origin, away_area)
//wait ETA here.
arrive_time = world.time + supply_shuttle.movetime
while (world.time <= arrive_time)
sleep(5)
if (destination != away_area)
move(away_area, destination)
moving_status = SHUTTLE_IDLE
if (!at_station()) //at centcom
supply_shuttle.sell()
// returns 1 if the supply shuttle should be prevented from moving because it contains forbidden atoms
/datum/shuttle/ferry/supply/proc/forbidden_atoms_check()
if (!at_station())
return 0 //if badmins want to send mobs or a nuke on the supply shuttle from centcom we don't care
return supply_shuttle.forbidden_atoms_check(get_location_area())
/datum/shuttle/ferry/supply/proc/at_station()
return (!location)
//returns 1 if the shuttle is moving and we can show valid ETAs
/datum/shuttle/ferry/supply/proc/has_eta()
return (moving_status == SHUTTLE_INTRANSIT)
//returns 1 if the shuttle is idle and we can still mess with the cargo shopping list
/datum/shuttle/ferry/supply/proc/idle()
return (moving_status == SHUTTLE_IDLE)
//returns the ETA in minutes
/datum/shuttle/ferry/supply/proc/eta_minutes()
var/ticksleft = arrive_time - world.time
return round(ticksleft/600,1)