Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions code/__defines/dcs/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -833,18 +833,6 @@
/// COMSIG used to get messages where they need to go
#define COMSIG_VISIBLE_MESSAGE "visible_message"

// Weaver Component
///from /mob/living/proc/check_silk_amount()
#define COMSIG_CHECK_SILK_AMOUNT "check_silk_amount"
///from /mob/living/proc/weave_structure()
#define COMSIG_WEAVE_STRUCTURE "weave_structure"
///from /mob/living/proc/toggle_silk_production()
#define COMSIG_TOGGLE_SILK_PRODUCTION "toggle_silk_production"
///from /mob/living/proc/weave_item()
#define COMSIG_WEAVE_ITEM "weave_item"
///from /mob/living/proc/set_silk_color()
#define COMSIG_SET_SILK_COLOR "set_silk_color"

// Gargoyle Component
///from /mob/living/carbon/human/proc/gargoyle_transformation()
#define COMSIG_GARGOYLE_TRANSFORMATION "gargoyle_transformation"
Expand Down
8 changes: 8 additions & 0 deletions code/_helpers/global_lists_vr.dm
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,18 @@ GLOBAL_LIST_EMPTY(existing_solargrubs)
continue //A prototype or something
GLOB.weavable_items[instance.title] = instance

paths = subtypesof(/datum/weaver_recipe)
for(var/path in paths)
var/datum/weaver_recipe/instance = new path()
if(!instance.title)
continue //A prototype or something
GLOB.all_weavable[instance.title] = instance

return 1 // Hooks must return 1

GLOBAL_LIST_EMPTY(weavable_structures)
GLOBAL_LIST_EMPTY(weavable_items)
GLOBAL_LIST_EMPTY(all_weavable)


var/global/list/xenobio_metal_materials_normal = list(
Expand Down
152 changes: 119 additions & 33 deletions code/datums/components/traits/weaver.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
return COMPONENT_INCOMPATIBLE

owner = parent
add_verb(owner, /mob/living/proc/check_silk_amount)
add_verb(owner, /mob/living/proc/toggle_silk_production)
add_verb(owner, /mob/living/proc/weave_structure)
add_verb(owner, /mob/living/proc/weave_item)
add_verb(owner, /mob/living/proc/set_silk_color)
add_verb(owner, /mob/living/proc/weaver_control_panel)
if(ishuman(parent))
add_verb(owner, /mob/living/carbon/human/proc/enter_cocoon)

//Processing
RegisterSignal(owner, COMSIG_LIVING_LIFE, PROC_REF(process_component))
<<<<<<< HEAD

Check failure on line 26 in code/datums/components/traits/weaver.dm

View workflow job for this annotation

GitHub Actions / DreamChecker

got '<<', expected one of: ';', '//!', '/*!', '/'

//When procs are used
RegisterSignal(owner, COMSIG_CHECK_SILK_AMOUNT, PROC_REF(check_silk_amount))
Expand All @@ -33,23 +32,18 @@
RegisterSignal(owner, COMSIG_WEAVE_ITEM, PROC_REF(weave_item))
RegisterSignal(owner, COMSIG_SET_SILK_COLOR, PROC_REF(set_silk_color))

=======
>>>>>>> 4778981111 ([MIRROR] Makes weaver TGUI (#11768))
/datum/component/weaver/proc/process_component()
if (QDELETED(parent))
return
process_weaver_silk()

/datum/component/weaver/Destroy(force = FALSE)
UnregisterSignal(owner, COMSIG_LIVING_LIFE) //IF we registered a signal, we need to unregister it.
UnregisterSignal(owner, COMSIG_CHECK_SILK_AMOUNT)
UnregisterSignal(owner, COMSIG_WEAVE_STRUCTURE)
UnregisterSignal(owner, COMSIG_TOGGLE_SILK_PRODUCTION)
UnregisterSignal(owner, COMSIG_WEAVE_ITEM)
UnregisterSignal(owner, COMSIG_SET_SILK_COLOR)
remove_verb(owner, /mob/living/proc/check_silk_amount)
remove_verb(owner, /mob/living/proc/toggle_silk_production)
remove_verb(owner, /mob/living/proc/weave_structure)
remove_verb(owner, /mob/living/proc/weave_item)
remove_verb(owner, /mob/living/proc/set_silk_color)
remove_verb(owner, /mob/living/proc/weaver_control_panel)
if(ishuman(parent))
remove_verb(owner, /mob/living/carbon/human/proc/enter_cocoon)
owner = null
. = ..()

Expand All @@ -58,6 +52,7 @@
silk_reserve = min(silk_reserve + silk_generation_amount, silk_max_reserve)
owner.adjust_nutrition(-(nutrtion_per_silk*silk_generation_amount))

<<<<<<< HEAD

/mob/living/proc/check_silk_amount()
set name = "Check Silk Amount"
Expand Down Expand Up @@ -139,24 +134,112 @@
set category = "Abilities.Weaver"
SEND_SIGNAL(src, COMSIG_WEAVE_ITEM)

=======
>>>>>>> 4778981111 ([MIRROR] Makes weaver TGUI (#11768))
/datum/component/weaver/proc/weave_item()
var/choice
var/datum/weaver_recipe/item/desired_result
var/finalized = "No"

while(finalized == "No" && owner.client)
choice = tgui_input_list(owner,"What would you like to weave?", "Weave Choice", GLOB.weavable_items)
desired_result = GLOB.weavable_items[choice]
choice = tgui_input_list(owner,"What would you like to weave?", "Weave Choice", GLOB.all_weavable)
desired_result = GLOB.all_weavable[choice]
if(!desired_result || !istype(desired_result))
return

if(choice)
finalized = tgui_alert(owner, "Are you sure you want to weave [desired_result.title]? It will cost you [desired_result.cost] silk.","Confirmation",list("Yes","No"))

if(!desired_result || !istype(desired_result))
return
weave_check(desired_result.cost, desired_result.result_type)

if(desired_result.cost > silk_reserve)
//TGUI Weaver Panel
/datum/component/weaver/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "WeaverConfig", "Weaver Config")
ui.open()


/mob/living/proc/weaver_control_panel()
set name = "Weaver Control Panel"
set desc = "Allows you to adjust the settings of various weaver settings!"
set category = "Abilities.Weaver"

var/datum/component/weaver/weave = get_weaver_component()
if(!weave)
to_chat(src, span_warning("Only a weaver can use that!"))
return FALSE

weave.tgui_interact(src)

/mob/living/proc/get_weaver_component()
var/datum/component/weaver/weave = GetComponent(/datum/component/weaver)
if(weave)
return weave

/datum/component/weaver/tgui_data(mob/user)
var/data = list(
"silk_reserve" = silk_reserve,
"silk_max_reserve" = silk_max_reserve,
"silk_color" = silk_color,
"silk_production" = silk_production,
"savefile_selected" = correct_savefile_selected()
)

return data

/datum/component/weaver/tgui_close(mob/user)
SScharacter_setup.queue_preferences_save(user?.client?.prefs)
. = ..()

/datum/component/weaver/proc/correct_savefile_selected()
if(owner.client.prefs.default_slot == owner.mind.loaded_from_slot)
return TRUE
return FALSE

/datum/component/weaver/tgui_act(action, list/params, datum/tgui/ui, datum/tgui_state/state)
if(..())
return TRUE

switch(action)
if("new_silk_color")
var/set_new_color = tgui_color_picker(ui.user, "Select a color you wish your silk to be!", "Color Selector", silk_color)
if(!set_new_color)
return FALSE
silk_color = set_new_color
return TRUE
if("toggle_silk_production")
silk_production = !(silk_production)
to_chat(owner, span_info("You are [silk_production ? "now" : "no longer"] producing silk."))
return FALSE
if("check_silk_amount")
to_chat(owner, span_info("Your silk reserves are at [silk_reserve]/[silk_max_reserve]."))
return FALSE
/* //Unused.
if("weave_item") //The global list of items.
weave_item()
return TRUE
*/
if("weave_binding")
weave_check(50, /obj/item/clothing/suit/weaversilk_bindings)
return TRUE
if("weave_floor")
weave_check(25, /obj/effect/weaversilk/floor)
return TRUE
if("weave_wall")
weave_check(100, /obj/effect/weaversilk/wall)
return TRUE
if("weave_nest")
weave_check(100, /obj/structure/bed/double/weaversilk_nest)
return TRUE
if("weave_trap")
weave_check(250, /obj/effect/weaversilk/trap)
return TRUE
/*
* Checks to see if we can create the object
*/
/datum/component/weaver/proc/weave_check(cost, weaved_object)
if(cost > silk_reserve)
to_chat(owner, span_warning("You don't have enough silk to weave that!"))
return

Expand All @@ -168,26 +251,29 @@
to_chat(owner, span_warning("You can't weave here!"))
return

<<<<<<< HEAD
if(do_after(owner, desired_result.time, exclusive = TASK_USER_EXCLUSIVE))
if(desired_result.cost > silk_reserve)
=======
if(locate(weaved_object) in owner.loc)
to_chat(owner, span_warning("You can't create another one in the same tile here!"))
return

if(do_after(owner, ((cost/25) SECONDS), target = owner))
if(cost > silk_reserve)
>>>>>>> 4778981111 ([MIRROR] Makes weaver TGUI (#11768))
to_chat(owner, span_warning("You don't have enough silk to weave that!"))
return

if(!isturf(owner.loc))
to_chat(owner, span_warning("You can't weave here!"))
return

silk_reserve = max(silk_reserve - desired_result.cost, 0)

var/atom/O = new desired_result.result_type(owner.loc)
O.color = silk_color

/mob/living/proc/set_silk_color()
set name = "Set Silk Color"
set category = "Abilities.Weaver"
SEND_SIGNAL(src, COMSIG_SET_SILK_COLOR)
if(locate(weaved_object) in owner.loc)
to_chat(owner, span_warning("You can't create another one in the same tile!"))
return

/datum/component/weaver/proc/set_silk_color()
var/new_silk_color = tgui_color_picker(owner, "Pick a color for your woven products:","Silk Color", silk_color)
if(new_silk_color)
silk_color = new_silk_color
silk_reserve = max(silk_reserve - cost, 0)
var/atom/object = new weaved_object(owner.loc)
object.color = silk_color
return
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
has_preferences = list("silk_production" = list(TRAIT_PREF_TYPE_BOOLEAN, "Silk production on spawn", TRAIT_NO_VAREDIT_TARGET), \
"silk_color" = list(TRAIT_PREF_TYPE_COLOR, "Silk color", TRAIT_NO_VAREDIT_TARGET))
added_component_path = /datum/component/weaver
excludes = list(/datum/trait/positive/cocoon_tf)

/datum/trait/positive/weaver/apply(var/datum/species/S,var/mob/living/carbon/human/H, var/list/trait_prefs)
..()
Expand Down Expand Up @@ -243,6 +244,7 @@
cost = 1
// allowed_species = list(SPECIES_HANNER, SPECIES_CUSTOM) //So it only shows up for custom species and hanner CHOMPEDIT: It's a roleplay trait. Will things explode if more folks have it?
custom_only = FALSE
excludes = list(/datum/trait/positive/weaver)

/datum/trait/positive/cocoon_tf/apply(var/datum/species/S,var/mob/living/carbon/human/H)
..()
Expand Down
Loading
Loading