Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
cc17549
add trade_beacon.dm
michaelchessall May 13, 2022
392de09
Create trade_beacon.tmpl
michaelchessall May 13, 2022
658b1b1
Update tradebeacon.dm
michaelchessall May 13, 2022
72510d8
Update trade_beacon.tmpl
michaelchessall May 13, 2022
a4f7f9a
Fix SQL file
michaelchessall May 17, 2022
9f9d035
update trade beacon
michaelchessall May 18, 2022
b4e1ba8
Update trade_beacon.tmpl
michaelchessall May 18, 2022
c9a97bf
Update tradebeacon.dm
michaelchessall May 18, 2022
409aaad
updates
michaelchessall May 20, 2022
c892e67
Merge branch 'PersistentSS13:dev' into dev
michaelchessall May 20, 2022
44936b6
update files
michaelchessall May 25, 2022
034bd06
TRADE BEACON UPDATE
michaelchessall Mar 14, 2023
e0814fe
Merge branch 'dev' of https://github.com/FaurnsGoldberg/Nebula into dev
michaelchessall Mar 14, 2023
dc44d19
removed old files
michaelchessall Mar 14, 2023
ac18716
Delete tradebeacon.dm
michaelchessall Mar 14, 2023
4e23eaa
Update _persistence.dme
michaelchessall Mar 14, 2023
7dc1b2e
Update trade_beacon_program.dm
michaelchessall Mar 14, 2023
7261a26
fix map units tests
michaelchessall Mar 14, 2023
0500438
Fix unit tests, all_trade_beacons list
michaelchessall Mar 14, 2023
f500804
fix unit tests
michaelchessall Mar 14, 2023
b8a8350
Update _persistence.dme
michaelchessall Mar 14, 2023
6085c60
Update network.dm
michaelchessall Mar 14, 2023
9f21dda
Update cargo_telepads.dm
michaelchessall Mar 14, 2023
3fcae62
Merge branch 'dev' of https://github.com/FaurnsGoldberg/Nebula into dev
michaelchessall Mar 14, 2023
3c60d1b
Update cargo_telepads.dm
michaelchessall Mar 14, 2023
9f61421
fix unit tests, improve readability
michaelchessall Mar 14, 2023
69bc0a2
include return on init
michaelchessall Mar 14, 2023
b276e77
Update trade_beacons.dm
michaelchessall Mar 14, 2023
66e5a60
fix unit tests
michaelchessall Mar 14, 2023
a4b2754
fix unit tests????
michaelchessall Mar 14, 2023
8b9a391
Update trade_beacons.dm
michaelchessall Mar 14, 2023
3ea5d8f
Update trade_beacons.dm
michaelchessall Mar 14, 2023
0d5da55
Update trade_beacons.dm
michaelchessall Mar 14, 2023
1378028
fix unit tests??
michaelchessall Mar 14, 2023
4628ef5
Update trade_beacons.dm
michaelchessall Mar 15, 2023
6d2347b
Update trade_beacons.dm
michaelchessall Mar 15, 2023
b57d1c1
Update trade_beacons.dm
michaelchessall Mar 15, 2023
4095407
fix unit tests
michaelchessall Mar 15, 2023
bc08eb5
Update trade_beacons.dm
michaelchessall Mar 15, 2023
62536d2
fix unit tests
michaelchessall Mar 15, 2023
eca3ad0
fix err
michaelchessall Mar 15, 2023
84d7567
Update trade_beacons.dm
michaelchessall Mar 15, 2023
7ec419f
Update trade_beacons.dm
michaelchessall Mar 15, 2023
b6e288c
Update trade_beacons.dm
michaelchessall Mar 15, 2023
70a4976
z
michaelchessall Mar 15, 2023
921a612
Update trade_beacons.dm
michaelchessall Mar 15, 2023
6d2ad29
Update trade_beacons.dm
michaelchessall Mar 15, 2023
7db1021
Update mods/persistence/modules/trade_beacons/trade_beacons.dm
michaelchessall Mar 17, 2023
4dfa4b2
Update code/modules/economy/cargo_telepads.dm
michaelchessall Mar 17, 2023
d8da389
Update code/modules/economy/cargo_telepads.dm
michaelchessall Mar 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,18 @@

additional_spawn_components = list(
/obj/item/stock_parts/power/apc/buildable = 1
)
)

/obj/item/stock_parts/circuitboard/trade_controller
name = "circuitboard (trade control device)"
build_path = /obj/machinery/network/trade_controller
origin_tech = "{'programming':4,'magnets':3}"
req_components = list(
/obj/item/stock_parts/capacitor = 1,
/obj/item/stock_parts/scanning_module = 2
)

/obj/item/stock_parts/circuitboard/telepad
name = "circuitboard (cargo telepad)"
build_path = /obj/machinery/telepad_cargo

28 changes: 28 additions & 0 deletions code/modules/economy/cargo_telepads.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/obj/machinery/telepad_cargo
name = "cargo telepad"
desc = "A telepad used to recieve imports and send exports."
icon = 'icons/obj/machines/telepad.dmi'
icon_state = "pad-idle"
anchored = 1
use_power = 1
idle_power_usage = 20
active_power_usage = 500
var/telepad_id = 0
obj_flags = OBJ_FLAG_ANCHORABLE

/obj/machinery/telepad_cargo/Initialize()
telepad_id = random_id(type,10000,99999)
. = ..()

/obj/machinery/telepad_cargo/attackby(obj/item/O as obj, mob/user as mob, params)
if(IS_MULTITOOL(O))
var/id = input(user, "Enter a new telepad ID", "Telepad ID") as text|null
id = sanitize(id)
if(CanInteract(user, DefaultTopicState()) && id) telepad_id = id
return TRUE

. = ..()

/obj/machinery/telepad_cargo/examine(mob/user)
. = ..()
to_chat(user, "It has a telepad ID of [telepad_id].")
89 changes: 89 additions & 0 deletions code/modules/modular_computers/hardware/trade_controller.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/datum/extension/network_device/trade_controller
var/obj/effect/overmap/trade_beacon/linked_beacon
var/import_tax = 0
var/export_tax = 0
var/beacon_restrict = 0 // Restriction to ALL beacon functions, import/export/log. 0 = no restricton, 1 = restricted to the network
var/log_restrict = 0 // Restriction of the transaction log. 0 = no restricton, 1 = restricted to the network
var/access = 0 // Which access will allow for general beacon functions
var/log_access = 0 // which access will allow for viewing the transaction log

/datum/extension/network_device/trade_controller/proc/Unlink()
if(linked_beacon)
linked_beacon.linked_controller = null
linked_beacon = null
/datum/extension/network_device/trade_controller/Destroy()
Unlink()
. = ..()

/datum/extension/network_device/trade_controller/disconnect(net_down)
Unlink()
. = ..()

/datum/extension/network_device/trade_controller/proc/toggle_beacon_restrict()
if(!linked_beacon)
beacon_restrict = 0
return
beacon_restrict = !beacon_restrict
var/datum/computer_network/network = get_network()
if(network.trade_controller == src)
network.add_log("Trade Control Device toggled beacon restriction for [linked_beacon.name].", network_tag)
return 1


/datum/extension/network_device/trade_controller/proc/select_beacon_access(var/mob/M, var/obj/machinery/network/trade_controller/machine)
var/list/access_choices = list()
var/datum/computer_network/network = get_network()
var/datum/extension/network_device/acl/D
if(network)
D = network.access_controller
if(!linked_beacon)
access = 0
return
if(!D)
to_chat(M, SPAN_WARNING("Cannot restrict access! No access controller detected on network!"))
return
for(var/parent_group in D.group_dict)
access_choices |= parent_group
for(var/child_group in D.group_dict[parent_group])
access_choices |= child_group
access_choices |= "*NONE*"
var/chosen = input(M, "Select an Access for the Trade Beacon.", "Beacon Access Selection") as null|anything in access_choices
if(chosen && (!machine || machine.CanUseTopic(M)))
if(chosen == "*NONE*")
access = 0
network.add_log("Trade Control Device unset beacon access for [linked_beacon.name].", network_tag)
else
access = chosen
network.add_log("Trade Control Device set beacon access to [chosen] for [linked_beacon.name].", network_tag)
return 1
/datum/extension/network_device/trade_controller/proc/select_import_tax(var/mob/M, var/obj/machinery/network/trade_controller/machine)
var/datum/computer_network/network = get_network()
if(!linked_beacon)
import_tax = 0
return
var/chosen_tax = input(M, "Enter the import tax% to charge for this beacon. (30% MAX)", "Import Tax") as num|null
if(!machine || machine.CanUseTopic(M))
import_tax = clamp(chosen_tax, 0, 30)
network.add_log("Trade Control Device changed the import tax rate to [import_tax] for [linked_beacon.name].", network_tag)
return 1

/datum/extension/network_device/trade_controller/proc/select_export_tax(var/mob/M, var/obj/machinery/network/trade_controller/machine)
var/datum/computer_network/network = get_network()
if(!linked_beacon)
export_tax = 0
return
var/chosen_tax = input(M, "Enter the export tax% to charge for this beacon. (30% MAX)", "Export Tax") as num|null
if(!machine || machine.CanUseTopic(M))
export_tax = clamp(chosen_tax, 0, 30)
network.add_log("Trade Control Device changed the export tax rate to [export_tax] for [linked_beacon.name].", network_tag)
return 1

/datum/extension/network_device/trade_controller/proc/toggle_log_restrict()
if(!linked_beacon)
log_restrict = 0
return
log_restrict = !log_restrict
var/datum/computer_network/network = get_network()
if(network.trade_controller == src)
network.add_log("Trade Control Device toggled transaction log restriction for [linked_beacon.name].", network_tag)
return 1
9 changes: 9 additions & 0 deletions code/modules/modular_computers/networking/_network.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
var/datum/money_account/parent/network/parent_account
var/list/datum/extension/network_device/money_cube/money_cubes = list()

var/datum/extension/network_device/trade_controller/trade_controller

var/network_features_enabled = NET_ALL_FEATURES
var/intrusion_detection_enabled
var/intrusion_detection_alarm
Expand Down Expand Up @@ -108,6 +110,7 @@

banking_mainframe = D
add_log("New banking mainframe set", newtag)

else if(istype(D, /datum/extension/network_device/money_cube))
if(!parent_account)
return FALSE
Expand All @@ -117,6 +120,12 @@
parent_account.adjust_money(cube.stored_money)
cube.stored_money = 0

else if(istype(D, /datum/extension/network_device/trade_controller))
if(trade_controller)
return FALSE
trade_controller = D
add_log("New Trade Control set", newtag)

D.network_tag = newtag
devices |= D
devices_by_tag[D.network_tag] = D
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/obj/machinery/network/trade_controller
name = "trade control device"
desc = "A device used for controlling trade beacons and adding import/export tax. It must remain in a gravity well near the trade beacon"
icon = 'icons/obj/machines/tcomms/hub.dmi'
icon_state = "hub"
network_device_type = /datum/extension/network_device/trade_controller
main_template = "trade_controller.tmpl"
construct_state = /decl/machine_construction/default/panel_closed
uncreated_component_parts = null
base_type = /obj/machinery/network/trade_controller


/obj/machinery/network/trade_controller/OnTopic(mob/user, href_list, datum/topic_state/state)
. = ..()
if(.)
return
var/datum/extension/network_device/trade_controller/D = get_extension(src, /datum/extension/network_device)
var/datum/computer_network/network = D.get_network()
if(!network || network.trade_controller != D)
error = "NETWORK ERROR: Connection lost. Another trade controller may be active on the network."
return TOPIC_REFRESH

if(href_list["connect_beacon"])
var/list/possible_trade_beacons = get_adjacent_trade_beacons()
possible_trade_beacons += "*DISCONNECT*"
var/selected_beacon = input(usr, "Select a nearby trade beacon.", "Pick a beacon") as null|anything in possible_trade_beacons
if(!CanInteract(user, global.default_topic_state) || !selected_beacon)
return TOPIC_REFRESH
if(selected_beacon == "*DISCONNECT*")
D.Unlink()
else
var/obj/effect/overmap/trade_beacon/a = selected_beacon
if(a.linked_controller)
to_chat(user, SPAN_NOTICE("This beacon is already connected to a trade control device. The existing trade control device must be removed first."))
return TOPIC_REFRESH
else
a.linked_controller = D
D.linked_beacon = a
return TOPIC_REFRESH

if(href_list["toggle_beacon_restrict"])
D.toggle_beacon_restrict()
return TOPIC_REFRESH
if(href_list["select_beacon_access"])
D.select_beacon_access(usr, src)
return TOPIC_REFRESH
if(href_list["change_import_tax"])
D.select_import_tax(usr, src)
return TOPIC_REFRESH
if(href_list["change_export_tax"])
D.select_export_tax(usr, src)
return TOPIC_REFRESH
if(href_list["toggle_log_restrict"])
D.toggle_log_restrict()
return TOPIC_REFRESH

if(href_list["info"])
switch(href_list["info"])
if("connect_beacon")
to_chat(user, SPAN_NOTICE("The Trade Controller can take control of trade beacons that you are within 1 tile of in space. A beacon can only be controlled by one Trade Controller, and will remaiin controlled until that controller is brought offline."))
if("restrict_beacon_access")
to_chat(user, SPAN_NOTICE("If Beacon restriction is turned on, only devices connected to this network and with the appropriate access will be able to use the beacon for imports, exports or viewing the transaction log."))
if("select_beacon_access")
to_chat(user, SPAN_NOTICE("You can set this access to any group in the network, in which case it will be required to access the Import/Export/Log functions for the beacon. If this is unset any device on this network will be able to access the beacon."))
if("import_tax")
to_chat(user, SPAN_NOTICE("This is a percentage added to the cost of all imports done, except those done by the primary money account on this network. The added percentage will be deposited into the primary money account."))
if("export_tax")
to_chat(user, SPAN_NOTICE("This is a percentage taken from the revenue of all exports done, except those done by the primary money account on this network. The added percentage will be deposited into the primary money account."))
if("restrict_log_access")
to_chat(user, SPAN_NOTICE("If Transaction Log restriction is turned on, only devices connected to this network and with the appropriate access will be able to view the transaction log."))
if("select_log_access")
to_chat(user, SPAN_NOTICE("You can set this access to any group in the network, in which case it will be required to access the Log functions for the beacon. If this is unset any device on this network will be able to access the transaction log."))

/obj/machinery/network/trade_controller/ui_data(mob/user, ui_key)
. = ..()

if(error)
.["error"] = error
return

var/datum/extension/network_device/trade_controller/D = get_extension(src, /datum/extension/network_device)
if(!D.get_network())
.["connected"] = FALSE
return
.["connected"] = TRUE
if(D.linked_beacon)
.["connected_beacon"] = D.linked_beacon.name
.["valid_beacon"] = TRUE
.["beacon_restrict"] = D.beacon_restrict
if(D.beacon_restrict)
if(D.access)
.["selected_beacon_access"] = D.access
else
.["selected_beacon_access"] = "*NONE*"
.["import_tax"] = D.import_tax
.["export_tax"] = D.export_tax
.["log_restrict"] = D.log_restrict
if(D.log_restrict)
if(D.log_access)
.["selected_log_access"] = D.log_access
else
.["selected_log_access"] = "*NONE*"
else
.["connected_beacon"] = "*DISCONNECTED*"
Binary file added icons/obj/machines/telepad.dmi
Binary file not shown.
1 change: 1 addition & 0 deletions mods/persistence/_persistence.dme
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
#include "modules\modular_computers\file_system\directory.dm"
#include "modules\modular_computers\file_system\programs\cloning.dm"
#include "modules\modular_computers\file_system\programs\rent_management.dm"
#include "modules\modular_computers\file_system\programs\trade_beacon_program.dm"
#include "modules\modular_computers\file_system\reports\crew_record.dm"
#include "modules\modular_computers\file_system\reports\report.dm"
#include "modules\modular_computers\hardware\battery_module.dm"
Expand Down
28 changes: 28 additions & 0 deletions mods/persistence/controllers/subsystems/trade_beacons.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
SUBSYSTEM_DEF(trade_beacons)
name = "Trade Beacons"
wait = 5 MINUTES
priority = SS_PRIORITY_MONEY_ACCOUNTS
var/list/all_trade_beacons = list()
var/list/wanted_trade_beacons = list(/obj/effect/overmap/trade_beacon/test_beacon, /obj/effect/overmap/trade_beacon/test_beacon2) // list(//obj/effect/overmap/trade_beacon/example, /obj/effect/overmap/trade_beacon/steel, /obj/effect/overmap/trade_beacon/xandahar)
var/last_cycle = 0

/datum/controller/subsystem/trade_beacons/Destroy()
QDEL_NULL_LIST(all_trade_beacons)
. = ..()

/datum/controller/subsystem/trade_beacons/Initialize()
all_trade_beacons = list()
#ifndef UNIT_TEST
for(var/x in wanted_trade_beacons)
var/obj/effect/overmap/trade_beacon/beacon = new x()
all_trade_beacons |= beacon
#endif
. = ..()

/datum/controller/subsystem/trade_beacons/fire(resumed = FALSE)
if(REALTIMEOFDAY >= (last_cycle + 2 HOURS))
last_cycle = REALTIMEOFDAY
for(var/obj/effect/overmap/trade_beacon/x in all_trade_beacons)
x.regenerate_imports()
x.regenerate_exports()
return
Loading