Auxiliary Base construction fixes (#56969)

* Base construction fixes
This commit is contained in:
Arkatos1
2021-02-20 22:39:17 +01:00
committed by GitHub
parent 4ab9f10884
commit 0e5c7041e2
6 changed files with 41 additions and 31 deletions
@@ -0,0 +1,152 @@
/datum/action/innate/camera_off/base_construction
name = "Log out"
///Generic construction action for base [construction consoles][/obj/machinery/computer/camera_advanced/base_construction].
/datum/action/innate/construction
icon_icon = 'icons/mob/actions/actions_construction.dmi'
///Console's eye mob
var/mob/camera/ai_eye/remote/base_construction/remote_eye
///Console itself
var/obj/machinery/computer/camera_advanced/base_construction/base_console
///Is this used to build only on the station z level?
var/only_station_z = TRUE
/datum/action/innate/construction/Activate()
if(!target)
return TRUE
remote_eye = owner.remote_control
base_console = target
///Sanity check for any construction action that relies on an RCD being in the base console
/datum/action/innate/construction/proc/check_rcd()
//The console must always have an RCD.
if(!base_console.internal_rcd)
CRASH("Base console is somehow missing an internal RCD!")
///Check a loction to see if it is inside the aux base at the station. Camera visbility checks omitted so as to not hinder construction.
/datum/action/innate/construction/proc/check_spot()
var/turf/build_target = get_turf(remote_eye)
var/area/build_area = get_area(build_target)
var/area/area_constraint = base_console.allowed_area
//If the console has no allowed_area var, then we're free to build wherever
if (!area_constraint)
return TRUE
if(!istype(build_area, area_constraint))
to_chat(owner, "<span class='warning'>You can only build within [area_constraint]!</span>")
return FALSE
if(only_station_z && !is_station_level(build_target.z))
to_chat(owner, "<span class='warning'>[area_constraint] has launched and can no longer be modified.</span>")
return FALSE
return TRUE
/datum/action/innate/construction/build
name = "Build"
button_icon_state = "build"
/datum/action/innate/construction/build/Activate()
if(..())
return
if(!check_spot())
return
var/turf/target_turf = get_turf(remote_eye)
var/atom/rcd_target = target_turf
//Find airlocks and other shite
for(var/obj/S in target_turf)
if(LAZYLEN(S.rcd_vals(owner,base_console.internal_rcd)))
rcd_target = S //If we don't break out of this loop we'll get the last placed thing
owner.changeNext_move(CLICK_CD_RANGE)
check_rcd()
base_console.internal_rcd.pre_attack(rcd_target, owner, TRUE) //Activate the RCD and force it to work remotely!
playsound(target_turf, 'sound/items/deconstruct.ogg', 60, TRUE)
/datum/action/innate/construction/switch_mode
name = "Switch Mode"
button_icon_state = "builder_mode"
/datum/action/innate/construction/switch_mode/Activate()
if(..())
return
var/list/buildlist = list("Walls and Floors" = RCD_FLOORWALL, "Airlocks" = RCD_AIRLOCK, "Deconstruction" = RCD_DECONSTRUCT, "Windows and Grilles" = RCD_WINDOWGRILLE)
var/buildmode = input(owner, "Set construction mode.", "Base Console", null) in buildlist
check_rcd()
base_console.internal_rcd.construction_mode = buildlist[buildmode]
to_chat(owner, "Build mode is now [buildmode].")
/datum/action/innate/construction/airlock_type
name = "Select Airlock Type"
button_icon_state = "airlock_select"
/datum/action/innate/construction/airlock_type/Activate()
if(..())
return
check_rcd()
base_console.internal_rcd.change_airlock_setting(owner, remote_eye)
/datum/action/innate/construction/window_type
name = "Select Window Glass"
button_icon_state = "window_select"
/datum/action/innate/construction/window_type/Activate()
if(..())
return
check_rcd()
base_console.internal_rcd.toggle_window_glass(owner)
///Generic action used with base construction consoles to build anything that can't be built with an RCD
/datum/action/innate/construction/place_structure
name = "Place Generic Structure"
var/obj/structure_path
var/structure_name
var/place_sound
/datum/action/innate/construction/place_structure/Activate()
if(..())
return
var/turf/place_turf = get_turf(remote_eye)
if(!base_console.structures[structure_name])
to_chat(owner, "<span class='warning'>[base_console] is out of [structure_name]!</span>")
return
if(!check_spot())
return
//Can't place inside a closed turf
if(place_turf.density)
to_chat(owner, "<span class='warning'>[structure_name] may only be placed on a floor.</span>")
return
//Can't place two dense objects inside eachother
if(initial(structure_path.density) && place_turf.is_blocked_turf())
to_chat(owner, "<span class='warning'>Location is obstructed by something. Please clear the location and try again.</span>")
return
var/obj/placed_structure = new structure_path(place_turf)
base_console.structures[structure_name]--
var/remaining = base_console.structures[structure_name]
playsound(place_turf, place_sound, 50, TRUE)
after_place(placed_structure, remaining)
///Proc to handle additional behavior after placing an object
/datum/action/innate/construction/place_structure/proc/after_place()
return
/datum/action/innate/construction/place_structure/fan
name = "Place Tiny Fan"
button_icon_state = "build_fan"
structure_name = "fans"
structure_path = /obj/structure/fans/tiny
place_sound = 'sound/machines/click.ogg'
/datum/action/innate/construction/place_structure/turret/after_place(obj/placed_structure, remaining)
to_chat(owner, "<span class='notice'>Tiny fan placed. [remaining] fans remaining.</span>")
/datum/action/innate/construction/place_structure/turret
name = "Install Plasma Anti-Wildlife Turret"
button_icon_state = "build_turret"
structure_name = "turrets"
structure_path = /obj/machinery/porta_turret/aux_base
place_sound = 'sound/items/drill_use.ogg'
/datum/action/innate/construction/place_structure/turret/after_place(obj/placed_structure, remaining)
var/obj/machinery/computer/auxiliary_base/turret_controller = locate() in get_area(placed_structure)
if(!turret_controller)
to_chat(owner, "<span class='notice'><b>Warning:</b> Aux base controller not found. Turrets might not work properly.</span>")
return
turret_controller.turrets += placed_structure
to_chat(owner, "<span class='notice'>You've constructed an additional turret. [remaining] turrets remaining.</span>")
@@ -0,0 +1,134 @@
/**
* Camera console used to control a base building drone
*
* Using this console will put the user in control of a [base building drone][/mob/camera/ai_eye/remote/base_construction].
* The drone will appear somewhere within the allowed_area var, or if no area is specified, at the location of the console.area
* Upon interacting, the user will be granted a set of base building actions that will generally be carried out at the drone's location.
* To create a new base builder system, this class should be the only thing that needs to be subtyped.
*
*/
/obj/machinery/computer/camera_advanced/base_construction
name = "generic base construction console"
desc = "An industrial computer integrated with a camera-assisted rapid construction drone."
networks = list("ss13")
circuit = /obj/item/circuitboard/computer/base_construction
off_action = new/datum/action/innate/camera_off/base_construction
jump_action = null
icon_screen = "mining"
icon_keyboard = "rd_key"
light_color = LIGHT_COLOR_PINK
///Area that the eyeobj will be constrained to. If null, eyeobj will be able to build and move anywhere.
var/area/allowed_area
///Assoc. list ("structure_name" : count) that keeps track of the number of special structures that can't be built with an RCD, for example, tiny fans or turrets.
var/list/structures = list()
///Internal RCD. Some construction actions rely on having this.
var/obj/item/construction/rcd/internal/internal_rcd
///Actions given to the console user to help with base building. Actions are generally carried out at the location of the eyeobj
var/list/datum/action/innate/construction_actions
/obj/machinery/computer/camera_advanced/base_construction/Initialize(mapload)
. = ..()
//Populate the actions list with the different action objects that will be granted to console users
populate_actions_list()
//Map spawned consoles will automatically restock their materials
if(mapload)
restock_materials()
/**
* Fill the construction_actios list with actions
*
* Instantiate each action object that we'll be giving to users of
* this console, and put it in the construction actions list.
*/
/obj/machinery/computer/camera_advanced/base_construction/proc/populate_actions_list()
construction_actions = list()
/**
* Reload materials used by the console
*
* Restocks any materials used by the base construction console.
* This might mean refilling the internal RCD (should it be initialized), or
* giving the structures list default values.
*/
/obj/machinery/computer/camera_advanced/base_construction/proc/restock_materials()
return
///Find a spawn location for the eyeobj. If no allowed_area is defined, spawn ontop of the console.
/obj/machinery/computer/camera_advanced/base_construction/proc/find_spawn_spot()
if (allowed_area)
return pick(get_area_turfs(allowed_area))
return get_turf(src)
/obj/machinery/computer/camera_advanced/base_construction/CreateEye()
var/turf/spawn_spot = find_spawn_spot()
if (!spawn_spot)
return FALSE
eyeobj = new /mob/camera/ai_eye/remote/base_construction(spawn_spot, src)
eyeobj.origin = src
return TRUE
/obj/machinery/computer/camera_advanced/base_construction/attackby(obj/item/W, mob/user, params)
//If we have an internal RCD, we can refill it by slapping the console with some materials
if(internal_rcd && (istype(W, /obj/item/rcd_ammo) || istype(W, /obj/item/stack/sheet)))
internal_rcd.attackby(W, user, params)
else
return ..()
/obj/machinery/computer/camera_advanced/base_construction/Destroy()
qdel(internal_rcd)
return ..()
///Go through every action object in the construction_action list (which should be fully initialized by now) and grant it to the user.
/obj/machinery/computer/camera_advanced/base_construction/GrantActions(mob/living/user)
..()
for (var/datum/action/innate/construction_action in construction_actions)
if(construction_action)
construction_action.target = src
construction_action.Grant(user)
actions += construction_action
//When the eye is in use, make it visible to players so they know when someone is building.
eyeobj.invisibility = 0
/obj/machinery/computer/camera_advanced/base_construction/remove_eye_control(mob/living/user)
..()
//Hide the eye when not in use.
eyeobj.invisibility = INVISIBILITY_MAXIMUM
/**
* A mob used by [/obj/machinery/computer/camera_advanced/base_construction] for building in specific areas.
*
* Controlled by a user who is using a base construction console.
* The user will be granted a set of building actions by the console, and the actions will be carried out by this mob.
* The mob is constrained to a given area defined by the base construction console.
*
*/
/mob/camera/ai_eye/remote/base_construction
name = "construction holo-drone"
//Allows any curious crew to watch the base after it leaves. (This is safe as the base cannot be modified once it leaves)
move_on_shuttle = TRUE
icon = 'icons/obj/mining.dmi'
icon_state = "construction_drone"
///Reference to the camera console controlling this drone
var/obj/machinery/computer/camera_advanced/base_construction/linked_console
/mob/camera/ai_eye/remote/base_construction/Initialize(mapload, obj/machinery/computer/camera_advanced/console_link)
linked_console = console_link
return ..()
/mob/camera/ai_eye/remote/base_construction/setLoc(t)
var/area/curr_area = get_area(t)
//Only move if we're in the allowed area. If no allowed area is defined, then we're free to move wherever.
if(!linked_console.allowed_area || istype(curr_area, linked_console.allowed_area))
return ..()
/mob/camera/ai_eye/remote/base_construction/relaymove(mob/living/user, direction)
//This camera eye is visible, and as such needs to keep it's dir updated
dir = direction
return ..()
///[Base console's][/obj/machinery/computer/camera_advanced/base_construction] internal RCD. Has a large material capacity and a fast buildspeed.
/obj/item/construction/rcd/internal
name = "internal RCD"
max_matter = 600
no_ammo_message = "<span class='warning'>Internal matter exhausted. Please add additional materials.</span>"
delay_mod = 0.5
@@ -0,0 +1,36 @@
///base consturctino console subtype for the mining aux base
/obj/machinery/computer/camera_advanced/base_construction/aux
name = "aux base construction console"
circuit = /obj/item/circuitboard/computer/base_construction/aux
structures = list("fans" = 0, "turrets" = 0)
allowed_area = /area/shuttle/auxiliary_base
/obj/machinery/computer/camera_advanced/base_construction/aux/Initialize(mapload)
internal_rcd = new(src)
return ..()
/obj/machinery/computer/camera_advanced/base_construction/aux/restock_materials()
internal_rcd.matter = internal_rcd.max_matter
structures["fans"] = 4
structures["turrets"] = 4
/obj/machinery/computer/camera_advanced/base_construction/aux/populate_actions_list()
construction_actions = list()
construction_actions.Add(new /datum/action/innate/construction/switch_mode())//Action for switching the RCD's build modes
construction_actions.Add(new /datum/action/innate/construction/build()) //Action for using the RCD
construction_actions.Add(new /datum/action/innate/construction/airlock_type()) //Action for setting the airlock type
construction_actions.Add(new /datum/action/innate/construction/window_type()) //Action for setting the window type
construction_actions.Add(new /datum/action/innate/construction/place_structure/fan()) //Action for spawning fans
construction_actions.Add(new /datum/action/innate/construction/place_structure/turret()) //Action for spawning turrets
/obj/machinery/computer/camera_advanced/base_construction/aux/find_spawn_spot()
//Aux base controller. Where the eyeobj will spawn.
var/obj/machinery/computer/auxiliary_base/aux_controller
for(var/obj/machinery/computer/auxiliary_base/potential_aux_console in GLOB.machines)
if(istype(get_area(potential_aux_console), allowed_area))
aux_controller = potential_aux_console
break
if(!aux_controller)
say("ERROR: Unable to locate auxiliary base controller!")
return null
return aux_controller
@@ -0,0 +1,16 @@
///admin-only base consturctino console subtype for building anywhere!
/obj/machinery/computer/camera_advanced/base_construction/centcom
name = "centcom base construction console"
circuit = /obj/item/circuitboard/computer/base_construction/centcom
/obj/machinery/computer/camera_advanced/base_construction/centcom/Initialize(mapload)
internal_rcd = new(src)
return ..()
/obj/machinery/computer/camera_advanced/base_construction/centcom/restock_materials()
internal_rcd.matter = internal_rcd.max_matter
/obj/machinery/computer/camera_advanced/base_construction/centcom/populate_actions_list()
construction_actions = list()
construction_actions.Add(new /datum/action/innate/construction/switch_mode())//Action for switching the RCD's build modes
construction_actions.Add(new /datum/action/innate/construction/build()) //Action for using the RCD