mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2025-12-29 19:43:16 +00:00
Ported Basic Overmap Functionality
- Ports the overmap, ships, sectors, and "landable" ships from baystation. - Ports necessary computers to control ships and overmap shuttles. - Shims missing machine and computer functionality pending future enhancements. - Includes required new sprites and sounds.
This commit is contained in:
104
code/modules/overmap/ships/computers/computer_shims.dm
Normal file
104
code/modules/overmap/ships/computers/computer_shims.dm
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
**
|
||||
** HELLO! DON'T COPY THINGS FROM HERE - READ THIS!
|
||||
**
|
||||
** The ship machines/computers ported from baystation expect certain procs and infrastruture that we don't have.
|
||||
** I /could/ just port those computers to our code, but I actually *like* that infrastructure. But I
|
||||
** don't have time (yet) to implement it fully in our codebase, so I'm shimming it here experimentally as a test
|
||||
** bed for later implementing it on /obj/machinery and /obj/machinery/computer for everything. ~Leshana (March 2020)
|
||||
*/
|
||||
|
||||
//
|
||||
// Power
|
||||
//
|
||||
|
||||
// This will have this machine have its area eat this much power next tick, and not afterwards. Do not use for continued power draw.
|
||||
/obj/machinery/proc/use_power_oneoff(var/amount, var/chan = -1)
|
||||
return use_power(amount, chan)
|
||||
|
||||
// Change one of the power consumption vars
|
||||
/obj/machinery/proc/change_power_consumption(new_power_consumption, use_power_mode = USE_POWER_IDLE)
|
||||
switch(use_power_mode)
|
||||
if(USE_POWER_IDLE)
|
||||
idle_power_usage = new_power_consumption
|
||||
if(USE_POWER_ACTIVE)
|
||||
active_power_usage = new_power_consumption
|
||||
// No need to do anything else in our power scheme.
|
||||
|
||||
// Defining directly here to avoid conflicts with existing set_broken procs in our codebase that behave differently.
|
||||
/obj/machinery/atmospherics/unary/engine/proc/set_broken(var/new_state, var/cause)
|
||||
if(!(stat & BROKEN) == !new_state)
|
||||
return // Nothing changed
|
||||
stat ^= BROKEN
|
||||
update_icon()
|
||||
|
||||
|
||||
//
|
||||
// Compoenents
|
||||
//
|
||||
|
||||
/obj/machinery/proc/total_component_rating_of_type(var/part_type)
|
||||
. = 0
|
||||
for(var/thing in component_parts)
|
||||
if(istype(thing, part_type))
|
||||
var/obj/item/weapon/stock_parts/part = thing
|
||||
. += part.rating
|
||||
// Now isn't THIS a cool idea?
|
||||
// for(var/path in uncreated_component_parts)
|
||||
// if(ispath(path, part_type))
|
||||
// var/obj/item/weapon/stock_parts/comp = path
|
||||
// . += initial(comp.rating) * uncreated_component_parts[path]
|
||||
|
||||
//
|
||||
// Skills
|
||||
//
|
||||
/obj/machinery/computer/ship
|
||||
var/core_skill = /datum/skill/devices //The skill used for skill checks for this machine (mostly so subtypes can use different skills).
|
||||
|
||||
//
|
||||
// Topic
|
||||
//
|
||||
|
||||
/obj/machinery/computer/ship/proc/DefaultTopicState()
|
||||
return global.default_state
|
||||
|
||||
/obj/machinery/computer/ship/Topic(var/href, var/href_list = list(), var/datum/topic_state/state)
|
||||
if((. = ..()))
|
||||
return
|
||||
state = state || DefaultTopicState() || global.default_state
|
||||
if(CanUseTopic(usr, state, href_list) == STATUS_INTERACTIVE)
|
||||
CouldUseTopic(usr)
|
||||
return OnTopic(usr, href_list, state)
|
||||
CouldNotUseTopic(usr)
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/computer/ship/proc/OnTopic(var/mob/user, var/href_list, var/datum/topic_state/state)
|
||||
return TOPIC_NOACTION
|
||||
|
||||
//
|
||||
// Interaction
|
||||
//
|
||||
|
||||
// If you want to have interface interactions handled for you conveniently, use this.
|
||||
// Return TRUE for handled.
|
||||
// If you perform direct interactions in here, you are responsible for ensuring that full interactivity checks have been made (i.e CanInteract).
|
||||
// The checks leading in to here only guarantee that the user should be able to view a UI.
|
||||
/obj/machinery/computer/ship/proc/interface_interact(var/mob/user)
|
||||
ui_interact(user)
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/computer/ship/attack_ai(mob/user)
|
||||
if(CanUseTopic(user, DefaultTopicState()) > STATUS_CLOSE)
|
||||
return interface_interact(user)
|
||||
|
||||
// After a recent rework this should mostly be safe.
|
||||
/obj/machinery/computer/ship/attack_ghost(mob/user)
|
||||
interface_interact(user)
|
||||
|
||||
// If you don't call parent in this proc, you must make all appropriate checks yourself.
|
||||
// If you do, you must respect the return value.
|
||||
/obj/machinery/computer/ship/attack_hand(mob/user)
|
||||
if((. = ..()))
|
||||
return
|
||||
if(CanUseTopic(user, DefaultTopicState()) > STATUS_CLOSE)
|
||||
return interface_interact(user)
|
||||
@@ -1,46 +1,24 @@
|
||||
//Engine control and monitoring console
|
||||
|
||||
/obj/machinery/computer/engines
|
||||
/obj/machinery/computer/ship/engines
|
||||
name = "engine control console"
|
||||
icon_keyboard = "tech_key"
|
||||
icon_screen = "id"
|
||||
var/state = "status"
|
||||
var/list/engines = list()
|
||||
var/obj/effect/map/ship/linked
|
||||
icon_screen = "engines"
|
||||
var/display_state = "status"
|
||||
|
||||
/obj/machinery/computer/engines/Initialize()
|
||||
. = ..()
|
||||
linked = map_sectors["[z]"]
|
||||
if (linked)
|
||||
if (!linked.eng_control)
|
||||
linked.eng_control = src
|
||||
testing("Engines console at level [z] found a corresponding overmap object '[linked.name]'.")
|
||||
else
|
||||
testing("Engines console at level [z] was unable to find a corresponding overmap object.")
|
||||
|
||||
for(var/datum/ship_engine/E in engines)
|
||||
if (E.zlevel == z && !(E in engines))
|
||||
engines += E
|
||||
|
||||
/obj/machinery/computer/engines/attack_hand(var/mob/user as mob)
|
||||
if(..())
|
||||
user.unset_machine()
|
||||
return
|
||||
|
||||
if(!isAI(user))
|
||||
user.set_machine(src)
|
||||
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/computer/engines/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
/obj/machinery/computer/ship/engines/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
if(!linked)
|
||||
display_reconnect_dialog(user, "ship control systems")
|
||||
return
|
||||
|
||||
var/data[0]
|
||||
data["state"] = state
|
||||
data["state"] = display_state
|
||||
data["global_state"] = linked.engines_state
|
||||
data["global_limit"] = round(linked.thrust_limit*100)
|
||||
var/total_thrust = 0
|
||||
|
||||
var/list/enginfo[0]
|
||||
for(var/datum/ship_engine/E in engines)
|
||||
for(var/datum/ship_engine/E in linked.engines)
|
||||
var/list/rdata[0]
|
||||
rdata["eng_type"] = E.name
|
||||
rdata["eng_on"] = E.is_on()
|
||||
@@ -48,54 +26,70 @@
|
||||
rdata["eng_thrust_limiter"] = round(E.get_thrust_limit()*100)
|
||||
rdata["eng_status"] = E.get_status()
|
||||
rdata["eng_reference"] = "\ref[E]"
|
||||
total_thrust += E.get_thrust()
|
||||
enginfo.Add(list(rdata))
|
||||
|
||||
data["engines_info"] = enginfo
|
||||
data["total_thrust"] = total_thrust
|
||||
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "engines_control.tmpl", "[linked.name] Engines Control", 380, 530)
|
||||
ui = new(user, src, ui_key, "engines_control.tmpl", "[linked.name] Engines Control", 390, 530)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
|
||||
/obj/machinery/computer/engines/Topic(href, href_list)
|
||||
/obj/machinery/computer/ship/engines/OnTopic(var/mob/user, var/list/href_list, state)
|
||||
if(..())
|
||||
return 1
|
||||
return ..()
|
||||
|
||||
if(href_list["state"])
|
||||
state = href_list["state"]
|
||||
display_state = href_list["state"]
|
||||
return TOPIC_REFRESH
|
||||
|
||||
if(href_list["global_toggle"])
|
||||
linked.engines_state = !linked.engines_state
|
||||
for(var/datum/ship_engine/E in linked.engines)
|
||||
if(linked.engines_state == !E.is_on())
|
||||
E.toggle()
|
||||
return TOPIC_REFRESH
|
||||
|
||||
if(href_list["set_global_limit"])
|
||||
var/newlim = input("Input new thrust limit (0..100%)", "Thrust limit", linked.thrust_limit*100) as num
|
||||
if(!CanInteract(user, state))
|
||||
return TOPIC_NOACTION
|
||||
linked.thrust_limit = CLAMP(newlim/100, 0, 1)
|
||||
for(var/datum/ship_engine/E in linked.engines)
|
||||
E.set_thrust_limit(linked.thrust_limit)
|
||||
return TOPIC_REFRESH
|
||||
|
||||
if(href_list["global_limit"])
|
||||
linked.thrust_limit = CLAMP(linked.thrust_limit + text2num(href_list["global_limit"]), 0, 1)
|
||||
for(var/datum/ship_engine/E in linked.engines)
|
||||
E.set_thrust_limit(linked.thrust_limit)
|
||||
return TOPIC_REFRESH
|
||||
|
||||
if(href_list["engine"])
|
||||
if(href_list["set_limit"])
|
||||
var/datum/ship_engine/E = locate(href_list["engine"])
|
||||
var/newlim = input("Input new thrust limit (0..100)", "Thrust limit", E.get_thrust_limit()) as num
|
||||
if(!CanInteract(user, state))
|
||||
return
|
||||
var/limit = CLAMP(newlim/100, 0, 1)
|
||||
if(E)
|
||||
if(istype(E))
|
||||
E.set_thrust_limit(limit)
|
||||
|
||||
return TOPIC_REFRESH
|
||||
if(href_list["limit"])
|
||||
var/datum/ship_engine/E = locate(href_list["engine"])
|
||||
var/limit = CLAMP(E.get_thrust_limit() + text2num(href_list["limit"]), 0, 1)
|
||||
if(E)
|
||||
if(istype(E))
|
||||
E.set_thrust_limit(limit)
|
||||
return TOPIC_REFRESH
|
||||
|
||||
if(href_list["toggle"])
|
||||
var/datum/ship_engine/E = locate(href_list["engine"])
|
||||
if(E)
|
||||
if(istype(E))
|
||||
E.toggle()
|
||||
|
||||
add_fingerprint(usr)
|
||||
updateUsrDialog()
|
||||
|
||||
/obj/machinery/computer/engines/proc/burn()
|
||||
if(engines.len == 0)
|
||||
return 0
|
||||
var/res = 0
|
||||
for(var/datum/ship_engine/E in engines)
|
||||
res |= E.burn()
|
||||
return res
|
||||
|
||||
/obj/machinery/computer/engines/proc/get_total_thrust()
|
||||
for(var/datum/ship_engine/E in engines)
|
||||
. += E.get_thrust()
|
||||
return TOPIC_REFRESH
|
||||
return TOPIC_REFRESH
|
||||
return TOPIC_NOACTION
|
||||
@@ -1,151 +1,188 @@
|
||||
/obj/machinery/computer/helm
|
||||
// LEGACY_RECORD_STRUCTURE(all_waypoints, waypoint)
|
||||
GLOBAL_LIST_EMPTY(all_waypoints)
|
||||
/datum/computer_file/data/waypoint
|
||||
var/list/fields
|
||||
filetype = "WPT"
|
||||
|
||||
/datum/computer_file/data/waypoint/New()
|
||||
..()
|
||||
fields = list()
|
||||
GLOB.all_waypoints.Add(src)
|
||||
|
||||
/datum/computer_file/data/waypoint/Destroy()
|
||||
. = ..()
|
||||
GLOB.all_waypoints.Remove(src);
|
||||
// End LEGACY_RECORD_STRUCTURE(all_waypoints, waypoint)
|
||||
|
||||
/obj/machinery/computer/ship/helm
|
||||
name = "helm control console"
|
||||
icon_keyboard = "med_key"
|
||||
icon_screen = "id"
|
||||
var/state = "status"
|
||||
var/obj/effect/map/ship/linked //connected overmap object
|
||||
icon_keyboard = "teleport_key"
|
||||
icon_screen = "helm"
|
||||
light_color = "#7faaff"
|
||||
core_skill = /datum/skill/pilot
|
||||
var/autopilot = 0
|
||||
var/manual_control = 0
|
||||
var/list/known_sectors = list()
|
||||
var/dx //desitnation
|
||||
var/dy //coordinates
|
||||
var/speedlimit = 1/(20 SECONDS) //top speed for autopilot, 5
|
||||
var/accellimit = 0.001 //manual limiter for acceleration
|
||||
req_one_access = list(access_pilot)
|
||||
|
||||
/obj/machinery/computer/helm/Initialize()
|
||||
/obj/machinery/computer/ship/helm/Initialize()
|
||||
. = ..()
|
||||
linked = map_sectors["[z]"]
|
||||
if (linked)
|
||||
if(!linked.nav_control)
|
||||
linked.nav_control = src
|
||||
testing("Helm console at level [z] found a corresponding overmap object '[linked.name]'.")
|
||||
else
|
||||
testing("Helm console at level [z] was unable to find a corresponding overmap object.")
|
||||
get_known_sectors()
|
||||
|
||||
for(var/level in map_sectors)
|
||||
var/obj/effect/map/sector/S = map_sectors["[level]"]
|
||||
if (istype(S) && S.always_known)
|
||||
var/datum/data/record/R = new()
|
||||
/obj/machinery/computer/ship/helm/proc/get_known_sectors()
|
||||
var/area/overmap/map = locate() in world
|
||||
for(var/obj/effect/overmap/visitable/sector/S in map)
|
||||
if (S.known)
|
||||
var/datum/computer_file/data/waypoint/R = new()
|
||||
R.fields["name"] = S.name
|
||||
R.fields["x"] = S.x
|
||||
R.fields["y"] = S.y
|
||||
known_sectors += R
|
||||
known_sectors[S.name] = R
|
||||
|
||||
/obj/machinery/computer/helm/process()
|
||||
/obj/machinery/computer/ship/helm/process()
|
||||
..()
|
||||
if (autopilot && dx && dy)
|
||||
var/turf/T = locate(dx,dy,1)
|
||||
var/turf/T = locate(dx,dy,global.using_map.overmap_z)
|
||||
if(linked.loc == T)
|
||||
if(linked.is_still())
|
||||
autopilot = 0
|
||||
else
|
||||
linked.decelerate()
|
||||
|
||||
var/brake_path = linked.get_brake_path()
|
||||
|
||||
if(get_dist(linked.loc, T) > brake_path)
|
||||
linked.accelerate(get_dir(linked.loc, T))
|
||||
else
|
||||
linked.decelerate()
|
||||
var/brake_path = linked.get_brake_path()
|
||||
var/direction = get_dir(linked.loc, T)
|
||||
var/acceleration = min(linked.get_acceleration(), accellimit)
|
||||
var/speed = linked.get_speed()
|
||||
var/heading = linked.get_heading()
|
||||
|
||||
// Destination is current grid or speedlimit is exceeded
|
||||
if ((get_dist(linked.loc, T) <= brake_path) || speed > speedlimit)
|
||||
linked.decelerate()
|
||||
// Heading does not match direction
|
||||
else if (heading & ~direction)
|
||||
linked.accelerate(turn(heading & ~direction, 180), accellimit)
|
||||
// All other cases, move toward direction
|
||||
else if (speed + acceleration <= speedlimit)
|
||||
linked.accelerate(direction, accellimit)
|
||||
linked.operator_skill = null//if this is on you can't dodge meteors
|
||||
return
|
||||
|
||||
/obj/machinery/computer/helm/relaymove(var/mob/user, direction)
|
||||
if(manual_control && linked)
|
||||
linked.relaymove(user,direction)
|
||||
/obj/machinery/computer/ship/helm/relaymove(var/mob/user, direction)
|
||||
if(viewing_overmap(user) && linked)
|
||||
if(prob(user.skill_fail_chance(/datum/skill/pilot, 50, linked.skill_needed, factor = 1)))
|
||||
direction = turn(direction,pick(90,-90))
|
||||
linked.relaymove(user, direction, accellimit)
|
||||
return 1
|
||||
|
||||
/obj/machinery/computer/helm/check_eye(var/mob/user as mob)
|
||||
if (!manual_control)
|
||||
return -1
|
||||
if (!get_dist(user, src) > 1 || user.blinded || !linked )
|
||||
return -1
|
||||
return 0
|
||||
|
||||
/obj/machinery/computer/helm/attack_hand(var/mob/user as mob)
|
||||
if(..())
|
||||
user.unset_machine()
|
||||
manual_control = 0
|
||||
return
|
||||
|
||||
if(!isAI(user))
|
||||
user.set_machine(src)
|
||||
if(linked)
|
||||
user.reset_view(linked)
|
||||
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/computer/helm/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
if(!linked)
|
||||
return
|
||||
|
||||
/obj/machinery/computer/ship/helm/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
var/data[0]
|
||||
data["state"] = state
|
||||
|
||||
data["sector"] = linked.current_sector ? linked.current_sector.name : "Deep Space"
|
||||
data["sector_info"] = linked.current_sector ? linked.current_sector.desc : "Not Available"
|
||||
data["s_x"] = linked.x
|
||||
data["s_y"] = linked.y
|
||||
data["dest"] = dy && dx
|
||||
data["d_x"] = dx
|
||||
data["d_y"] = dy
|
||||
data["speed"] = linked.get_speed()
|
||||
data["accel"] = round(linked.get_acceleration())
|
||||
data["heading"] = linked.get_heading() ? dir2angle(linked.get_heading()) : 0
|
||||
data["autopilot"] = autopilot
|
||||
data["manual_control"] = manual_control
|
||||
if(!linked)
|
||||
display_reconnect_dialog(user, "helm")
|
||||
else
|
||||
var/turf/T = get_turf(linked)
|
||||
var/obj/effect/overmap/visitable/sector/current_sector = locate() in T
|
||||
|
||||
var/list/locations[0]
|
||||
for (var/datum/data/record/R in known_sectors)
|
||||
var/list/rdata[0]
|
||||
rdata["name"] = R.fields["name"]
|
||||
rdata["x"] = R.fields["x"]
|
||||
rdata["y"] = R.fields["y"]
|
||||
rdata["reference"] = "\ref[R]"
|
||||
locations.Add(list(rdata))
|
||||
data["sector"] = current_sector ? current_sector.name : "Deep Space"
|
||||
data["sector_info"] = current_sector ? current_sector.desc : "Not Available"
|
||||
data["landed"] = linked.get_landed_info()
|
||||
data["s_x"] = linked.x
|
||||
data["s_y"] = linked.y
|
||||
data["dest"] = dy && dx
|
||||
data["d_x"] = dx
|
||||
data["d_y"] = dy
|
||||
data["speedlimit"] = speedlimit ? speedlimit*1000 : "Halted"
|
||||
data["accel"] = min(round(linked.get_acceleration()*1000, 0.01),accellimit*1000)
|
||||
data["heading"] = linked.get_heading_degrees()
|
||||
data["autopilot"] = autopilot
|
||||
data["manual_control"] = viewing_overmap(user)
|
||||
data["canburn"] = linked.can_burn()
|
||||
data["accellimit"] = accellimit*1000
|
||||
|
||||
data["locations"] = locations
|
||||
var/speed = round(linked.get_speed()*1000, 0.01)
|
||||
if(linked.get_speed() < SHIP_SPEED_SLOW)
|
||||
speed = "<span class='good'>[speed]</span>"
|
||||
if(linked.get_speed() > SHIP_SPEED_FAST)
|
||||
speed = "<span class='average'>[speed]</span>"
|
||||
data["speed"] = speed
|
||||
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "helm.tmpl", "[linked.name] Helm Control", 380, 530)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
if(linked.get_speed())
|
||||
data["ETAnext"] = "[round(linked.ETA()/10)] seconds"
|
||||
else
|
||||
data["ETAnext"] = "N/A"
|
||||
|
||||
/obj/machinery/computer/helm/Topic(href, href_list)
|
||||
var/list/locations[0]
|
||||
for (var/key in known_sectors)
|
||||
var/datum/computer_file/data/waypoint/R = known_sectors[key]
|
||||
var/list/rdata[0]
|
||||
rdata["name"] = R.fields["name"]
|
||||
rdata["x"] = R.fields["x"]
|
||||
rdata["y"] = R.fields["y"]
|
||||
rdata["reference"] = "\ref[R]"
|
||||
locations.Add(list(rdata))
|
||||
|
||||
data["locations"] = locations
|
||||
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "helm.tmpl", "[linked.name] Helm Control", 565, 545)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
|
||||
/obj/machinery/computer/ship/helm/OnTopic(var/mob/user, var/list/href_list, state)
|
||||
if(..())
|
||||
return 1
|
||||
return TOPIC_HANDLED
|
||||
|
||||
if (!linked)
|
||||
return
|
||||
if(!linked)
|
||||
return TOPIC_HANDLED
|
||||
|
||||
if (href_list["add"])
|
||||
var/datum/data/record/R = new()
|
||||
var/datum/computer_file/data/waypoint/R = new()
|
||||
var/sec_name = input("Input naviation entry name", "New navigation entry", "Sector #[known_sectors.len]") as text
|
||||
if(!CanInteract(user,state))
|
||||
return TOPIC_NOACTION
|
||||
if(!sec_name)
|
||||
sec_name = "Sector #[known_sectors.len]"
|
||||
R.fields["name"] = sec_name
|
||||
if(sec_name in known_sectors)
|
||||
to_chat(user, "<span class='warning'>Sector with that name already exists, please input a different name.</span>")
|
||||
return TOPIC_REFRESH
|
||||
switch(href_list["add"])
|
||||
if("current")
|
||||
R.fields["x"] = linked.x
|
||||
R.fields["y"] = linked.y
|
||||
if("new")
|
||||
var/newx = input("Input new entry x coordinate", "Coordinate input", linked.x) as num
|
||||
R.fields["x"] = CLAMP(newx, 1, world.maxx)
|
||||
if(!CanInteract(user,state))
|
||||
return TOPIC_REFRESH
|
||||
var/newy = input("Input new entry y coordinate", "Coordinate input", linked.y) as num
|
||||
if(!CanInteract(user,state))
|
||||
return TOPIC_NOACTION
|
||||
R.fields["x"] = CLAMP(newx, 1, world.maxx)
|
||||
R.fields["y"] = CLAMP(newy, 1, world.maxy)
|
||||
known_sectors += R
|
||||
known_sectors[sec_name] = R
|
||||
|
||||
if (href_list["remove"])
|
||||
var/datum/data/record/R = locate(href_list["remove"])
|
||||
known_sectors.Remove(R)
|
||||
var/datum/computer_file/data/waypoint/R = locate(href_list["remove"])
|
||||
if(R)
|
||||
known_sectors.Remove(R.fields["name"])
|
||||
qdel(R)
|
||||
|
||||
if (href_list["setx"])
|
||||
var/newx = input("Input new destiniation x coordinate", "Coordinate input", dx) as num|null
|
||||
if(!CanInteract(user,state))
|
||||
return
|
||||
if (newx)
|
||||
dx = CLAMP(newx, 1, world.maxx)
|
||||
|
||||
if (href_list["sety"])
|
||||
var/newy = input("Input new destiniation y coordinate", "Coordinate input", dy) as num|null
|
||||
if(!CanInteract(user,state))
|
||||
return
|
||||
if (newy)
|
||||
dy = CLAMP(newy, 1, world.maxy)
|
||||
|
||||
@@ -157,9 +194,20 @@
|
||||
dx = 0
|
||||
dy = 0
|
||||
|
||||
if (href_list["speedlimit"])
|
||||
var/newlimit = input("Input new speed limit for autopilot (0 to brake)", "Autopilot speed limit", speedlimit*1000) as num|null
|
||||
if(newlimit)
|
||||
speedlimit = CLAMP(newlimit/1000, 0, 100)
|
||||
if (href_list["accellimit"])
|
||||
var/newlimit = input("Input new acceleration limit", "Acceleration limit", accellimit*1000) as num|null
|
||||
if(newlimit)
|
||||
accellimit = max(newlimit/1000, 0)
|
||||
|
||||
if (href_list["move"])
|
||||
var/ndir = text2num(href_list["move"])
|
||||
linked.relaymove(usr, ndir)
|
||||
if(prob(user.skill_fail_chance(/datum/skill/pilot, 50, linked.skill_needed, factor = 1)))
|
||||
ndir = turn(ndir,pick(90,-90))
|
||||
linked.relaymove(user, ndir, accellimit)
|
||||
|
||||
if (href_list["brake"])
|
||||
linked.decelerate()
|
||||
@@ -168,10 +216,71 @@
|
||||
autopilot = !autopilot
|
||||
|
||||
if (href_list["manual"])
|
||||
manual_control = !manual_control
|
||||
viewing_overmap(user) ? unlook(user) : look(user)
|
||||
|
||||
if (href_list["state"])
|
||||
state = href_list["state"]
|
||||
add_fingerprint(usr)
|
||||
add_fingerprint(user)
|
||||
updateUsrDialog()
|
||||
|
||||
|
||||
/obj/machinery/computer/ship/navigation
|
||||
name = "navigation console"
|
||||
icon_keyboard = "generic_key"
|
||||
icon_screen = "helm"
|
||||
|
||||
/obj/machinery/computer/ship/navigation/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
if(!linked)
|
||||
display_reconnect_dialog(user, "Navigation")
|
||||
return
|
||||
|
||||
var/data[0]
|
||||
|
||||
|
||||
var/turf/T = get_turf(linked)
|
||||
var/obj/effect/overmap/visitable/sector/current_sector = locate() in T
|
||||
|
||||
data["sector"] = current_sector ? current_sector.name : "Deep Space"
|
||||
data["sector_info"] = current_sector ? current_sector.desc : "Not Available"
|
||||
data["s_x"] = linked.x
|
||||
data["s_y"] = linked.y
|
||||
data["speed"] = round(linked.get_speed()*1000, 0.01)
|
||||
data["accel"] = round(linked.get_acceleration()*1000, 0.01)
|
||||
data["heading"] = linked.get_heading_degrees()
|
||||
data["viewing"] = viewing_overmap(user)
|
||||
|
||||
if(linked.get_speed())
|
||||
data["ETAnext"] = "[round(linked.ETA()/10)] seconds"
|
||||
else
|
||||
data["ETAnext"] = "N/A"
|
||||
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "nav.tmpl", "[linked.name] Navigation Screen", 380, 530)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
|
||||
/obj/machinery/computer/ship/navigation/OnTopic(var/mob/user, var/list/href_list)
|
||||
if(..())
|
||||
return TOPIC_HANDLED
|
||||
|
||||
if (!linked)
|
||||
return TOPIC_NOACTION
|
||||
|
||||
if (href_list["viewing"])
|
||||
viewing_overmap(user) ? unlook(user) : look(user)
|
||||
return TOPIC_REFRESH
|
||||
|
||||
/obj/machinery/computer/ship/navigation/telescreen //little hacky but it's only used on one ship so it should be okay
|
||||
icon_state = "tele_nav"
|
||||
icon_keyboard = null
|
||||
icon_screen = null
|
||||
density = 0
|
||||
|
||||
/obj/machinery/computer/ship/navigation/telescreen/update_icon()
|
||||
if(stat & NOPOWER || stat & BROKEN)
|
||||
icon_state = "tele_off"
|
||||
set_light(0)
|
||||
else
|
||||
icon_state = "tele_nav"
|
||||
set_light(light_range_on, light_power_on)
|
||||
..()
|
||||
|
||||
226
code/modules/overmap/ships/computers/sensors.dm
Normal file
226
code/modules/overmap/ships/computers/sensors.dm
Normal file
@@ -0,0 +1,226 @@
|
||||
/obj/machinery/computer/ship/sensors
|
||||
name = "sensors console"
|
||||
icon_keyboard = "teleport_key"
|
||||
icon_screen = "teleport"
|
||||
light_color = "#77fff8"
|
||||
extra_view = 4
|
||||
var/obj/machinery/shipsensors/sensors
|
||||
|
||||
/obj/machinery/computer/ship/sensors/attempt_hook_up(obj/effect/overmap/visitable/ship/sector)
|
||||
if(!(. = ..()))
|
||||
return
|
||||
find_sensors()
|
||||
|
||||
/obj/machinery/computer/ship/sensors/proc/find_sensors()
|
||||
if(!linked)
|
||||
return
|
||||
for(var/obj/machinery/shipsensors/S in global.machines)
|
||||
if(linked.check_ownership(S))
|
||||
sensors = S
|
||||
break
|
||||
|
||||
/obj/machinery/computer/ship/sensors/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
if(!linked)
|
||||
display_reconnect_dialog(user, "sensors")
|
||||
return
|
||||
|
||||
var/data[0]
|
||||
|
||||
data["viewing"] = viewing_overmap(user)
|
||||
if(sensors)
|
||||
data["on"] = sensors.use_power
|
||||
data["range"] = sensors.range
|
||||
data["health"] = sensors.health
|
||||
data["max_health"] = sensors.max_health
|
||||
data["heat"] = sensors.heat
|
||||
data["critical_heat"] = sensors.critical_heat
|
||||
if(sensors.health == 0)
|
||||
data["status"] = "DESTROYED"
|
||||
else if(!sensors.powered())
|
||||
data["status"] = "NO POWER"
|
||||
else if(!sensors.in_vacuum())
|
||||
data["status"] = "VACUUM SEAL BROKEN"
|
||||
else
|
||||
data["status"] = "OK"
|
||||
var/list/contacts = list()
|
||||
for(var/obj/effect/overmap/O in view(7,linked))
|
||||
if(linked == O)
|
||||
continue
|
||||
if(!O.scannable)
|
||||
continue
|
||||
var/bearing = round(90 - ATAN2(O.x - linked.x, O.y - linked.y),5)
|
||||
if(bearing < 0)
|
||||
bearing += 360
|
||||
contacts.Add(list(list("name"=O.name, "ref"="\ref[O]", "bearing"=bearing)))
|
||||
if(contacts.len)
|
||||
data["contacts"] = contacts
|
||||
else
|
||||
data["status"] = "MISSING"
|
||||
data["range"] = "N/A"
|
||||
data["on"] = 0
|
||||
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "shipsensors.tmpl", "[linked.name] Sensors Control", 420, 530, src)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
|
||||
/obj/machinery/computer/ship/sensors/OnTopic(var/mob/user, var/list/href_list, state)
|
||||
if(..())
|
||||
return TOPIC_HANDLED
|
||||
|
||||
if (!linked)
|
||||
return TOPIC_NOACTION
|
||||
|
||||
if (href_list["viewing"])
|
||||
if(user && !isAI(user))
|
||||
viewing_overmap(user) ? unlook(user) : look(user)
|
||||
return TOPIC_REFRESH
|
||||
|
||||
if (href_list["link"])
|
||||
find_sensors()
|
||||
return TOPIC_REFRESH
|
||||
|
||||
if(sensors)
|
||||
if (href_list["range"])
|
||||
var/nrange = input("Set new sensors range", "Sensor range", sensors.range) as num|null
|
||||
if(!CanInteract(user,state))
|
||||
return TOPIC_NOACTION
|
||||
if (nrange)
|
||||
sensors.set_range(CLAMP(nrange, 1, world.view))
|
||||
return TOPIC_REFRESH
|
||||
if (href_list["toggle"])
|
||||
sensors.toggle()
|
||||
return TOPIC_REFRESH
|
||||
|
||||
if (href_list["scan"])
|
||||
var/obj/effect/overmap/O = locate(href_list["scan"])
|
||||
if(istype(O) && !QDELETED(O) && (O in view(7,linked)))
|
||||
playsound(loc, "sound/machines/dotprinter.ogg", 30, 1)
|
||||
new/obj/item/weapon/paper/(get_turf(src), O.get_scan_data(user), "paper (Sensor Scan - [O])")
|
||||
return TOPIC_HANDLED
|
||||
|
||||
/obj/machinery/computer/ship/sensors/process()
|
||||
..()
|
||||
if(!linked)
|
||||
return
|
||||
if(sensors && sensors.use_power && sensors.powered())
|
||||
var/sensor_range = round(sensors.range*1.5) + 1
|
||||
linked.set_light(sensor_range + 0.5, 4)
|
||||
else
|
||||
linked.set_light(0)
|
||||
|
||||
/obj/machinery/shipsensors
|
||||
name = "sensors suite"
|
||||
desc = "Long range gravity scanner with various other sensors, used to detect irregularities in surrounding space. Can only run in vacuum to protect delicate quantum BS elements."
|
||||
icon = 'icons/obj/stationobjs.dmi'
|
||||
icon_state = "sensors"
|
||||
anchored = 1
|
||||
var/max_health = 200
|
||||
var/health = 200
|
||||
var/critical_heat = 50 // sparks and takes damage when active & above this heat
|
||||
var/heat_reduction = 1.5 // mitigates this much heat per tick
|
||||
var/heat = 0
|
||||
var/range = 1
|
||||
idle_power_usage = 5000
|
||||
|
||||
/obj/machinery/shipsensors/attackby(obj/item/weapon/W, mob/user)
|
||||
var/damage = max_health - health
|
||||
if(damage && istype(W, /obj/item/weapon/weldingtool))
|
||||
|
||||
var/obj/item/weapon/weldingtool/WT = W
|
||||
|
||||
if(!WT.isOn())
|
||||
return
|
||||
|
||||
if(WT.remove_fuel(0,user))
|
||||
to_chat(user, "<span class='notice'>You start repairing the damage to [src].</span>")
|
||||
playsound(src, 'sound/items/Welder.ogg', 100, 1)
|
||||
if(do_after(user, max(5, damage / 5), src) && WT && WT.isOn())
|
||||
to_chat(user, "<span class='notice'>You finish repairing the damage to [src].</span>")
|
||||
take_damage(-damage)
|
||||
else
|
||||
to_chat(user, "<span class='notice'>You need more welding fuel to complete this task.</span>")
|
||||
return
|
||||
return
|
||||
..()
|
||||
|
||||
/obj/machinery/shipsensors/proc/in_vacuum()
|
||||
var/turf/T=get_turf(src)
|
||||
if(istype(T))
|
||||
var/datum/gas_mixture/environment = T.return_air()
|
||||
if(environment && environment.return_pressure() > MINIMUM_PRESSURE_DIFFERENCE_TO_SUSPEND)
|
||||
return 0
|
||||
return 1
|
||||
|
||||
/obj/machinery/shipsensors/update_icon()
|
||||
if(use_power)
|
||||
icon_state = "sensors"
|
||||
else
|
||||
icon_state = "sensors_off"
|
||||
..()
|
||||
|
||||
/obj/machinery/shipsensors/examine(mob/user)
|
||||
. = ..()
|
||||
if(health <= 0)
|
||||
to_chat(user, "\The [src] is wrecked.")
|
||||
else if(health < max_health * 0.25)
|
||||
to_chat(user, "<span class='danger'>\The [src] looks like it's about to break!</span>")
|
||||
else if(health < max_health * 0.5)
|
||||
to_chat(user, "<span class='danger'>\The [src] looks seriously damaged!</span>")
|
||||
else if(health < max_health * 0.75)
|
||||
to_chat(user, "\The [src] shows signs of damage!")
|
||||
|
||||
/obj/machinery/shipsensors/bullet_act(var/obj/item/projectile/Proj)
|
||||
take_damage(Proj.get_structure_damage())
|
||||
..()
|
||||
|
||||
/obj/machinery/shipsensors/proc/toggle()
|
||||
if(!use_power && (health == 0 || !in_vacuum()))
|
||||
return // No turning on if broken or misplaced.
|
||||
if(!use_power) //need some juice to kickstart
|
||||
use_power_oneoff(idle_power_usage*5)
|
||||
update_use_power(!use_power)
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/shipsensors/process()
|
||||
if(use_power) //can't run in non-vacuum
|
||||
if(!in_vacuum())
|
||||
toggle()
|
||||
if(heat > critical_heat)
|
||||
src.visible_message("<span class='danger'>\The [src] violently spews out sparks!</span>")
|
||||
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
|
||||
s.set_up(3, 1, src)
|
||||
s.start()
|
||||
|
||||
take_damage(rand(10,50))
|
||||
toggle()
|
||||
heat += idle_power_usage/15000
|
||||
|
||||
if (heat > 0)
|
||||
heat = max(0, heat - heat_reduction)
|
||||
|
||||
/obj/machinery/shipsensors/power_change()
|
||||
. = ..()
|
||||
if(use_power && !powered())
|
||||
toggle()
|
||||
|
||||
/obj/machinery/shipsensors/proc/set_range(nrange)
|
||||
range = nrange
|
||||
change_power_consumption(1500 * (range**2), USE_POWER_IDLE) //Exponential increase, also affects speed of overheating
|
||||
|
||||
/obj/machinery/shipsensors/emp_act(severity)
|
||||
if(!use_power)
|
||||
return
|
||||
take_damage(20/severity)
|
||||
toggle()
|
||||
|
||||
/obj/machinery/shipsensors/take_damage(value)
|
||||
health = min(max(health - value, 0),max_health)
|
||||
if(use_power && health == 0)
|
||||
toggle()
|
||||
|
||||
/obj/machinery/shipsensors/weak
|
||||
heat_reduction = 0.2
|
||||
desc = "Miniturized gravity scanner with various other sensors, used to detect irregularities in surrounding space. Can only run in vacuum to protect delicate quantum BS elements."
|
||||
99
code/modules/overmap/ships/computers/ship.dm
Normal file
99
code/modules/overmap/ships/computers/ship.dm
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
While these computers can be placed anywhere, they will only function if placed on either a non-space, non-shuttle turf
|
||||
with an /obj/effect/overmap/visitable/ship present elsewhere on that z level, or else placed in a shuttle area with an /obj/effect/overmap/visitable/ship
|
||||
somewhere on that shuttle. Subtypes of these can be then used to perform ship overmap movement functions.
|
||||
*/
|
||||
/obj/machinery/computer/ship
|
||||
var/obj/effect/overmap/visitable/ship/linked
|
||||
var/list/viewers // Weakrefs to mobs in direct-view mode.
|
||||
var/extra_view = 0 // how much the view is increased by when the mob is in overmap mode.
|
||||
|
||||
// A late init operation called in SSshuttles, used to attach the thing to the right ship.
|
||||
/obj/machinery/computer/ship/proc/attempt_hook_up(obj/effect/overmap/visitable/ship/sector)
|
||||
if(!istype(sector))
|
||||
return
|
||||
if(sector.check_ownership(src))
|
||||
linked = sector
|
||||
return 1
|
||||
|
||||
/obj/machinery/computer/ship/proc/sync_linked()
|
||||
var/obj/effect/overmap/visitable/ship/sector = map_sectors["[z]"]
|
||||
if(!sector)
|
||||
return
|
||||
return attempt_hook_up_recursive(sector)
|
||||
|
||||
/obj/machinery/computer/ship/proc/attempt_hook_up_recursive(obj/effect/overmap/visitable/ship/sector)
|
||||
if(attempt_hook_up(sector))
|
||||
return sector
|
||||
for(var/obj/effect/overmap/visitable/ship/candidate in sector)
|
||||
if((. = .(candidate)))
|
||||
return
|
||||
|
||||
/obj/machinery/computer/ship/proc/display_reconnect_dialog(var/mob/user, var/flavor)
|
||||
var/datum/browser/popup = new (user, "[src]", "[src]")
|
||||
popup.set_content("<center><strong><font color = 'red'>Error</strong></font><br>Unable to connect to [flavor].<br><a href='?src=\ref[src];sync=1'>Reconnect</a></center>")
|
||||
popup.open()
|
||||
|
||||
// In computer_shims for now - we had to define it.
|
||||
// /obj/machinery/computer/ship/interface_interact(var/mob/user)
|
||||
// ui_interact(user)
|
||||
// return TRUE
|
||||
|
||||
/obj/machinery/computer/ship/OnTopic(var/mob/user, var/list/href_list)
|
||||
if(..())
|
||||
return TOPIC_HANDLED
|
||||
if(href_list["sync"])
|
||||
sync_linked()
|
||||
return TOPIC_REFRESH
|
||||
if(href_list["close"])
|
||||
unlook(user)
|
||||
user.unset_machine()
|
||||
return TOPIC_HANDLED
|
||||
return TOPIC_NOACTION
|
||||
|
||||
// Management of mob view displacement. look to shift view to the ship on the overmap; unlook to shift back.
|
||||
|
||||
/obj/machinery/computer/ship/proc/look(var/mob/user)
|
||||
if(linked)
|
||||
user.reset_view(linked)
|
||||
if(user.client)
|
||||
user.client.view = world.view + extra_view
|
||||
GLOB.moved_event.register(user, src, /obj/machinery/computer/ship/proc/unlook)
|
||||
// TODO GLOB.stat_set_event.register(user, src, /obj/machinery/computer/ship/proc/unlook)
|
||||
LAZYDISTINCTADD(viewers, weakref(user))
|
||||
|
||||
/obj/machinery/computer/ship/proc/unlook(var/mob/user)
|
||||
user.reset_view()
|
||||
if(user.client)
|
||||
user.client.view = world.view
|
||||
GLOB.moved_event.unregister(user, src, /obj/machinery/computer/ship/proc/unlook)
|
||||
// TODO GLOB.stat_set_event.unregister(user, src, /obj/machinery/computer/ship/proc/unlook)
|
||||
LAZYREMOVE(viewers, weakref(user))
|
||||
|
||||
/obj/machinery/computer/ship/proc/viewing_overmap(mob/user)
|
||||
return (weakref(user) in viewers)
|
||||
|
||||
/obj/machinery/computer/ship/CouldNotUseTopic(mob/user)
|
||||
. = ..()
|
||||
unlook(user)
|
||||
|
||||
/obj/machinery/computer/ship/CouldUseTopic(mob/user)
|
||||
. = ..()
|
||||
if(viewing_overmap(user))
|
||||
look(user)
|
||||
|
||||
/obj/machinery/computer/ship/check_eye(var/mob/user)
|
||||
if (!get_dist(user, src) > 1 || user.blinded || !linked )
|
||||
unlook(user)
|
||||
return -1
|
||||
else
|
||||
return 0
|
||||
|
||||
/obj/machinery/computer/ship/sensors/Destroy()
|
||||
sensors = null
|
||||
if(LAZYLEN(viewers))
|
||||
for(var/weakref/W in viewers)
|
||||
var/M = W.resolve()
|
||||
if(M)
|
||||
unlook(M)
|
||||
. = ..()
|
||||
@@ -1,139 +1,45 @@
|
||||
//Shuttle controller computer for shuttles going between sectors
|
||||
/datum/shuttle/ferry/var/range = 0 //how many overmap tiles can shuttle go, for picking destinatiosn and returning.
|
||||
/obj/machinery/computer/shuttle_control/explore
|
||||
name = "exploration shuttle console"
|
||||
shuttle_tag = "Exploration"
|
||||
req_access = list()
|
||||
var/landing_type //area for shuttle ship-side
|
||||
var/obj/effect/map/destination //current destination
|
||||
var/obj/effect/map/home //current destination
|
||||
name = "general shuttle control console"
|
||||
ui_template = "shuttle_control_console_exploration.tmpl"
|
||||
|
||||
/obj/machinery/computer/shuttle_control/explore/Initialize()
|
||||
/obj/machinery/computer/shuttle_control/explore/get_ui_data(var/datum/shuttle/autodock/overmap/shuttle)
|
||||
. = ..()
|
||||
home = map_sectors["[z]"]
|
||||
shuttle_tag = "[shuttle_tag]-[z]"
|
||||
if(!shuttle_controller.shuttles[shuttle_tag])
|
||||
var/datum/shuttle/ferry/shuttle = new()
|
||||
shuttle.warmup_time = 10
|
||||
shuttle.area_station = locate(landing_type)
|
||||
shuttle.area_offsite = shuttle.area_station
|
||||
shuttle_controller.shuttles[shuttle_tag] = shuttle
|
||||
shuttle_controller.process_shuttles += shuttle
|
||||
testing("Exploration shuttle '[shuttle_tag]' at z-level [z] successfully added.")
|
||||
if(istype(shuttle))
|
||||
var/total_gas = 0
|
||||
for(var/obj/structure/fuel_port/FP in shuttle.fuel_ports) //loop through fuel ports
|
||||
var/obj/item/weapon/tank/fuel_tank = locate() in FP
|
||||
if(fuel_tank)
|
||||
total_gas += fuel_tank.air_contents.total_moles
|
||||
|
||||
//Sets destination to new sector. Can be null.
|
||||
/obj/machinery/computer/shuttle_control/explore/proc/update_destination(var/obj/effect/map/D)
|
||||
destination = D
|
||||
if(destination && shuttle_controller.shuttles[shuttle_tag])
|
||||
var/datum/shuttle/ferry/shuttle = shuttle_controller.shuttles[shuttle_tag]
|
||||
shuttle.area_offsite = destination.shuttle_landing
|
||||
testing("Shuttle controller [shuttle_tag] now sends shuttle to [destination]")
|
||||
shuttle_controller.shuttles[shuttle_tag] = shuttle
|
||||
var/fuel_span = "good"
|
||||
if(total_gas < shuttle.fuel_consumption * 2)
|
||||
fuel_span = "bad"
|
||||
|
||||
//Gets all sectors with landing zones in shuttle's range
|
||||
/obj/machinery/computer/shuttle_control/explore/proc/get_possible_destinations()
|
||||
var/list/res = list()
|
||||
var/datum/shuttle/ferry/shuttle = shuttle_controller.shuttles[shuttle_tag]
|
||||
for (var/obj/effect/map/S in orange(shuttle.range, home))
|
||||
if(S.shuttle_landing)
|
||||
res += S
|
||||
return res
|
||||
. += list(
|
||||
"destination_name" = shuttle.get_destination_name(),
|
||||
"can_pick" = shuttle.moving_status == SHUTTLE_IDLE,
|
||||
"fuel_usage" = shuttle.fuel_consumption * 100,
|
||||
"remaining_fuel" = round(total_gas, 0.01) * 100,
|
||||
"fuel_span" = fuel_span
|
||||
)
|
||||
|
||||
//Checks if current destination is still reachable
|
||||
/obj/machinery/computer/shuttle_control/explore/proc/check_destination()
|
||||
var/datum/shuttle/ferry/shuttle = shuttle_controller.shuttles[shuttle_tag]
|
||||
return shuttle && destination && get_dist(home, destination) <= shuttle.range
|
||||
/obj/machinery/computer/shuttle_control/explore/handle_topic_href(var/datum/shuttle/autodock/overmap/shuttle, var/list/href_list)
|
||||
if(ismob(usr))
|
||||
var/mob/user = usr
|
||||
shuttle.operator_skill = user.get_skill_value(/datum/skill/pilot)
|
||||
|
||||
/obj/machinery/computer/shuttle_control/explore/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
var/data[0]
|
||||
var/datum/shuttle/ferry/shuttle = shuttle_controller.shuttles[shuttle_tag]
|
||||
if (!istype(shuttle))
|
||||
return
|
||||
|
||||
//If we are already there, or can't reach place anymore, reset destination
|
||||
if(!shuttle.location && !check_destination())
|
||||
destination = null
|
||||
|
||||
//check if shuttle can fly at all
|
||||
var/can_go = !isnull(destination)
|
||||
var/current_destination = destination ? destination.name : "None"
|
||||
//shuttle doesn't need destination set to return home, as long as it's in range.
|
||||
if(shuttle.location)
|
||||
current_destination = "Return"
|
||||
var/area/offsite = shuttle.area_offsite
|
||||
var/obj/effect/map/cur_loc = map_sectors["[offsite.z]"]
|
||||
can_go = (get_dist(home,cur_loc) <= shuttle.range)
|
||||
|
||||
//disable picking locations if there are none, or shuttle is already off-site
|
||||
var/list/possible_d = get_possible_destinations()
|
||||
var/can_pick = !shuttle.location && possible_d.len
|
||||
|
||||
var/shuttle_state
|
||||
switch(shuttle.moving_status)
|
||||
if(SHUTTLE_IDLE) shuttle_state = "idle"
|
||||
if(SHUTTLE_WARMUP) shuttle_state = "warmup"
|
||||
if(SHUTTLE_INTRANSIT) shuttle_state = "in_transit"
|
||||
|
||||
var/shuttle_status
|
||||
switch (shuttle.process_state)
|
||||
if(IDLE_STATE)
|
||||
if (shuttle.in_use)
|
||||
shuttle_status = "Busy."
|
||||
else if (!shuttle.location)
|
||||
shuttle_status = "Standing-by at station."
|
||||
else
|
||||
shuttle_status = "Standing-by at offsite location."
|
||||
if(WAIT_LAUNCH, FORCE_LAUNCH)
|
||||
shuttle_status = "Shuttle has received command and will depart shortly."
|
||||
if(WAIT_ARRIVE)
|
||||
shuttle_status = "Proceeding to destination."
|
||||
if(WAIT_FINISH)
|
||||
shuttle_status = "Arriving at destination now."
|
||||
|
||||
data = list(
|
||||
"destination_name" = current_destination,
|
||||
"can_pick" = can_pick,
|
||||
"shuttle_status" = shuttle_status,
|
||||
"shuttle_state" = shuttle_state,
|
||||
"has_docking" = shuttle.docking_controller? 1 : 0,
|
||||
"docking_status" = shuttle.docking_controller? shuttle.docking_controller.get_docking_status() : null,
|
||||
"docking_override" = shuttle.docking_controller? shuttle.docking_controller.override_enabled : null,
|
||||
"can_launch" = can_go && shuttle.can_launch(),
|
||||
"can_cancel" = can_go && shuttle.can_cancel(),
|
||||
"can_force" = can_go && shuttle.can_force(),
|
||||
)
|
||||
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
|
||||
if (!ui)
|
||||
ui = new(user, src, ui_key, "shuttle_control_console_exploration.tmpl", "[shuttle_tag] Shuttle Control", 470, 310)
|
||||
ui.set_initial_data(data)
|
||||
ui.open()
|
||||
ui.set_auto_update(1)
|
||||
|
||||
/obj/machinery/computer/shuttle_control/explore/Topic(href, href_list)
|
||||
if(..())
|
||||
return 1
|
||||
|
||||
usr.set_machine(src)
|
||||
src.add_fingerprint(usr)
|
||||
|
||||
var/datum/shuttle/ferry/shuttle = shuttle_controller.shuttles[shuttle_tag]
|
||||
if (!istype(shuttle))
|
||||
if((. = ..()) != null)
|
||||
return
|
||||
|
||||
if(href_list["pick"])
|
||||
var/obj/effect/map/self = map_sectors["[z]"]
|
||||
if(self)
|
||||
var/list/possible_d = get_possible_destinations()
|
||||
var/obj/effect/map/D
|
||||
if(possible_d.len)
|
||||
D = input("Choose shuttle destination", "Shuttle Destination") as null|anything in possible_d
|
||||
update_destination(D)
|
||||
|
||||
if(href_list["move"])
|
||||
shuttle.launch(src)
|
||||
if(href_list["force"])
|
||||
shuttle.force_launch(src)
|
||||
else if(href_list["cancel"])
|
||||
shuttle.cancel_launch(src)
|
||||
var/list/possible_d = shuttle.get_possible_destinations()
|
||||
var/D
|
||||
if(possible_d.len)
|
||||
D = input("Choose shuttle destination", "Shuttle Destination") as null|anything in possible_d
|
||||
else
|
||||
to_chat(usr,"<span class='warning'>No valid landing sites in range.</span>")
|
||||
possible_d = shuttle.get_possible_destinations()
|
||||
if(CanInteract(usr, global.default_state) && (D in possible_d))
|
||||
shuttle.set_destination(possible_d[D])
|
||||
return TOPIC_REFRESH
|
||||
|
||||
Reference in New Issue
Block a user