mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-25 06:00:16 +01:00
e (#12368)
This commit is contained in:
@@ -34,7 +34,7 @@ GLOBAL_LIST_INIT(armament_entries, build_armament_list())
|
||||
// ditto for the description
|
||||
spawned_armament_entry.description ||= initial(spawned_armament_entry.item_type.desc)
|
||||
// Make our icon cache for the UI.
|
||||
spawned_armament_entry.create_icon_cache()
|
||||
spawned_armament_entry.setup()
|
||||
// Now that we've set up our datum, we can add it to the correct category
|
||||
if(spawned_armament_entry.category)
|
||||
if(spawned_armament_entry.subcategory)
|
||||
@@ -94,9 +94,17 @@ GLOBAL_LIST_INIT(armament_entries, build_armament_list())
|
||||
var/cached_base64
|
||||
/// The maximum amount of this item that can be equipped.
|
||||
var/max_purchase = 1
|
||||
/// Do we have magazines for purchase?
|
||||
var/magazine
|
||||
/// If we have a magazine, how much is it?
|
||||
var/magazine_cost = 1
|
||||
|
||||
/datum/armament_entry/proc/create_icon_cache() // TODO: Make this use overlays.
|
||||
/datum/armament_entry/proc/setup() // TODO: Make this use overlays.
|
||||
var/obj/item/test_item = new item_type()
|
||||
if(istype(test_item, /obj/item/gun/ballistic))
|
||||
var/obj/item/gun/ballistic/ballistic_test = test_item
|
||||
if(!ballistic_test.internal_magazine)
|
||||
magazine = ballistic_test.mag_type
|
||||
cached_base64 = icon2base64(getFlatIcon(test_item, no_anim = TRUE))
|
||||
qdel(test_item)
|
||||
|
||||
|
||||
@@ -68,6 +68,8 @@
|
||||
"icon" = armament_entry.cached_base64,
|
||||
"name" = armament_entry.name,
|
||||
"cost" = armament_entry.cost,
|
||||
"buyable_ammo" = armament_entry.magazine ? TRUE : FALSE,
|
||||
"magazine_cost" = armament_entry.magazine_cost,
|
||||
"quantity" = armament_entry.max_purchase,
|
||||
"purchased" = purchased_items[armament_entry] ? purchased_items[armament_entry] : 0,
|
||||
"description" = armament_entry.description,
|
||||
@@ -98,22 +100,47 @@
|
||||
|
||||
switch(action)
|
||||
if("equip_item")
|
||||
var/datum/armament_entry/armament_entry
|
||||
for(var/category in GLOB.armament_entries)
|
||||
for(var/subcategory in GLOB.armament_entries[category][CATEGORY_ENTRY])
|
||||
armament_entry = locate(params["armament_ref"]) in GLOB.armament_entries[category][CATEGORY_ENTRY][subcategory]
|
||||
if(armament_entry)
|
||||
break
|
||||
if(armament_entry)
|
||||
break
|
||||
if(!armament_entry)
|
||||
var/check = check_item(params["armament_ref"])
|
||||
if(!check)
|
||||
return
|
||||
if(products && !(armament_entry.type in products))
|
||||
select_armament(usr, check)
|
||||
if("buy_ammo")
|
||||
var/check = check_item(params["armament_ref"])
|
||||
if(!check)
|
||||
return
|
||||
select_armament(usr, armament_entry)
|
||||
buy_ammo(usr, check, params["quantity"])
|
||||
if("eject_card")
|
||||
eject_card(usr)
|
||||
|
||||
/obj/machinery/armament_station/proc/buy_ammo(mob/user, datum/armament_entry/armament_entry, quantity = 1)
|
||||
if(!armament_entry.magazine)
|
||||
return
|
||||
if(!inserted_card)
|
||||
to_chat(user, span_warning("No card inserted!"))
|
||||
return
|
||||
var/quantity_cost = armament_entry.magazine_cost * quantity
|
||||
if(!inserted_card.use_points(quantity_cost))
|
||||
to_chat(user, span_warning("Not enough points!"))
|
||||
return
|
||||
for(var/i in 1 to quantity)
|
||||
new armament_entry.magazine(drop_location())
|
||||
|
||||
|
||||
/obj/machinery/armament_station/proc/check_item(reference)
|
||||
var/datum/armament_entry/armament_entry
|
||||
for(var/category in GLOB.armament_entries)
|
||||
for(var/subcategory in GLOB.armament_entries[category][CATEGORY_ENTRY])
|
||||
armament_entry = locate(reference) in GLOB.armament_entries[category][CATEGORY_ENTRY][subcategory]
|
||||
if(armament_entry)
|
||||
break
|
||||
if(armament_entry)
|
||||
break
|
||||
if(!armament_entry)
|
||||
return FALSE
|
||||
if(products && !(armament_entry.type in products))
|
||||
return FALSE
|
||||
return armament_entry
|
||||
|
||||
/obj/machinery/armament_station/proc/eject_card(mob/user)
|
||||
if(!inserted_card)
|
||||
to_chat(user, span_warning("No card inserted!"))
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
shuttleId = "goldeneye_cruiser"
|
||||
jump_to_ports = list("syndicate_n" = 1, "whiteship_away" = 1, "whiteship_home" = 1, "whiteship_z4" = 1)
|
||||
view_range = 14
|
||||
whitelist_turfs = list(/turf/open/space, /turf/open/floor/plating, /turf/open/lava, /turf/closed/mineral)
|
||||
whitelist_turfs = list(/turf/open/space, /turf/open/floor/plating, /turf/open/lava, /turf/closed/mineral, /turf/open/misc/ice/icemoon, /turf/open/misc/ice)
|
||||
see_hidden = TRUE
|
||||
x_offset = -10
|
||||
y_offset = 5
|
||||
|
||||
@@ -134,6 +134,12 @@ export const ArmamentStation = (props, context) => {
|
||||
textColor={(item.cost > card_points || !card_inserted) ? "red" : "green"}>
|
||||
{'Cost: ' + item.cost}
|
||||
</Stack.Item>
|
||||
{!!item.buyable_ammo && (
|
||||
<Stack.Item
|
||||
textColor={(item.magazine_cost > card_points || !card_inserted) ? "red" : "green"}>
|
||||
{'Ammo Cost: ' + item.magazine_cost}
|
||||
</Stack.Item>
|
||||
)}
|
||||
<Stack.Item>
|
||||
<Button
|
||||
content="Buy"
|
||||
@@ -145,6 +151,18 @@ export const ArmamentStation = (props, context) => {
|
||||
armament_ref: item.ref })}
|
||||
/>
|
||||
</Stack.Item>
|
||||
{!!item.buyable_ammo && (
|
||||
<Stack.Item>
|
||||
<Button
|
||||
content="Buy Ammo"
|
||||
textAlign="center"
|
||||
width="100%"
|
||||
disabled={item.magazine_cost > card_points}
|
||||
onClick={() => act('buy_ammo', {
|
||||
armament_ref: item.ref })}
|
||||
/>
|
||||
</Stack.Item>
|
||||
)}
|
||||
</Stack>
|
||||
)
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user