mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2026-01-04 14:33:30 +00:00
39 lines
1.3 KiB
Plaintext
39 lines
1.3 KiB
Plaintext
#define CELLS 4
|
|
#define CELLSIZE (32/CELLS)
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// Food.
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/obj/item/weapon/reagent_containers/food
|
|
possible_transfer_amounts = null
|
|
volume = 50 //Sets the default container amount for all food items.
|
|
var/filling_color = "#FFFFFF" //Used by sandwiches.
|
|
|
|
var/list/center_of_mass = list() // Used for table placement
|
|
|
|
/obj/item/weapon/reagent_containers/food/New()
|
|
..()
|
|
if (!pixel_x && !pixel_y)
|
|
src.pixel_x = rand(-6.0, 6) //Randomizes postion
|
|
src.pixel_y = rand(-6.0, 6)
|
|
|
|
/obj/item/weapon/reagent_containers/food/afterattack(atom/A, mob/user, proximity, params)
|
|
if(proximity && params && istype(A, /obj/structure/table) && center_of_mass.len)
|
|
//Places the item on a grid
|
|
var/list/mouse_control = params2list(params)
|
|
|
|
var/mouse_x = text2num(mouse_control["icon-x"])
|
|
var/mouse_y = text2num(mouse_control["icon-y"])
|
|
|
|
if(!isnum(mouse_x) || !isnum(mouse_y))
|
|
return
|
|
|
|
var/cell_x = max(0, min(CELLS-1, round(mouse_x/CELLSIZE)))
|
|
var/cell_y = max(0, min(CELLS-1, round(mouse_y/CELLSIZE)))
|
|
|
|
pixel_x = (CELLSIZE * (0.5 + cell_x)) - center_of_mass["x"]
|
|
pixel_y = (CELLSIZE * (0.5 + cell_y)) - center_of_mass["y"]
|
|
|
|
#undef CELLS
|
|
#undef CELLSIZE
|