diff --git a/code/datums/components/deployable.dm b/code/datums/components/deployable.dm index e2c6b84703e..14fc6747bd6 100644 --- a/code/datums/components/deployable.dm +++ b/code/datums/components/deployable.dm @@ -5,7 +5,8 @@ * If attaching this to something: * Set deploy_time to a number in seconds for the deploy delay * Set thing_to_be_deployed to an obj path for the thing that gets spawned - * Lastly, set delete_on_use to TRUE or FALSE if you want the object you're deploying with to get deleted when used + * Multiple deployments and deployments work together to allow a thing to be placed down several times. If multiple deployments is false then don't worry about deployments + * Direction setting true means the object spawned will face the direction of the person who deployed it, false goes to the default direction */ /datum/component/deployable @@ -13,23 +14,29 @@ var/deploy_time /// The object that gets spawned if deployed successfully var/obj/thing_to_be_deployed - /// If the item used to deploy gets deleted on use or not - var/delete_on_use + /// Can the parent be deployed multiple times + var/multiple_deployments + /// How many times we can deploy the parent, if multiple deployments is set to true and this gets below zero, the parent will be deleted + var/deployments /// If the component adds a little bit into the parent's description var/add_description_hint + /// If the direction of the thing we place is changed upon placing + var/direction_setting /// Used in getting the name of the deployed object var/deployed_name -/datum/component/deployable/Initialize(deploy_time = 5 SECONDS, thing_to_be_deployed, delete_on_use = TRUE, add_description_hint = TRUE) +/datum/component/deployable/Initialize(deploy_time = 5 SECONDS, thing_to_be_deployed, multiple_deployments = FALSE, deployments = 1, add_description_hint = TRUE, direction_setting = TRUE) . = ..() if(!isitem(parent)) return COMPONENT_INCOMPATIBLE src.deploy_time = deploy_time src.thing_to_be_deployed = thing_to_be_deployed - src.delete_on_use = delete_on_use src.add_description_hint = add_description_hint + src.direction_setting = direction_setting + src.deployments = deployments + src.multiple_deployments = multiple_deployments if(add_description_hint) RegisterSignal(parent, COMSIG_ATOM_EXAMINE, PROC_REF(examine)) @@ -40,23 +47,23 @@ /datum/component/deployable/proc/examine(datum/source, mob/user, list/examine_list) SIGNAL_HANDLER - - examine_list += span_notice("[source.p_they()] look[source.p_s()] like [source.p_they()] can be deployed into \a [deployed_name].") + examine_list += span_notice("It can be used in hand to deploy into [((deployments > 1) && multiple_deployments) ? "[deployments]" : "a"] [deployed_name].") /datum/component/deployable/proc/on_attack_hand(datum/source, mob/user, location, direction) SIGNAL_HANDLER INVOKE_ASYNC(src, PROC_REF(deploy), source, user, location, direction) /datum/component/deployable/proc/deploy(obj/source, mob/user, location, direction) //If there's no user, location and direction are used - var/obj/deployed_object //Used for spawning the deployed object - var/turf/deploy_location //Where our deployed_object gets put - var/new_direction //What direction do we want our deployed object in - if(user) - if(!ishuman(user)) - return + // The object we are going to create + var/atom/deployed_object + // The turf our object is going to be deployed to + var/turf/deploy_location + // What direction will the deployed object be placed facing + var/new_direction + if(user) deploy_location = get_step(user, user.dir) //Gets spawn location for thing_to_be_deployed if there is a user - if(deploy_location.is_blocked_turf(TRUE)) + if(deploy_location.is_blocked_turf(TRUE, parent)) source.balloon_alert(user, "insufficient room to deploy here.") return new_direction = user.dir //Gets the direction for thing_to_be_deployed if there is a user @@ -64,16 +71,18 @@ playsound(source, 'sound/items/ratchet.ogg', 50, TRUE) if(!do_after(user, deploy_time)) return - else //If there is for some reason no user, then the location and direction are set here + else // If there is for some reason no user, then the location and direction are set here deploy_location = location new_direction = direction deployed_object = new thing_to_be_deployed(deploy_location) deployed_object.setDir(new_direction) - //Sets the integrity of the new deployed machine to that of the object it came from - deployed_object.modify_max_integrity(source.max_integrity) - deployed_object.update_icon_state() + // Sets the direction of the resulting object if the variable says to + if(direction_setting) + deployed_object.update_icon_state() - if(delete_on_use) + deployments -= 1 + + if(!multiple_deployments || deployments < 1) qdel(source) diff --git a/code/game/machinery/deployable.dm b/code/game/machinery/deployable.dm index 2dfb2f7ed32..79ec5e1861a 100644 --- a/code/game/machinery/deployable.dm +++ b/code/game/machinery/deployable.dm @@ -235,7 +235,7 @@ /obj/item/deployable_turret_folded/Initialize(mapload) . = ..() - AddComponent(/datum/component/deployable, 5 SECONDS, /obj/machinery/deployable_turret/hmg, delete_on_use = TRUE) + AddComponent(/datum/component/deployable, 5 SECONDS, /obj/machinery/deployable_turret/hmg) #undef SINGLE #undef VERTICAL diff --git a/code/modules/shuttle/spaceship_navigation_beacon.dm b/code/modules/shuttle/spaceship_navigation_beacon.dm index 4ae91af588a..d46396a0e8b 100644 --- a/code/modules/shuttle/spaceship_navigation_beacon.dm +++ b/code/modules/shuttle/spaceship_navigation_beacon.dm @@ -101,7 +101,7 @@ /obj/item/folded_navigation_gigabeacon/Initialize(mapload) . = ..() - AddComponent(/datum/component/deployable, 3 SECONDS, /obj/machinery/spaceship_navigation_beacon, delete_on_use = TRUE) + AddComponent(/datum/component/deployable, 3 SECONDS, /obj/machinery/spaceship_navigation_beacon) /obj/item/folded_navigation_gigabeacon/examine() .=..() diff --git a/modular_skyrat/modules/colony_fabricator/code/colony_fabricator.dm b/modular_skyrat/modules/colony_fabricator/code/colony_fabricator.dm index 5bb3276553f..b547d5c555e 100644 --- a/modular_skyrat/modules/colony_fabricator/code/colony_fabricator.dm +++ b/modular_skyrat/modules/colony_fabricator/code/colony_fabricator.dm @@ -90,7 +90,7 @@ /obj/item/flatpacked_machine/Initialize(mapload) . = ..() desc = initial(type_to_deploy.desc) - AddComponent(/datum/component/deployable, deploy_time, type_to_deploy, delete_on_use = TRUE) + AddComponent(/datum/component/deployable, deploy_time, type_to_deploy) give_manufacturer_examine() /// Adds the manufacturer examine element to the flatpack machine, but can be overridden in the future diff --git a/modular_skyrat/modules/mounted_machine_gun/code/mounted_machine_gun.dm b/modular_skyrat/modules/mounted_machine_gun/code/mounted_machine_gun.dm index ccabd4e05a9..a1b7b159336 100644 --- a/modular_skyrat/modules/mounted_machine_gun/code/mounted_machine_gun.dm +++ b/modular_skyrat/modules/mounted_machine_gun/code/mounted_machine_gun.dm @@ -467,4 +467,4 @@ /obj/item/mounted_machine_gun_folded/Initialize(mapload) . = ..() - AddComponent(/datum/component/deployable, deploy_time, type_to_deploy, delete_on_use = TRUE) + AddComponent(/datum/component/deployable, deploy_time, type_to_deploy)