mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +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:
@@ -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
|
||||
Reference in New Issue
Block a user