forked from Aurorastation/Aurora.3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from NonQueueingMatt/love_symptom_of_the_cure
Bringing the RUST in
- Loading branch information
Showing
87 changed files
with
3,676 additions
and
508 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/datum/component/local_network_member | ||
var/id_tag | ||
|
||
/datum/component/local_network_member/Destroy() | ||
if(parent) | ||
var/datum/local_network/lan = get_local_network() | ||
if(lan) | ||
lan.remove_device(parent) | ||
. = ..() | ||
|
||
/datum/component/local_network_member/Initialize(initial_id_tag) | ||
if(initial_id_tag) | ||
set_tag(null, initial_id_tag) | ||
|
||
/datum/component/local_network_member/proc/set_tag(mob/user, new_ident) | ||
if(id_tag == new_ident) | ||
to_chat(user, SPAN_WARNING("\The [parent] is already part of the [new_ident] local network.")) | ||
return FALSE | ||
|
||
if(id_tag) | ||
var/datum/local_network/old_lan = local_networks[id_tag] | ||
if(old_lan) | ||
if(!old_lan.remove_device(parent)) | ||
to_chat(user, SPAN_WARNING("You encounter an error when trying to unregister \the [parent] from the [id_tag] local network.")) | ||
return FALSE | ||
to_chat(user, SPAN_NOTICE("You unregister \the [parent] from the [id_tag] local network.")) | ||
|
||
var/datum/local_network/lan = local_networks[new_ident] | ||
if(!lan) | ||
lan = new(new_ident) | ||
lan.add_device(parent) | ||
to_chat(user, SPAN_NOTICE("You create a new [new_ident] local network and register \the [parent] with it.")) | ||
else if(lan.within_radius(parent)) | ||
lan.add_device(parent) | ||
to_chat(user, SPAN_NOTICE("You register \the [parent] with the [new_ident] local network.")) | ||
else | ||
to_chat(user, SPAN_WARNING("\The [parent] is out of range of the [new_ident] local network.")) | ||
return FALSE | ||
id_tag = new_ident | ||
return TRUE | ||
|
||
/datum/component/local_network_member/proc/get_local_network() | ||
var/datum/local_network/lan = id_tag ? local_networks[id_tag] : null | ||
if(lan && !lan.within_radius(parent)) | ||
lan.remove_device(parent) | ||
id_tag = null | ||
lan = null | ||
return lan | ||
|
||
/datum/component/local_network_member/nano_host() | ||
if(parent) | ||
return parent.nano_host() | ||
. = ..() | ||
|
||
/datum/component/local_network_member/proc/get_new_tag(mob/user) | ||
var/new_ident = input(user, "Enter a new ident tag.", "[parent]", id_tag) as null|text | ||
if(new_ident && parent && user.Adjacent(parent) && CanInteract(user, physical_state)) | ||
return set_tag(user, new_ident) | ||
|
||
// | ||
|
||
/datum/component/local_network_member/multilevel/set_tag(mob/user, new_ident) | ||
if(id_tag == new_ident) | ||
to_chat(user, SPAN_WARNING("\The [parent] is already part of the [new_ident] local network.")) | ||
return FALSE | ||
|
||
if(id_tag) | ||
var/datum/local_network/multilevel/old_lan = multilevel_local_networks[id_tag] | ||
if(old_lan) | ||
if(!old_lan.remove_device(parent)) | ||
to_chat(user, SPAN_WARNING("You encounter an error when trying to unregister \the [parent] from the [id_tag] local network.")) | ||
return FALSE | ||
to_chat(user, SPAN_NOTICE("You unregister \the [parent] from the [id_tag] local network.")) | ||
|
||
var/datum/local_network/multilevel/lan = multilevel_local_networks[new_ident] | ||
if(!lan) | ||
lan = new(new_ident) | ||
lan.add_device(parent) | ||
to_chat(user, SPAN_NOTICE("You create a new [new_ident] local network and register \the [parent] with it.")) | ||
else if(lan.within_radius(parent)) | ||
lan.add_device(parent) | ||
to_chat(user, SPAN_NOTICE("You register \the [parent] with the [new_ident] local network.")) | ||
else | ||
to_chat(user, SPAN_WARNING("\The [parent] is out of range of the [new_ident] local network.")) | ||
return FALSE | ||
id_tag = new_ident | ||
return TRUE | ||
|
||
/datum/component/local_network_member/multilevel/get_local_network() | ||
var/datum/local_network/multilevel/lan = id_tag ? multilevel_local_networks[id_tag] : null | ||
if(lan && !lan.within_radius(parent)) | ||
lan.remove_device(parent) | ||
id_tag = null | ||
lan = null | ||
return lan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
var/global/list/local_networks = list() | ||
|
||
/datum/local_network | ||
var/id_tag | ||
var/list/network_entities = list() | ||
var/const/network_size = 25 // Distance in tiles network objects can be from each other. | ||
|
||
/datum/local_network/New(_id) | ||
id_tag = _id | ||
local_networks[id_tag] = src | ||
|
||
/datum/local_network/Destroy() | ||
network_entities.Cut() | ||
local_networks -= src | ||
. = ..() | ||
|
||
/datum/local_network/proc/within_radius(atom/checking) | ||
for(var/entity_list in network_entities) | ||
for(var/entity in entity_list) | ||
if(get_dist(entity, checking) > network_size) | ||
return FALSE | ||
return TRUE | ||
|
||
/datum/local_network/proc/add_device(obj/machinery/device) | ||
var/list/entities = get_devices(device.type) | ||
|
||
if(!entities) | ||
entities = list() | ||
network_entities[device.type] = entities | ||
|
||
entities[device] = TRUE | ||
|
||
return entities[device] | ||
|
||
/datum/local_network/proc/remove_device(obj/machinery/device) | ||
var/list/entities = get_devices(device.type) | ||
if(!entities) | ||
return TRUE | ||
|
||
entities -= device | ||
if(length(entities) <= 0) | ||
network_entities -= device.type | ||
if(length(network_entities) <= 0) | ||
qdel(src) | ||
return isnull(entities[device]) | ||
|
||
/datum/local_network/proc/is_connected(obj/machinery/device) | ||
var/list/entities = get_devices(device.type) | ||
|
||
if(!entities) | ||
return FALSE | ||
return !isnull(entities[device]) | ||
|
||
/datum/local_network/proc/get_devices(device_type) | ||
for(var/entity_type in network_entities) | ||
if(ispath(entity_type, device_type)) | ||
return network_entities[entity_type] | ||
|
||
|
||
//Multilevel network | ||
var/global/list/multilevel_local_networks = list() | ||
|
||
/datum/local_network/multilevel/New(_id) | ||
id_tag = _id | ||
multilevel_local_networks[id_tag] = src | ||
|
||
/datum/local_network/multilevel/Destroy() | ||
network_entities.Cut() | ||
multilevel_local_networks -= src | ||
. = ..() | ||
|
||
/datum/local_network/multilevel/within_radius(atom/checking) | ||
for(var/entity_list in network_entities) | ||
for(var/atom/entity in entity_list) | ||
if(!(GET_Z(entity) in GetConnectedZlevels(GET_Z(checking)))) | ||
return FALSE | ||
return TRUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.