mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2025-12-28 19:11:37 +00:00
Stacks update.
This commit is contained in:
@@ -124,7 +124,6 @@ var/global/list/datum/stack_recipe/plasma_recipes = list ( \
|
||||
throw_range = 3
|
||||
origin_tech = "materials=3"
|
||||
perunit = 2000
|
||||
sheettype = "plastic"
|
||||
|
||||
var/global/list/datum/stack_recipe/plastic_recipes = list ( \
|
||||
new/datum/stack_recipe("plastic crate", /obj/structure/closet/pcrate, 10, one_per_turf = 1, on_floor = 1), \
|
||||
|
||||
@@ -13,10 +13,20 @@
|
||||
var/global/list/datum/stack_recipe/metal_recipes = list ( \
|
||||
new/datum/stack_recipe("stool", /obj/structure/stool, one_per_turf = 1, on_floor = 1), \
|
||||
new/datum/stack_recipe("chair", /obj/structure/stool/bed/chair, one_per_turf = 1, on_floor = 1), \
|
||||
new/datum/stack_recipe("swivel chair", /obj/structure/stool/bed/chair/office/dark, 5, one_per_turf = 1, on_floor = 1), \
|
||||
new/datum/stack_recipe("comfy chair", /obj/structure/stool/bed/chair/comfy/beige, 2, one_per_turf = 1, on_floor = 1), \
|
||||
new/datum/stack_recipe("bed", /obj/structure/stool/bed, 2, one_per_turf = 1, on_floor = 1), \
|
||||
null, \
|
||||
new/datum/stack_recipe_list("office chairs",list( \
|
||||
new/datum/stack_recipe("dark office chair", /obj/structure/stool/bed/chair/office/dark, 5, one_per_turf = 1, on_floor = 1), \
|
||||
new/datum/stack_recipe("light office chair", /obj/structure/stool/bed/chair/office/light, 5, one_per_turf = 1, on_floor = 1), \
|
||||
), 5), \
|
||||
new/datum/stack_recipe_list("comfy chairs", list( \
|
||||
new/datum/stack_recipe("beige comfy chair", /obj/structure/stool/bed/chair/comfy/beige, 2, one_per_turf = 1, on_floor = 1), \
|
||||
new/datum/stack_recipe("black comfy chair", /obj/structure/stool/bed/chair/comfy/black, 2, one_per_turf = 1, on_floor = 1), \
|
||||
new/datum/stack_recipe("brown comfy chair", /obj/structure/stool/bed/chair/comfy/brown, 2, one_per_turf = 1, on_floor = 1), \
|
||||
new/datum/stack_recipe("lime comfy chair", /obj/structure/stool/bed/chair/comfy/lime, 2, one_per_turf = 1, on_floor = 1), \
|
||||
new/datum/stack_recipe("teal comfy chair", /obj/structure/stool/bed/chair/comfy/teal, 2, one_per_turf = 1, on_floor = 1), \
|
||||
), 2), \
|
||||
null, \
|
||||
new/datum/stack_recipe("table parts", /obj/item/weapon/table_parts, 2), \
|
||||
new/datum/stack_recipe("rack parts", /obj/item/weapon/rack_parts), \
|
||||
new/datum/stack_recipe("closet", /obj/structure/closet, 2, time = 15, one_per_turf = 1, on_floor = 1), \
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/* Stack type objects!
|
||||
* Contains:
|
||||
* Stacks
|
||||
* Recipe datum
|
||||
* Recipe datum
|
||||
* Recipe list datum
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -32,51 +33,66 @@
|
||||
return
|
||||
|
||||
/obj/item/stack/attack_self(mob/user as mob)
|
||||
interact(user)
|
||||
list_recipes(user)
|
||||
|
||||
/obj/item/stack/interact(mob/user as mob)
|
||||
/obj/item/stack/proc/list_recipes(mob/user as mob, recipes_sublist)
|
||||
if (!recipes)
|
||||
return
|
||||
if (!src || amount<=0)
|
||||
user << browse(null, "window=stack")
|
||||
user.set_machine(src) //for correct work of onclose
|
||||
var/list/recipe_list = recipes
|
||||
if (recipes_sublist && recipe_list[recipes_sublist] && istype(recipe_list[recipes_sublist], /datum/stack_recipe_list))
|
||||
var/datum/stack_recipe_list/srl = recipe_list[recipes_sublist]
|
||||
recipe_list = srl.recipes
|
||||
var/t1 = text("<HTML><HEAD><title>Constructions from []</title></HEAD><body><TT>Amount Left: []<br>", src, src.amount)
|
||||
for(var/i=1;i<=recipes.len,i++)
|
||||
var/datum/stack_recipe/R = recipes[i]
|
||||
if (isnull(R))
|
||||
for(var/i=1;i<=recipe_list.len,i++)
|
||||
var/E = recipe_list[i]
|
||||
if (isnull(E))
|
||||
t1 += "<hr>"
|
||||
continue
|
||||
if (i>1 && !isnull(recipes[i-1]))
|
||||
|
||||
if (i>1 && !isnull(recipe_list[i-1]))
|
||||
t1+="<br>"
|
||||
var/max_multiplier = round(src.amount / R.req_amount)
|
||||
var/title as text
|
||||
var/can_build = 1
|
||||
can_build = can_build && (max_multiplier>0)
|
||||
/*
|
||||
if (R.one_per_turf)
|
||||
can_build = can_build && !(locate(R.result_type) in usr.loc)
|
||||
if (R.on_floor)
|
||||
can_build = can_build && istype(usr.loc, /turf/simulated/floor)
|
||||
*/
|
||||
if (R.res_amount>1)
|
||||
title+= "[R.res_amount]x [R.title]\s"
|
||||
else
|
||||
title+= "[R.title]"
|
||||
title+= " ([R.req_amount] [src.singular_name]\s)"
|
||||
if (can_build)
|
||||
t1 += text("<A href='?src=\ref[];make=[]'>[]</A> ", src, i, title)
|
||||
else
|
||||
t1 += text("[]", title)
|
||||
continue
|
||||
if (R.max_res_amount>1 && max_multiplier>1)
|
||||
max_multiplier = min(max_multiplier, round(R.max_res_amount/R.res_amount))
|
||||
t1 += " |"
|
||||
var/list/multipliers = list(5,10,25)
|
||||
for (var/n in multipliers)
|
||||
if (max_multiplier>=n)
|
||||
t1 += " <A href='?src=\ref[src];make=[i];multiplier=[n]'>[n*R.res_amount]x</A>"
|
||||
if (!(max_multiplier in multipliers))
|
||||
t1 += " <A href='?src=\ref[src];make=[i];multiplier=[max_multiplier]'>[max_multiplier*R.res_amount]x</A>"
|
||||
|
||||
if (istype(E, /datum/stack_recipe_list))
|
||||
var/datum/stack_recipe_list/srl = E
|
||||
if (src.amount >= srl.req_amount)
|
||||
t1 += "<a href='?src=\ref[src];sublist=[i]'>[srl.title] ([srl.req_amount] [src.singular_name]\s)</a>"
|
||||
else
|
||||
t1 += "[srl.title] ([srl.req_amount] [src.singular_name]\s<br>"
|
||||
|
||||
if (istype(E, /datum/stack_recipe))
|
||||
var/datum/stack_recipe/R = E
|
||||
var/max_multiplier = round(src.amount / R.req_amount)
|
||||
var/title as text
|
||||
var/can_build = 1
|
||||
can_build = can_build && (max_multiplier>0)
|
||||
/*
|
||||
if (R.one_per_turf)
|
||||
can_build = can_build && !(locate(R.result_type) in usr.loc)
|
||||
if (R.on_floor)
|
||||
can_build = can_build && istype(usr.loc, /turf/simulated/floor)
|
||||
*/
|
||||
if (R.res_amount>1)
|
||||
title+= "[R.res_amount]x [R.title]\s"
|
||||
else
|
||||
title+= "[R.title]"
|
||||
title+= " ([R.req_amount] [src.singular_name]\s)"
|
||||
if (can_build)
|
||||
t1 += text("<A href='?src=\ref[src];sublist=[recipes_sublist];make=[i]'>[title]</A> ")
|
||||
else
|
||||
t1 += text("[]", title)
|
||||
continue
|
||||
if (R.max_res_amount>1 && max_multiplier>1)
|
||||
max_multiplier = min(max_multiplier, round(R.max_res_amount/R.res_amount))
|
||||
t1 += " |"
|
||||
var/list/multipliers = list(5,10,25)
|
||||
for (var/n in multipliers)
|
||||
if (max_multiplier>=n)
|
||||
t1 += " <A href='?src=\ref[src];make=[i];multiplier=[n]'>[n*R.res_amount]x</A>"
|
||||
if (!(max_multiplier in multipliers))
|
||||
t1 += " <A href='?src=\ref[src];make=[i];multiplier=[max_multiplier]'>[max_multiplier*R.res_amount]x</A>"
|
||||
|
||||
t1 += "</TT></body></HTML>"
|
||||
user << browse(t1, "window=stack")
|
||||
@@ -87,10 +103,18 @@
|
||||
..()
|
||||
if ((usr.restrained() || usr.stat || usr.get_active_hand() != src))
|
||||
return
|
||||
|
||||
if (href_list["sublist"] && !href_list["make"])
|
||||
list_recipes(usr, text2num(href_list["sublist"]))
|
||||
|
||||
if (href_list["make"])
|
||||
if (src.amount < 1) del(src) //Never should happen
|
||||
|
||||
var/datum/stack_recipe/R = recipes[text2num(href_list["make"])]
|
||||
var/list/recipes_list = recipes
|
||||
if (href_list["sublist"])
|
||||
var/datum/stack_recipe_list/srl = recipes_list[text2num(href_list["sublist"])]
|
||||
recipes_list = srl.recipes
|
||||
var/datum/stack_recipe/R = recipes_list[text2num(href_list["make"])]
|
||||
var/multiplier = text2num(href_list["multiplier"])
|
||||
if (!multiplier) multiplier = 1
|
||||
if (src.amount < R.req_amount*multiplier)
|
||||
@@ -222,4 +246,16 @@
|
||||
src.max_res_amount = max_res_amount
|
||||
src.time = time
|
||||
src.one_per_turf = one_per_turf
|
||||
src.on_floor = on_floor
|
||||
src.on_floor = on_floor
|
||||
|
||||
/*
|
||||
* Recipe list datum
|
||||
*/
|
||||
/datum/stack_recipe_list
|
||||
var/title = "ERROR"
|
||||
var/list/recipes = null
|
||||
var/req_amount = 1
|
||||
New(title, recipes, req_amount = 1)
|
||||
src.title = title
|
||||
src.recipes = recipes
|
||||
src.req_amount = req_amount
|
||||
Reference in New Issue
Block a user