mirror of
https://github.com/Citadel-Station-13/Citadel-Station-13-RP.git
synced 2025-12-11 23:21:28 +00:00
* move phoronlock define * t * force rename * nuke unneeded things * don't do that * tgui sync? * changes * unit testing module * backend * tools update * aaah * go and stay go * path replace * move everything * toss out more stuff * remove * fine those can stay * dependencies.sh * ruin datum move + rename * level assets why did you guys put the turfs in my atmosphers folder grr * more moving * basemap, force stuff * fix that desync meme * move more stuff * move those too * repath * get rid of useless initializers * hacky patchy * reservations * alright * tgui * changelog example * checksum * md5 * errors * more * turf empty * stop * fix * bad kwarg * let's get those in again * alright * rid of that * huh * newlines * newlines * folder * mood * woops * readme * might as well trim now * let's go * fuck it tether isn't being used anyways lol * ok * empty files go * tether is demoted * sorry but this goes too * okay * make that work too * ok * wow. * whew * Fix * fixes * ok * sigh * fix * fix * aah. * rust_g logging * update rust g file * fix * funny * Fix * map issues * fix * initialize hints * solves some problems * those too * ok * pills * let's do that. * hit that too * runtime * add that too * alright * fix * fix * fix * Fix * add * fix * wildwest, what have they done to you... * do that too' git push * fixes * fixes * fixes * pack this tightly * let's not have empty files * sigh * fix * FUCK OFF * fix icon * rip old mapmerge * zz * woo yeah woo yeah * logging * fix * better logs * GRRRRRR * last commit?? * awful
153 lines
3.2 KiB
Plaintext
153 lines
3.2 KiB
Plaintext
#define FORWARD -1
|
|
#define BACKWARD 1
|
|
|
|
|
|
// As of August 4th, 2018, these datums are only used in Mech construction.
|
|
/datum/construction
|
|
var/list/steps
|
|
var/atom/holder
|
|
var/result
|
|
var/list/steps_desc
|
|
|
|
/datum/construction/New(atom)
|
|
..()
|
|
holder = atom
|
|
if(!holder) //don't want this without a holder
|
|
spawn
|
|
qdel(src)
|
|
set_desc(steps.len)
|
|
return
|
|
|
|
/datum/construction/proc/next_step()
|
|
steps.len--
|
|
if(!steps.len)
|
|
spawn_result()
|
|
else
|
|
set_desc(steps.len)
|
|
return
|
|
|
|
/datum/construction/proc/action(var/obj/item/I,mob/user as mob)
|
|
return
|
|
|
|
/datum/construction/proc/check_step(var/obj/item/I,mob/user as mob) //check last step only
|
|
var/valid_step = is_right_key(I)
|
|
if(valid_step)
|
|
if(custom_action(valid_step, I, user))
|
|
next_step()
|
|
return 1
|
|
return 0
|
|
|
|
/datum/construction/proc/is_right_key(var/obj/item/I) // returns current step num if I is of the right type.
|
|
var/list/L = steps[steps.len]
|
|
switch(L["key"])
|
|
if(IS_SCREWDRIVER)
|
|
if(I.is_screwdriver())
|
|
return steps.len
|
|
if(IS_CROWBAR)
|
|
if(I.is_crowbar())
|
|
return steps.len
|
|
if(IS_WIRECUTTER)
|
|
if(I.is_wirecutter())
|
|
return steps.len
|
|
if(IS_WRENCH)
|
|
if(I.is_wrench())
|
|
return steps.len
|
|
|
|
if(istype(I, L["key"]))
|
|
return steps.len
|
|
return 0
|
|
|
|
/datum/construction/proc/custom_action(step, I, user)
|
|
return 1
|
|
|
|
/datum/construction/proc/check_all_steps(var/obj/item/I,mob/user as mob) //check all steps, remove matching one.
|
|
for(var/i=1;i<=steps.len;i++)
|
|
var/list/L = steps[i];
|
|
if(istype(I, L["key"]))
|
|
if(custom_action(i, I, user))
|
|
steps[i]=null;//stupid byond list from list removal...
|
|
listclearnulls(steps);
|
|
if(!steps.len)
|
|
spawn_result()
|
|
return 1
|
|
return 0
|
|
|
|
|
|
/datum/construction/proc/spawn_result()
|
|
if(result)
|
|
new result(get_turf(holder))
|
|
spawn()
|
|
qdel(holder)
|
|
return
|
|
|
|
/datum/construction/proc/set_desc(index as num)
|
|
var/list/step = steps[index]
|
|
holder.desc = step["desc"]
|
|
return
|
|
|
|
|
|
// Reversible
|
|
/datum/construction/reversible
|
|
var/index
|
|
|
|
/datum/construction/reversible/New(atom)
|
|
..()
|
|
index = steps.len
|
|
return
|
|
|
|
/datum/construction/reversible/proc/update_index(diff as num)
|
|
index+=diff
|
|
if(index==0)
|
|
spawn_result()
|
|
else
|
|
set_desc(index)
|
|
return
|
|
|
|
/datum/construction/reversible/is_right_key(var/obj/item/I) // returns index step
|
|
var/list/L = steps[index]
|
|
|
|
switch(L["key"])
|
|
if(IS_SCREWDRIVER)
|
|
if(I.is_screwdriver())
|
|
return FORWARD
|
|
if(IS_CROWBAR)
|
|
if(I.is_crowbar())
|
|
return FORWARD
|
|
if(IS_WIRECUTTER)
|
|
if(I.is_wirecutter())
|
|
return FORWARD
|
|
if(IS_WRENCH)
|
|
if(I.is_wrench())
|
|
return FORWARD
|
|
|
|
switch(L["backkey"])
|
|
if(IS_SCREWDRIVER)
|
|
if(I.is_screwdriver())
|
|
return BACKWARD
|
|
if(IS_CROWBAR)
|
|
if(I.is_crowbar())
|
|
return BACKWARD
|
|
if(IS_WIRECUTTER)
|
|
if(I.is_wirecutter())
|
|
return BACKWARD
|
|
if(IS_WRENCH)
|
|
if(I.is_wrench())
|
|
return BACKWARD
|
|
|
|
if(istype(I, L["key"]))
|
|
return FORWARD //to the first step -> forward
|
|
else if(L["backkey"] && istype(I, L["backkey"]))
|
|
return BACKWARD //to the last step -> backwards
|
|
return 0
|
|
|
|
/datum/construction/reversible/check_step(var/obj/item/I,mob/user as mob)
|
|
var/diff = is_right_key(I)
|
|
if(diff)
|
|
if(custom_action(index, diff, I, user))
|
|
update_index(diff)
|
|
return 1
|
|
return 0
|
|
|
|
/datum/construction/reversible/custom_action(index, diff, I, user)
|
|
return 1
|