mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Merge pull request #2241 from CHOMPStationBot/upstream-merge-10694
[MIRROR] [MIRROR] Refactors utensils to use weakrefs
This commit is contained in:
@@ -11,12 +11,11 @@
|
|||||||
thrown_force_divisor = 1
|
thrown_force_divisor = 1
|
||||||
origin_tech = list(TECH_MATERIAL = 1)
|
origin_tech = list(TECH_MATERIAL = 1)
|
||||||
attack_verb = list("attacked", "stabbed", "poked")
|
attack_verb = list("attacked", "stabbed", "poked")
|
||||||
sharp = 1
|
sharp = TRUE
|
||||||
edge = 1
|
edge = TRUE
|
||||||
force_divisor = 0.1 // 6 when wielded with hardness 60 (steel)
|
force_divisor = 0.1 // 6 when wielded with hardness 60 (steel)
|
||||||
thrown_force_divisor = 0.25 // 5 when thrown with weight 20 (steel)
|
thrown_force_divisor = 0.25 // 5 when thrown with weight 20 (steel)
|
||||||
var/loaded //Descriptive string for currently loaded food object.
|
var/weakref/loaded //Weakref for currently loaded food object.
|
||||||
var/scoop_food = 1
|
|
||||||
|
|
||||||
/obj/item/weapon/material/kitchen/utensil/New()
|
/obj/item/weapon/material/kitchen/utensil/New()
|
||||||
..()
|
..()
|
||||||
@@ -25,6 +24,15 @@
|
|||||||
create_reagents(5)
|
create_reagents(5)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
/obj/item/weapon/material/kitchen/utensil/update_icon()
|
||||||
|
. = ..()
|
||||||
|
cut_overlays()
|
||||||
|
var/obj/item/weapon/reagent_containers/food/snacks/eaten = loaded?.resolve()
|
||||||
|
if(eaten)
|
||||||
|
var/image/I = new(icon, "loadedfood")
|
||||||
|
I.color = eaten.filling_color
|
||||||
|
add_overlay(I)
|
||||||
|
|
||||||
/obj/item/weapon/material/kitchen/utensil/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob)
|
/obj/item/weapon/material/kitchen/utensil/attack(mob/living/carbon/M as mob, mob/living/carbon/user as mob)
|
||||||
if(!istype(M))
|
if(!istype(M))
|
||||||
return ..()
|
return ..()
|
||||||
@@ -37,30 +45,32 @@
|
|||||||
else
|
else
|
||||||
return ..()
|
return ..()
|
||||||
|
|
||||||
if (reagents.total_volume > 0)
|
if (loaded && reagents.total_volume > 0)
|
||||||
|
var/atom/movable/eaten = loaded?.resolve()
|
||||||
reagents.trans_to_mob(M, reagents.total_volume, CHEM_INGEST)
|
reagents.trans_to_mob(M, reagents.total_volume, CHEM_INGEST)
|
||||||
if(M == user)
|
if(eaten)
|
||||||
if(!M.can_eat(loaded))
|
if(M == user)
|
||||||
return
|
if(!M.can_eat(eaten))
|
||||||
M.visible_message("<span class='notice'>\The [user] eats some [loaded] from \the [src].</span>")
|
return
|
||||||
else
|
M.visible_message(SPAN_NOTICE("\The [user] eats some of \the [eaten] with \the [src]."))
|
||||||
user.visible_message("<span class='warning'>\The [user] begins to feed \the [M]!</span>")
|
else
|
||||||
if(!(M.can_force_feed(user, loaded) && do_mob(user, M, 5 SECONDS)))
|
user.visible_message(SPAN_WARNING("\The [user] begins to feed \the [M]!"))
|
||||||
return
|
if(!(M.can_force_feed(user, eaten) && do_mob(user, M, 5 SECONDS)))
|
||||||
M.visible_message("<span class='notice'>\The [user] feeds some [loaded] to \the [M] with \the [src].</span>")
|
return
|
||||||
playsound(src,'sound/items/eatfood.ogg', rand(10,40), 1)
|
M.visible_message(SPAN_NOTICE("\The [user] feeds some of \the [eaten] to \the [M] with \the [src]."))
|
||||||
cut_overlays()
|
playsound(src,'sound/items/eatfood.ogg', rand(10,40), 1)
|
||||||
|
update_icon()
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
to_chat(user, "<span class='warning'>You don't have anything on \the [src].</span>") //if we have help intent and no food scooped up DON'T STAB OURSELVES WITH THE FORK
|
to_chat(user, SPAN_WARNING("You don't have anything on \the [src].")) //if we have help intent and no food scooped up DON'T STAB OURSELVES WITH THE FORK
|
||||||
return
|
return
|
||||||
|
|
||||||
/obj/item/weapon/material/kitchen/utensil/fork
|
/obj/item/weapon/material/kitchen/utensil/fork
|
||||||
name = "fork"
|
name = "fork"
|
||||||
desc = "It's a fork. Sure is pointy."
|
desc = "It's a fork. Sure is pointy."
|
||||||
icon_state = "fork"
|
icon_state = "fork"
|
||||||
sharp = 1
|
sharp = TRUE
|
||||||
edge = 0
|
edge = FALSE
|
||||||
|
|
||||||
/obj/item/weapon/material/kitchen/utensil/fork/plastic
|
/obj/item/weapon/material/kitchen/utensil/fork/plastic
|
||||||
default_material = "plastic"
|
default_material = "plastic"
|
||||||
@@ -70,8 +80,8 @@
|
|||||||
desc = "It's a spoon. You can see your own upside-down face in it."
|
desc = "It's a spoon. You can see your own upside-down face in it."
|
||||||
icon_state = "spoon"
|
icon_state = "spoon"
|
||||||
attack_verb = list("attacked", "poked")
|
attack_verb = list("attacked", "poked")
|
||||||
edge = 0
|
edge = FALSE
|
||||||
sharp = 0
|
sharp = FALSE
|
||||||
force_divisor = 0.1 //2 when wielded with weight 20 (steel)
|
force_divisor = 0.1 //2 when wielded with weight 20 (steel)
|
||||||
|
|
||||||
/obj/item/weapon/material/kitchen/utensil/spoon/plastic
|
/obj/item/weapon/material/kitchen/utensil/spoon/plastic
|
||||||
|
|||||||
@@ -181,32 +181,26 @@
|
|||||||
// Eating with forks
|
// Eating with forks
|
||||||
if(istype(W,/obj/item/weapon/material/kitchen/utensil))
|
if(istype(W,/obj/item/weapon/material/kitchen/utensil))
|
||||||
var/obj/item/weapon/material/kitchen/utensil/U = W
|
var/obj/item/weapon/material/kitchen/utensil/U = W
|
||||||
if(U.scoop_food)
|
if(!U.reagents)
|
||||||
if(!U.reagents)
|
U.create_reagents(5)
|
||||||
U.create_reagents(5)
|
|
||||||
|
|
||||||
if (U.reagents.total_volume > 0)
|
if (U.reagents.total_volume > 0)
|
||||||
to_chat(user, "<font color='red'>You already have something on your [U].</font>")
|
to_chat(user, "<font color='red'>You already have something on your [U].</font>")
|
||||||
return
|
|
||||||
|
|
||||||
user.visible_message( \
|
|
||||||
"[user] scoops up some [src] with \the [U]!", \
|
|
||||||
"<font color='blue'>You scoop up some [src] with \the [U]!</font>" \
|
|
||||||
)
|
|
||||||
|
|
||||||
src.bitecount++
|
|
||||||
U.cut_overlays()
|
|
||||||
U.loaded = "[src]"
|
|
||||||
var/image/I = new(U.icon, "loadedfood")
|
|
||||||
I.color = src.filling_color
|
|
||||||
U.add_overlay(I)
|
|
||||||
|
|
||||||
reagents.trans_to_obj(U, min(reagents.total_volume,5))
|
|
||||||
|
|
||||||
if (reagents.total_volume <= 0)
|
|
||||||
qdel(src)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
user.visible_message( \
|
||||||
|
"[user] scoops up some [src] with \the [U]!", \
|
||||||
|
"<font color='blue'>You scoop up some [src] with \the [U]!</font>" \
|
||||||
|
)
|
||||||
|
|
||||||
|
bitecount++
|
||||||
|
|
||||||
|
reagents.trans_to_obj(U, min(reagents.total_volume,5))
|
||||||
|
|
||||||
|
if (reagents.total_volume <= 0)
|
||||||
|
qdel(src)
|
||||||
|
return
|
||||||
|
|
||||||
if (is_sliceable())
|
if (is_sliceable())
|
||||||
//these are used to allow hiding edge items in food that is not on a table/tray
|
//these are used to allow hiding edge items in food that is not on a table/tray
|
||||||
var/can_slice_here = isturf(src.loc) && ((locate(/obj/structure/table) in src.loc) || (locate(/obj/machinery/optable) in src.loc) || (locate(/obj/item/weapon/tray) in src.loc))
|
var/can_slice_here = isturf(src.loc) && ((locate(/obj/structure/table) in src.loc) || (locate(/obj/machinery/optable) in src.loc) || (locate(/obj/item/weapon/tray) in src.loc))
|
||||||
|
|||||||
37
html/changelogs/MDP-utensilsrefactor.yml
Normal file
37
html/changelogs/MDP-utensilsrefactor.yml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
################################
|
||||||
|
# Example Changelog File
|
||||||
|
#
|
||||||
|
# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb.
|
||||||
|
#
|
||||||
|
# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.)
|
||||||
|
# When it is, any changes listed below will disappear.
|
||||||
|
#
|
||||||
|
# Valid Prefixes:
|
||||||
|
# bugfix
|
||||||
|
# wip (For works in progress)
|
||||||
|
# tweak
|
||||||
|
# soundadd
|
||||||
|
# sounddel
|
||||||
|
# rscadd (general adding of nice things)
|
||||||
|
# rscdel (general deleting of nice things)
|
||||||
|
# imageadd
|
||||||
|
# imagedel
|
||||||
|
# maptweak
|
||||||
|
# spellcheck (typo fixes)
|
||||||
|
# experiment
|
||||||
|
#################################
|
||||||
|
|
||||||
|
# Your name.
|
||||||
|
author: MoondancerPony
|
||||||
|
|
||||||
|
# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again.
|
||||||
|
delete-after: True
|
||||||
|
|
||||||
|
# Any changes you've made. See valid prefix list above.
|
||||||
|
# INDENT WITH TWO SPACES. NOT TABS. SPACES.
|
||||||
|
# SCREW THIS UP AND IT WON'T WORK.
|
||||||
|
# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries.
|
||||||
|
# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog.
|
||||||
|
changes:
|
||||||
|
- bugfix: "Foods will no longer have improper grammar and capitalisation when eaten with utensils."
|
||||||
|
- tweak: "Refactors utensils to use weakrefs rather than stored strings; also does a bunch of code cleanup."
|
||||||
Reference in New Issue
Block a user