mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +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
|
||||
origin_tech = list(TECH_MATERIAL = 1)
|
||||
attack_verb = list("attacked", "stabbed", "poked")
|
||||
sharp = 1
|
||||
edge = 1
|
||||
sharp = TRUE
|
||||
edge = TRUE
|
||||
force_divisor = 0.1 // 6 when wielded with hardness 60 (steel)
|
||||
thrown_force_divisor = 0.25 // 5 when thrown with weight 20 (steel)
|
||||
var/loaded //Descriptive string for currently loaded food object.
|
||||
var/scoop_food = 1
|
||||
var/weakref/loaded //Weakref for currently loaded food object.
|
||||
|
||||
/obj/item/weapon/material/kitchen/utensil/New()
|
||||
..()
|
||||
@@ -25,6 +24,15 @@
|
||||
create_reagents(5)
|
||||
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)
|
||||
if(!istype(M))
|
||||
return ..()
|
||||
@@ -37,30 +45,32 @@
|
||||
else
|
||||
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)
|
||||
if(eaten)
|
||||
if(M == user)
|
||||
if(!M.can_eat(loaded))
|
||||
if(!M.can_eat(eaten))
|
||||
return
|
||||
M.visible_message("<span class='notice'>\The [user] eats some [loaded] from \the [src].</span>")
|
||||
M.visible_message(SPAN_NOTICE("\The [user] eats some of \the [eaten] with \the [src]."))
|
||||
else
|
||||
user.visible_message("<span class='warning'>\The [user] begins to feed \the [M]!</span>")
|
||||
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]!"))
|
||||
if(!(M.can_force_feed(user, eaten) && do_mob(user, M, 5 SECONDS)))
|
||||
return
|
||||
M.visible_message("<span class='notice'>\The [user] feeds some [loaded] to \the [M] with \the [src].</span>")
|
||||
M.visible_message(SPAN_NOTICE("\The [user] feeds some of \the [eaten] to \the [M] with \the [src]."))
|
||||
playsound(src,'sound/items/eatfood.ogg', rand(10,40), 1)
|
||||
cut_overlays()
|
||||
update_icon()
|
||||
return
|
||||
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
|
||||
|
||||
/obj/item/weapon/material/kitchen/utensil/fork
|
||||
name = "fork"
|
||||
desc = "It's a fork. Sure is pointy."
|
||||
icon_state = "fork"
|
||||
sharp = 1
|
||||
edge = 0
|
||||
sharp = TRUE
|
||||
edge = FALSE
|
||||
|
||||
/obj/item/weapon/material/kitchen/utensil/fork/plastic
|
||||
default_material = "plastic"
|
||||
@@ -70,8 +80,8 @@
|
||||
desc = "It's a spoon. You can see your own upside-down face in it."
|
||||
icon_state = "spoon"
|
||||
attack_verb = list("attacked", "poked")
|
||||
edge = 0
|
||||
sharp = 0
|
||||
edge = FALSE
|
||||
sharp = FALSE
|
||||
force_divisor = 0.1 //2 when wielded with weight 20 (steel)
|
||||
|
||||
/obj/item/weapon/material/kitchen/utensil/spoon/plastic
|
||||
|
||||
@@ -181,7 +181,6 @@
|
||||
// Eating with forks
|
||||
if(istype(W,/obj/item/weapon/material/kitchen/utensil))
|
||||
var/obj/item/weapon/material/kitchen/utensil/U = W
|
||||
if(U.scoop_food)
|
||||
if(!U.reagents)
|
||||
U.create_reagents(5)
|
||||
|
||||
@@ -194,12 +193,7 @@
|
||||
"<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)
|
||||
bitecount++
|
||||
|
||||
reagents.trans_to_obj(U, min(reagents.total_volume,5))
|
||||
|
||||
|
||||
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