Skip to content

Commit

Permalink
Restoring missing files...?
Browse files Browse the repository at this point in the history
  • Loading branch information
lectronyx committed Jun 13, 2024
1 parent f50415c commit fe043b3
Show file tree
Hide file tree
Showing 20 changed files with 2,929 additions and 1 deletion.
88 changes: 88 additions & 0 deletions code/__DEFINES/storage.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// storage_flags variable on /datum/component/storage

// Storage limits. These can be combined (and usually are combined).
/// Check max_items and contents.len when trying to insert
#define STORAGE_LIMIT_MAX_ITEMS (1<<0)
/// Check max_combined_w_class.
#define STORAGE_LIMIT_COMBINED_W_CLASS (1<<1)
/// Use the new volume system. Will automatically force rendering to use the new volume/baystation scaling UI so this is kind of incompatible with stuff like stack storage etc etc.
#define STORAGE_LIMIT_VOLUME (1<<2)
/// Use max_w_class
#define STORAGE_LIMIT_MAX_W_CLASS (1<<3)

#define STORAGE_FLAGS_LEGACY_DEFAULT (STORAGE_LIMIT_MAX_ITEMS | STORAGE_LIMIT_COMBINED_W_CLASS | STORAGE_LIMIT_MAX_W_CLASS)
#define STORAGE_FLAGS_VOLUME_DEFAULT (STORAGE_LIMIT_VOLUME | STORAGE_LIMIT_MAX_W_CLASS)

// UI defines
/// Size of volumetric box icon
#define VOLUMETRIC_STORAGE_BOX_ICON_SIZE 32
/// Size of EACH left/right border icon for volumetric boxes
#define VOLUMETRIC_STORAGE_BOX_BORDER_SIZE 1
/// Minimum pixels an item must have in volumetric scaled storage UI
#define MINIMUM_PIXELS_PER_ITEM 8
/// Maximum number of objects that will be allowed to be displayed using the volumetric display system. Arbitrary number to prevent server lockups.
#define MAXIMUM_VOLUMETRIC_ITEMS 256
/// How much padding to give between items
#define VOLUMETRIC_STORAGE_ITEM_PADDING 3
/// How much padding to give to edges
#define VOLUMETRIC_STORAGE_EDGE_PADDING 1

//ITEM INVENTORY WEIGHT, FOR w_class
/// Usually items smaller then a human hand, ex: Playing Cards, Lighter, Scalpel, Coins/Money
#define WEIGHT_CLASS_TINY 1
/// Fits within a small pocket, ex: Flashlight, Multitool, Grenades, GPS Device
#define WEIGHT_CLASS_SMALL 2
/// Can be carried in one hand comfortably, ex: Fire extinguisher, Stunbaton, Gas Mask, Metal Sheets
#define WEIGHT_CLASS_NORMAL 3
/// Items that can be wielded or equipped, (e.g. defibrillator, space suits). Often fits inside backpacks.
#define WEIGHT_CLASS_BULKY 4
/// Usually represents objects that require two hands to operate, (e.g. shotgun, two-handed melee weapons) May fit on some inventory slots
#define WEIGHT_CLASS_HUGE 5
/// Essentially means it cannot be picked up or placed in an inventory, ex: Mech Parts, Safe - Can not fit in Boh
#define WEIGHT_CLASS_GIGANTIC 6

// PLEASE KEEP ALL VOLUME DEFINES IN THIS FILE, it's going to be hell to keep track of them later.
#define DEFAULT_VOLUME_TINY 1
#define DEFAULT_VOLUME_SMALL 2
#define DEFAULT_VOLUME_NORMAL 6
#define DEFAULT_VOLUME_BULKY 12
#define DEFAULT_VOLUME_HUGE 24
#define DEFAULT_VOLUME_GIGANTIC 48

GLOBAL_LIST_INIT(default_weight_class_to_volume, list(
"[WEIGHT_CLASS_TINY]" = DEFAULT_VOLUME_TINY,
"[WEIGHT_CLASS_SMALL]" = DEFAULT_VOLUME_SMALL,
"[WEIGHT_CLASS_NORMAL]" = DEFAULT_VOLUME_NORMAL,
"[WEIGHT_CLASS_BULKY]" = DEFAULT_VOLUME_BULKY,
"[WEIGHT_CLASS_HUGE]" = DEFAULT_VOLUME_HUGE,
"[WEIGHT_CLASS_GIGANTIC]" = DEFAULT_VOLUME_GIGANTIC
))

/// Macro for automatically getting the volume of an item from its w_class.
#define AUTO_SCALE_VOLUME(w_class) (GLOB.default_weight_class_to_volume["[w_class]"])
/// Macro for automatically getting the volume of a storage item from its max_w_class and max_combined_w_class.
#define AUTO_SCALE_STORAGE_VOLUME(w_class, max_combined_w_class) (AUTO_SCALE_VOLUME(w_class) * (max_combined_w_class / w_class))

// Let's keep all of this in one place. given what we put above anyways..

// volume amount for items
#define ITEM_VOLUME_DISK DEFAULT_VOLUME_TINY
#define ITEM_VOLUME_CONTAINER_M 12 //makes nested toolboxes & toolbelts less efficient
#define ITEM_VOLUME_MOB 40//prevents mob stacking

// #define SAMPLE_VOLUME_AMOUNT 2

// max_weight_class for storages
//
#define MAX_WEIGHT_CLASS_S_CONTAINER WEIGHT_CLASS_SMALL
#define MAX_WEIGHT_CLASS_M_CONTAINER WEIGHT_CLASS_NORMAL
#define MAX_WEIGHT_CLASS_BACKPACK WEIGHT_CLASS_NORMAL
#define MAX_WEIGHT_CLASS_DUFFEL WEIGHT_CLASS_BULKY

// max_volume for storages
#define STORAGE_VOLUME_CONTAINER_S DEFAULT_VOLUME_NORMAL //3 small items
#define STORAGE_VOLUME_CONTAINER_M (DEFAULT_VOLUME_NORMAL * 2) //6 small items
#define STORAGE_VOLUME_SATCHEL (DEFAULT_VOLUME_NORMAL * 4) //4 normal items
#define STORAGE_VOLUME_BACKPACK (DEFAULT_VOLUME_NORMAL * 6) //6 normal items, or 3 bulky items
#define STORAGE_VOLUME_DUFFLEBAG (DEFAULT_VOLUME_NORMAL * 8) // 2 huge items, or 4 bulky items
#define STORAGE_VOLUME_BAG_OF_HOLDING (DEFAULT_VOLUME_NORMAL * 9) //1.5X backpack
198 changes: 198 additions & 0 deletions code/_onclick/hud/storage.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
/atom/movable/screen/storage
name = "storage"
var/insertion_click = FALSE

/atom/movable/screen/storage/Initialize(mapload, new_master)
. = ..()
master = new_master

/atom/movable/screen/storage/Click(location, control, params)
if(!insertion_click)
return ..()
if(hud?.mymob && (hud.mymob != usr))
return
// just redirect clicks
if(master)
var/obj/item/I = usr.get_active_held_item()
if(I)
master.attackby(null, I, usr, params)
return TRUE

/atom/movable/screen/storage/boxes
name = "storage"
icon_state = "block"
screen_loc = "7,7 to 10,8"
layer = HUD_LAYER
plane = HUD_PLANE
insertion_click = TRUE

/atom/movable/screen/storage/close
name = "close"
layer = ABOVE_HUD_LAYER
plane = ABOVE_HUD_PLANE
icon_state = "backpack_close"

/atom/movable/screen/storage/close/Click()
var/datum/component/storage/S = master
S.close(usr)
return TRUE

/atom/movable/screen/storage/left
icon_state = "storage_start"
insertion_click = TRUE

/atom/movable/screen/storage/right
icon_state = "storage_end"
insertion_click = TRUE

/atom/movable/screen/storage/continuous
icon_state = "storage_continue"
insertion_click = TRUE

/atom/movable/screen/storage/volumetric_box
icon_state = "stored_continue"
layer = VOLUMETRIC_STORAGE_BOX_LAYER
plane = VOLUMETRIC_STORAGE_BOX_PLANE
var/obj/item/our_item

/atom/movable/screen/storage/volumetric_box/Initialize(mapload, new_master, obj/item/our_item)
src.our_item = our_item
RegisterSignal(our_item, COMSIG_ITEM_MOUSE_ENTER, PROC_REF(on_item_mouse_enter))
RegisterSignal(our_item, COMSIG_ITEM_MOUSE_EXIT, PROC_REF(on_item_mouse_exit))
return ..()

/atom/movable/screen/storage/volumetric_box/Destroy()
makeItemInactive()
our_item = null
return ..()

/atom/movable/screen/storage/volumetric_box/Click(location, control, params)
return our_item.Click(location, control, params)

/atom/movable/screen/storage/volumetric_box/MouseDrop(atom/over, src_location, over_location, src_control, over_control, params)
return our_item.MouseDrop(over, src_location, over_location, src_control, over_control, params)

/atom/movable/screen/storage/volumetric_box/MouseExited(location, control, params)
makeItemInactive()

/atom/movable/screen/storage/volumetric_box/MouseEntered(location, control, params)
. = ..()
makeItemActive()

/atom/movable/screen/storage/volumetric_box/proc/on_item_mouse_enter()
makeItemActive()

/atom/movable/screen/storage/volumetric_box/proc/on_item_mouse_exit()
makeItemInactive()

/atom/movable/screen/storage/volumetric_box/proc/makeItemInactive()
return

/atom/movable/screen/storage/volumetric_box/proc/makeItemActive()
return

/atom/movable/screen/storage/volumetric_box/center
icon_state = "stored_continue"
var/atom/movable/screen/storage/volumetric_edge/stored_left/left
var/atom/movable/screen/storage/volumetric_edge/stored_right/right
var/atom/movable/screen/storage/item_holder/holder
var/pixel_size

/atom/movable/screen/storage/volumetric_box/center/Initialize(mapload, new_master, our_item)
left = new(null, src, our_item)
right = new(null, src, our_item)
return ..()

/atom/movable/screen/storage/volumetric_box/center/Destroy()
QDEL_NULL(left)
QDEL_NULL(right)
vis_contents.Cut()
if(holder)
QDEL_NULL(holder)
return ..()

/atom/movable/screen/storage/volumetric_box/center/proc/on_screen_objects()
return list(src)


//Sets the size of this box screen object and regenerates its left/right borders. This includes the actual border's size!
/atom/movable/screen/storage/volumetric_box/center/proc/set_pixel_size(pixels)
if(pixel_size == pixels)
return
pixel_size = pixels
cut_overlays()
vis_contents.Cut()
//our icon size is 32 pixels.
var/multiplier = (pixels - (VOLUMETRIC_STORAGE_BOX_BORDER_SIZE * 2)) / VOLUMETRIC_STORAGE_BOX_ICON_SIZE
transform = matrix(multiplier, 0, 0, 0, 1, 0)
if(our_item)
if(holder)
qdel(holder)
holder = new(null, src, our_item)
holder.transform = matrix(1 / multiplier, 0, 0, 0, 1, 0)
holder.mouse_opacity = MOUSE_OPACITY_TRANSPARENT
holder.appearance_flags &= ~RESET_TRANSFORM
makeItemInactive()
vis_contents += holder
left.pixel_x = -((pixels - VOLUMETRIC_STORAGE_BOX_ICON_SIZE) * 0.5) - VOLUMETRIC_STORAGE_BOX_BORDER_SIZE
right.pixel_x = ((pixels - VOLUMETRIC_STORAGE_BOX_ICON_SIZE) * 0.5) + VOLUMETRIC_STORAGE_BOX_BORDER_SIZE
add_overlay(left)
add_overlay(right)

/atom/movable/screen/storage/volumetric_box/center/makeItemInactive()
if(!holder)
return
holder.layer = VOLUMETRIC_STORAGE_ITEM_LAYER
holder.plane = VOLUMETRIC_STORAGE_ITEM_PLANE

/atom/movable/screen/storage/volumetric_box/center/makeItemActive()
if(!holder)
return
holder.our_item.layer = VOLUMETRIC_STORAGE_ACTIVE_ITEM_LAYER //make sure we display infront of the others!
holder.our_item.plane = VOLUMETRIC_STORAGE_ACTIVE_ITEM_PLANE

/atom/movable/screen/storage/volumetric_edge
layer = VOLUMETRIC_STORAGE_BOX_LAYER
plane = VOLUMETRIC_STORAGE_BOX_PLANE

/atom/movable/screen/storage/volumetric_edge/Initialize(mapload, master, our_item)
src.master = master
return ..()

/atom/movable/screen/storage/volumetric_edge/Click(location, control, params)
return master.Click(location, control, params)

/atom/movable/screen/storage/volumetric_edge/MouseDrop(atom/over, src_location, over_location, src_control, over_control, params)
return master.MouseDrop(over, src_location, over_location, src_control, over_control, params)

/atom/movable/screen/storage/volumetric_edge/MouseExited(location, control, params)
return master.MouseExited(location, control, params)

/atom/movable/screen/storage/volumetric_edge/MouseEntered(location, control, params)
. = ..()
return master.MouseEntered(location, control, params)

/atom/movable/screen/storage/volumetric_edge/stored_left
icon_state = "stored_start"
appearance_flags = APPEARANCE_UI | KEEP_APART | RESET_TRANSFORM // Yes I know RESET_TRANSFORM is in APPEARANCE_UI but we're hard-asserting this incase someone changes it.

/atom/movable/screen/storage/volumetric_edge/stored_right
icon_state = "stored_end"
appearance_flags = APPEARANCE_UI | KEEP_APART | RESET_TRANSFORM

/atom/movable/screen/storage/item_holder
var/obj/item/our_item
vis_flags = NONE

/atom/movable/screen/storage/item_holder/Initialize(mapload, new_master, obj/item/I)
. = ..()
our_item = I
vis_contents += I

/atom/movable/screen/storage/item_holder/Destroy()
vis_contents.Cut()
our_item = null
return ..()

/atom/movable/screen/storage/item_holder/Click(location, control, params)
return our_item.Click(location, control, params)
24 changes: 24 additions & 0 deletions code/controllers/subsystem/processing/movable_physics.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
///Real fast ticking subsystem for moving movables via modifying pixel_x/y/z
PROCESSING_SUBSYSTEM_DEF(movablephysics)
name = "Movable Physics"
wait = 0.05 SECONDS
stat_tag = "MP"
priority = FIRE_PRIORITY_MOVABLE_PHYSICS

/datum/controller/subsystem/processing/movablephysics/fire(resumed = FALSE)
if (!resumed)
currentrun = processing.Copy()
//cache for sanic speed (lists are references anyways)
var/list/current_run = currentrun

while(current_run.len)
var/datum/component/thing = current_run[current_run.len]
current_run.len--
if(QDELETED(thing))
processing -= thing
else
if(thing.process(wait * 0.1) == PROCESS_KILL)
// fully stop so that a future START_PROCESSING will work
STOP_PROCESSING(src, thing)
if (MC_TICK_CHECK)
return
Loading

0 comments on commit fe043b3

Please sign in to comment.