diff --git a/.editorconfig b/.editorconfig
index 8d9bbba74..700d4f9ae 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,132 +1,164 @@
-# Remove the line below if you want to inherit .editorconfig settings from higher directories
+# EditorConfig is awesome: https://EditorConfig.org
+
+# top-most EditorConfig file
root = true
+# Don't use tabs for indentation.
[*]
indent_style = space
+# (Please don't specify an indent_size here; that has too many unintended consequences.)
+spelling_exclusion_path =
+SpellingExclusions.dic
-# C# files
-[*.cs]
+# Code files
+[*.{cs,csx,vb,vbx}]
+indent_size = 4
+insert_final_newline = true
+charset = utf-8-bom
-#### Core EditorConfig Options ####
+# XML project files
+[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
+indent_size = 2
-# Indentation and spacing
-indent_size = 4
-tab_width = 4
+# XML config files
+[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
+indent_size = 2
+
+# JSON files
+[*.json]
+indent_size = 2
+
+# Powershell files
+[*.ps1]
+indent_size = 2
-# New line preferences
-end_of_line = crlf
-insert_final_newline = false
+# Shell script files
+[*.sh]
+end_of_line = lf
+indent_size = 2
-#### .NET Coding Conventions ####
+# Dotnet code style settings:
+[*.{cs,vb}]
-# Organize usings
+# Sort using and Import directives with System.* appearing first
+dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false
-dotnet_sort_system_directives_first = false
-
-# this. and Me. preferences
-dotnet_style_qualification_for_event = false
-dotnet_style_qualification_for_field = false
-dotnet_style_qualification_for_method = false
-dotnet_style_qualification_for_property = false
-
-# Language keywords vs BCL types preferences
-dotnet_style_predefined_type_for_locals_parameters_members = true
-dotnet_style_predefined_type_for_member_access = true
-
-# Parentheses preferences
-dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity
-dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
-dotnet_style_parentheses_in_other_operators = never_if_unnecessary
-dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
-
-# Modifier preferences
-dotnet_style_require_accessibility_modifiers = for_non_interface_members
-
-# Expression-level preferences
-dotnet_style_coalesce_expression = true
-dotnet_style_collection_initializer = true
-dotnet_style_explicit_tuple_names = true
-dotnet_style_null_propagation = true
-dotnet_style_object_initializer = true
-dotnet_style_operator_placement_when_wrapping = beginning_of_line
-dotnet_style_prefer_auto_properties = true
-dotnet_style_prefer_compound_assignment = true
-dotnet_style_prefer_conditional_expression_over_assignment = true
-dotnet_style_prefer_conditional_expression_over_return = true
-dotnet_style_prefer_inferred_anonymous_type_member_names = true
-dotnet_style_prefer_inferred_tuple_names = true
-dotnet_style_prefer_is_null_check_over_reference_equality_method = true
-dotnet_style_prefer_simplified_boolean_expressions = true
-dotnet_style_prefer_simplified_interpolation = true
-
-# Field preferences
-dotnet_style_readonly_field = true
-
-# Parameter preferences
-dotnet_code_quality_unused_parameters = all
-
-# Suppression preferences
-dotnet_remove_unnecessary_suppression_exclusions = none
-
-#### C# Coding Conventions ####
-
-# var preferences
-csharp_style_var_elsewhere = false
-csharp_style_var_for_built_in_types = false
-csharp_style_var_when_type_is_apparent = false
-
-# Expression-bodied members
-csharp_style_expression_bodied_accessors = true
-csharp_style_expression_bodied_constructors = false
-csharp_style_expression_bodied_indexers = true
-csharp_style_expression_bodied_lambdas = true
-csharp_style_expression_bodied_local_functions = false
-csharp_style_expression_bodied_methods = false
-csharp_style_expression_bodied_operators = false
-csharp_style_expression_bodied_properties = true
-
-# Pattern matching preferences
-csharp_style_pattern_matching_over_as_with_null_check = true
-csharp_style_pattern_matching_over_is_with_cast_check = true
-csharp_style_prefer_not_pattern = true
-csharp_style_prefer_pattern_matching = true
-csharp_style_prefer_switch_expression = true
-
-# Null-checking preferences
-csharp_style_conditional_delegate_call = true
-
-# Modifier preferences
-csharp_prefer_static_local_function = true
-csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async
-
-# Code-block preferences
-csharp_prefer_braces = true
-csharp_prefer_simple_using_statement = true
-
-# Expression-level preferences
-csharp_prefer_simple_default_expression = true
-csharp_style_deconstructed_variable_declaration = true
-csharp_style_implicit_object_creation_when_type_is_apparent = true
-csharp_style_inlined_variable_declaration = true
-csharp_style_pattern_local_over_anonymous_function = true
-csharp_style_prefer_index_operator = true
-csharp_style_prefer_range_operator = true
-csharp_style_throw_expression = true
-csharp_style_unused_value_assignment_preference = discard_variable
-csharp_style_unused_value_expression_statement_preference = discard_variable
-
-# 'using' directive preferences
-csharp_using_directive_placement = outside_namespace
-
-#### C# Formatting Rules ####
-
-# New line preferences
-csharp_new_line_before_catch = true
+# Avoid "this." and "Me." if not necessary
+dotnet_style_qualification_for_field = false:refactoring
+dotnet_style_qualification_for_property = false:refactoring
+dotnet_style_qualification_for_method = false:refactoring
+dotnet_style_qualification_for_event = false:refactoring
+
+# Use language keywords instead of framework type names for type references
+dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
+dotnet_style_predefined_type_for_member_access = true:suggestion
+
+# Suggest more modern language features when available
+dotnet_style_object_initializer = true:suggestion
+dotnet_style_collection_initializer = true:suggestion
+dotnet_style_coalesce_expression = true:suggestion
+dotnet_style_null_propagation = true:suggestion
+dotnet_style_explicit_tuple_names = true:suggestion
+
+# Whitespace options
+dotnet_style_allow_multiple_blank_lines_experimental = false
+
+# Non-private static fields are PascalCase
+dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.severity = suggestion
+dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.symbols = non_private_static_fields
+dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.style = non_private_static_field_style
+
+dotnet_naming_symbols.non_private_static_fields.applicable_kinds = field
+dotnet_naming_symbols.non_private_static_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected
+dotnet_naming_symbols.non_private_static_fields.required_modifiers = static
+
+dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case
+
+# Non-private readonly fields are PascalCase
+dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.severity = suggestion
+dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields
+dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = non_private_readonly_field_style
+
+dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field
+dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected
+dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly
+
+dotnet_naming_style.non_private_readonly_field_style.capitalization = pascal_case
+
+# Constants are PascalCase
+dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion
+dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants
+dotnet_naming_rule.constants_should_be_pascal_case.style = constant_style
+
+dotnet_naming_symbols.constants.applicable_kinds = field, local
+dotnet_naming_symbols.constants.required_modifiers = const
+
+dotnet_naming_style.constant_style.capitalization = pascal_case
+
+# Static fields are camelCase and start with s_
+dotnet_naming_rule.static_fields_should_be_camel_case.severity = suggestion
+dotnet_naming_rule.static_fields_should_be_camel_case.symbols = static_fields
+dotnet_naming_rule.static_fields_should_be_camel_case.style = static_field_style
+
+dotnet_naming_symbols.static_fields.applicable_kinds = field
+dotnet_naming_symbols.static_fields.required_modifiers = static
+
+dotnet_naming_style.static_field_style.capitalization = camel_case
+dotnet_naming_style.static_field_style.required_prefix = s_
+
+# Instance fields are camelCase and start with _
+dotnet_naming_rule.instance_fields_should_be_camel_case.severity = suggestion
+dotnet_naming_rule.instance_fields_should_be_camel_case.symbols = instance_fields
+dotnet_naming_rule.instance_fields_should_be_camel_case.style = instance_field_style
+
+dotnet_naming_symbols.instance_fields.applicable_kinds = field
+
+dotnet_naming_style.instance_field_style.capitalization = camel_case
+dotnet_naming_style.instance_field_style.required_prefix = _
+
+# Locals and parameters are camelCase
+dotnet_naming_rule.locals_should_be_camel_case.severity = suggestion
+dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters
+dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style
+
+dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local
+
+dotnet_naming_style.camel_case_style.capitalization = camel_case
+
+# Local functions are PascalCase
+dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion
+dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions
+dotnet_naming_rule.local_functions_should_be_pascal_case.style = local_function_style
+
+dotnet_naming_symbols.local_functions.applicable_kinds = local_function
+
+dotnet_naming_style.local_function_style.capitalization = pascal_case
+
+# By default, name items with PascalCase
+dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion
+dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members
+dotnet_naming_rule.members_should_be_pascal_case.style = pascal_case_style
+
+dotnet_naming_symbols.all_members.applicable_kinds = *
+
+dotnet_naming_style.pascal_case_style.capitalization = pascal_case
+
+# RS0016: Only enable if API files are present
+dotnet_public_api_analyzer.require_api_files = true
+
+# IDE0055: Fix formatting
+# Workaround for https://github.com/dotnet/roslyn/issues/70570
+dotnet_diagnostic.IDE0055.severity = warning
+
+# CSharp code style settings:
+[*.cs]
+# Newline settings
+csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
+csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
-csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_before_members_in_object_initializers = true
-csharp_new_line_before_open_brace = all
+csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true
# Indentation preferences
@@ -134,8 +166,38 @@ csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = true
-csharp_indent_labels = no_change
csharp_indent_switch_labels = true
+csharp_indent_labels = flush_left
+
+# Whitespace options
+csharp_style_allow_embedded_statements_on_same_line_experimental = false
+csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false
+csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false
+csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = false
+csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = false
+
+# Prefer "var" everywhere
+csharp_style_var_for_built_in_types = true:suggestion
+csharp_style_var_when_type_is_apparent = true:suggestion
+csharp_style_var_elsewhere = true:suggestion
+
+# Prefer method-like constructs to have a block body
+csharp_style_expression_bodied_methods = false:none
+csharp_style_expression_bodied_constructors = false:none
+csharp_style_expression_bodied_operators = false:none
+
+# Prefer property-like constructs to have an expression-body
+csharp_style_expression_bodied_properties = true:none
+csharp_style_expression_bodied_indexers = true:none
+csharp_style_expression_bodied_accessors = true:none
+
+# Suggest more modern language features when available
+csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
+csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
+csharp_style_inlined_variable_declaration = true:suggestion
+csharp_style_throw_expression = true:suggestion
+csharp_style_conditional_delegate_call = true:suggestion
+csharp_style_prefer_extended_property_pattern = true:suggestion
# Space preferences
csharp_space_after_cast = false
@@ -145,7 +207,7 @@ csharp_space_after_dot = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_after_semicolon_in_for_statement = true
csharp_space_around_binary_operators = before_and_after
-csharp_space_around_declaration_statements = false
+csharp_space_around_declaration_statements = do_not_ignore
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_before_comma = false
csharp_space_before_dot = false
@@ -161,49 +223,63 @@ csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false
-# Wrapping preferences
+# Blocks are allowed
+csharp_prefer_braces = true:silent
csharp_preserve_single_line_blocks = true
csharp_preserve_single_line_statements = true
-#### Naming styles ####
+# IDE0060: Remove unused parameter
+dotnet_diagnostic.IDE0060.severity = warning
+
+[src/{Compilers,ExpressionEvaluator,Scripting}/**Test**/*.{cs,vb}]
+
+# IDE0060: Remove unused parameter
+dotnet_diagnostic.IDE0060.severity = none
+
+[src/{Analyzers,CodeStyle,Features,Workspaces,EditorFeatures,VisualStudio}/**/*.{cs,vb}]
-# Naming rules
+# IDE0011: Add braces
+csharp_prefer_braces = when_multiline:warning
+# NOTE: We need the below severity entry for Add Braces due to https://github.com/dotnet/roslyn/issues/44201
+dotnet_diagnostic.IDE0011.severity = warning
-dotnet_naming_rule.interface_should_be_begins_with_i.severity = warning
-dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
-dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
+# IDE0040: Add accessibility modifiers
+dotnet_diagnostic.IDE0040.severity = warning
-dotnet_naming_rule.types_should_be_pascal_case.severity = warning
-dotnet_naming_rule.types_should_be_pascal_case.symbols = types
-dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
+# IDE0052: Remove unread private member
+dotnet_diagnostic.IDE0052.severity = warning
-dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = warning
-dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
-dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
+# IDE0059: Unnecessary assignment to a value
+dotnet_diagnostic.IDE0059.severity = warning
-dotnet_naming_rule.non_private_field_members_should_be_pascal_case.severity = warning
-dotnet_naming_rule.non_private_field_members_should_be_pascal_case.symbols = non_private_field_members
-dotnet_naming_rule.non_private_field_members_should_be_pascal_case.style = pascal_case
+# CA1012: Abstract types should not have public constructors
+dotnet_diagnostic.CA1012.severity = warning
-# Symbol specifications
+# CA1822: Make member static
+dotnet_diagnostic.CA1822.severity = warning
-dotnet_naming_symbols.interface.applicable_kinds = interface
-dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
-dotnet_naming_symbols.interface.required_modifiers =
+# Prefer "var" everywhere
+dotnet_diagnostic.IDE0007.severity = warning
+csharp_style_var_for_built_in_types = true:warning
+csharp_style_var_when_type_is_apparent = true:warning
+csharp_style_var_elsewhere = true:warning
-dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
-dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
-dotnet_naming_symbols.types.required_modifiers =
+# csharp_style_allow_embedded_statements_on_same_line_experimental
+dotnet_diagnostic.IDE2001.severity = warning
-dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
-dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
+# csharp_style_allow_blank_lines_between_consecutive_braces_experimental
+dotnet_diagnostic.IDE2002.severity = warning
-dotnet_naming_symbols.non_private_field_members.applicable_kinds = field
-dotnet_naming_symbols.non_private_field_members.applicable_accessibilities = public, internal, protected, protected_internal, private_protected
+# csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental
+dotnet_diagnostic.IDE2004.severity = warning
-# Naming styles
+# csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental
+dotnet_diagnostic.IDE2005.severity = warning
-dotnet_naming_style.pascal_case.capitalization = pascal_case
+# csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental
+dotnet_diagnostic.IDE2006.severity = warning
-dotnet_naming_style.begins_with_i.required_prefix = I
-dotnet_naming_style.begins_with_i.capitalization = pascal_case
\ No newline at end of file
+[src/{VisualStudio}/**/*.{cs,vb}]
+# CA1822: Make member static
+# There is a risk of accidentally breaking an internal API that partners rely on though IVT.
+dotnet_code_quality.CA1822.api_surface = private
diff --git a/.github/workflows/build-winx64.yml b/.github/workflows/build-winx64.yml
index 7123a5b50..57b8c2f98 100644
--- a/.github/workflows/build-winx64.yml
+++ b/.github/workflows/build-winx64.yml
@@ -19,7 +19,7 @@ jobs:
steps:
- name: Checkout
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0 # can't shallowly clone due to git versioning
@@ -33,9 +33,9 @@ jobs:
# Add dotnet to the PATH: https://github.com/actions/setup-dotnet
- name: Setup dotnet.exe
- uses: actions/setup-dotnet@v1
+ uses: actions/setup-dotnet@v4
with:
- dotnet-version: "6.0.x"
+ dotnet-version: "8.0.x"
# Build it
- name: Build the application
@@ -43,7 +43,7 @@ jobs:
# Upload it to the run results
- name: Upload a Build Artifact
- uses: actions/upload-artifact@v2.2.4
+ uses: actions/upload-artifact@v4
with:
# Artifact name
name: build-artifacts-${{ matrix.configuration }}
diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml
index 72cc10944..832c63593 100644
--- a/.github/workflows/publish-release.yml
+++ b/.github/workflows/publish-release.yml
@@ -13,7 +13,7 @@ jobs:
steps:
- name: Checkout
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0 # can't shallowly clone due to git versioning
@@ -23,7 +23,7 @@ jobs:
git remote set-url origin https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
- name: Setup Node.js
- uses: actions/setup-node@v2
+ uses: actions/setup-node@v4
with:
node-version: "14"
@@ -33,7 +33,7 @@ jobs:
echo "::set-output name=dir::$(npm config get cache)"
- name: Cache dependencies
- uses: actions/cache@v2
+ uses: actions/cache@v3
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: npm-${{ hashFiles('package-lock.json') }}
@@ -51,9 +51,9 @@ jobs:
# Add dotnet to the PATH: https://github.com/actions/setup-dotnet
- name: Setup dotnet.exe
- uses: actions/setup-dotnet@v1
+ uses: actions/setup-dotnet@v4
with:
- dotnet-version: "6.0.x"
+ dotnet-version: "8.0.x"
# Build it
- name: Build the application
@@ -66,13 +66,13 @@ jobs:
run: node .github\scripts\thunderstore_bundle.js
# Upload the thunderstore artifact (in case automatic upload fails)
- - uses: actions/upload-artifact@v2.2.4
+ - uses: actions/upload-artifact@v4
with:
name: nebula-thunderstore
path: ${{ env.DIST_RELEASE_FOLDER }}nebula-NebulaMultiplayerMod
# Upload the API thunderstore artifact (in case automatic upload fails)
- - uses: actions/upload-artifact@v2.2.4
+ - uses: actions/upload-artifact@v4
with:
name: nebula-api-thunderstore
path: ${{ env.DIST_RELEASE_FOLDER }}nebula-NebulaMultiplayerModApi
diff --git a/Directory.Build.props b/Directory.Build.props
index 4ec01a6dd..40eebb5d9 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -1,61 +1,61 @@
-
- $(MSBuildThisFileDirectory)DevEnv.targets
-
-
-
-
-
-
- C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\
- $([MSBuild]::EnsureTrailingSlash('$(DSPGameDir)'))
- $(DSPGameDir)BepInEx\plugins\nebula-NebulaMultiplayerMod\
- $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)'))
- $(PropSheetPath)dist\release\nebula-NebulaMultiplayerMod\
-
-
-
- false
- false
- true
-
- $(PluginOutputDirectory)
- net472
- latest
- true
- true
- $(DefaultItemExcludes);*.binlog
-
- portable
- true
- $(MSBuildThisFileDirectory)
-
-
-
- $(OutputPath)..\nebula-NebulaMultiplayerModApi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+ $(MSBuildThisFileDirectory)DevEnv.targets
+
+
+
+
+
+
+ C:\Program Files (x86)\Steam\steamapps\common\Dyson Sphere Program\
+ $([MSBuild]::EnsureTrailingSlash('$(DSPGameDir)'))
+ $(DSPGameDir)BepInEx\plugins\nebula-NebulaMultiplayerMod\
+ $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)'))
+ $(PropSheetPath)dist\release\nebula-NebulaMultiplayerMod\
+
+
+
+ false
+ false
+ true
+
+ $(PluginOutputDirectory)
+ net472
+ latest
+ true
+ true
+ $(DefaultItemExcludes);*.binlog
+
+ portable
+ true
+ $(MSBuildThisFileDirectory)
+
+
+
+ $(OutputPath)..\nebula-NebulaMultiplayerModApi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Directory.Build.targets b/Directory.Build.targets
index 1c8bb4c28..048dc696a 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -1,4 +1,4 @@
-
+
\ No newline at end of file
diff --git a/NebulaAPI/CHANGELOG.md b/NebulaAPI/CHANGELOG.md
index c6fb49364..3da32250e 100644
--- a/NebulaAPI/CHANGELOG.md
+++ b/NebulaAPI/CHANGELOG.md
@@ -35,7 +35,8 @@
1.1.0:
-- Float3 IPlayerData.MechaColor has been changed to Float4[] IPlayerData.MechaColors in line with changes introduced in DSP version 0.8.21.8562.
+- Float3 IPlayerData.MechaColor has been changed to Float4[] IPlayerData.MechaColors in line with changes introduced in
+ DSP version 0.8.21.8562.
- Edited description.
1.0.0:
diff --git a/NebulaAPI/DataStructures/CollectionExtensions.cs b/NebulaAPI/DataStructures/CollectionExtensions.cs
index 43fefafdd..64fee4831 100644
--- a/NebulaAPI/DataStructures/CollectionExtensions.cs
+++ b/NebulaAPI/DataStructures/CollectionExtensions.cs
@@ -1,37 +1,40 @@
-using System;
+#region
+
+using System;
using System.Collections;
using System.Threading;
-namespace NebulaAPI
+#endregion
+
+namespace NebulaAPI.DataStructures;
+
+public static class CollectionExtensions
{
- public static class CollectionExtensions
+ public static Locker Lock(this ICollection collection)
{
- public static Locker Lock(this ICollection collection)
- {
- return new Locker(collection.SyncRoot);
- }
-
- public static Locker GetLocked(this T collection, out T result) where T : ICollection
- {
- result = collection;
- return new Locker(collection.SyncRoot);
- }
+ return new Locker(collection.SyncRoot);
}
- public readonly struct Locker : IDisposable
+ public static Locker GetLocked(this T collection, out T result) where T : ICollection
{
- private readonly object lockObject;
+ result = collection;
+ return new Locker(collection.SyncRoot);
+ }
+}
- public Locker(object lockObject)
- {
- this.lockObject = lockObject;
+public readonly struct Locker : IDisposable
+{
+ private readonly object lockObject;
- Monitor.Enter(lockObject);
- }
+ public Locker(object lockObject)
+ {
+ this.lockObject = lockObject;
- public void Dispose()
- {
- Monitor.Exit(lockObject);
- }
+ Monitor.Enter(lockObject);
+ }
+
+ public void Dispose()
+ {
+ Monitor.Exit(lockObject);
}
}
diff --git a/NebulaAPI/DataStructures/DataStructureExtensions.cs b/NebulaAPI/DataStructures/DataStructureExtensions.cs
new file mode 100644
index 000000000..543da78a8
--- /dev/null
+++ b/NebulaAPI/DataStructures/DataStructureExtensions.cs
@@ -0,0 +1,35 @@
+#region
+
+using UnityEngine;
+
+#endregion
+
+namespace NebulaAPI.DataStructures;
+
+public static class DataStructureExtensions
+{
+ public static Vector3 ToVector3(this Float3 value)
+ {
+ return new Vector3(value.x, value.y, value.z);
+ }
+
+ public static VectorLF3 ToVectorLF3(this Double3 value)
+ {
+ return new VectorLF3(value.x, value.y, value.z);
+ }
+
+ public static Float3 ToFloat3(this Vector3 value)
+ {
+ return new Float3(value.x, value.y, value.z);
+ }
+
+ public static Quaternion ToQuaternion(this Float4 value)
+ {
+ return new Quaternion(value.x, value.y, value.z, value.w);
+ }
+
+ public static Float4 ToFloat4(this Quaternion value)
+ {
+ return new Float4(value.x, value.y, value.z, value.w);
+ }
+}
diff --git a/NebulaAPI/DataStructures/DataStructureExtenstions.cs b/NebulaAPI/DataStructures/DataStructureExtenstions.cs
deleted file mode 100644
index 9d8d5c7e1..000000000
--- a/NebulaAPI/DataStructures/DataStructureExtenstions.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using UnityEngine;
-
-namespace NebulaAPI
-{
- public static class DataStructureExtenstions
- {
- public static Vector3 ToVector3(this Float3 value)
- {
- return new Vector3(value.x, value.y, value.z);
- }
-
- public static VectorLF3 ToVectorLF3(this Double3 value)
- {
- return new VectorLF3(value.x, value.y, value.z);
- }
-
- public static Float3 ToFloat3(this Vector3 value)
- {
- return new Float3(value.x, value.y, value.z);
- }
-
- public static Quaternion ToQuaternion(this Float4 value)
- {
- return new Quaternion(value.x, value.y, value.z, value.w);
- }
-
- public static Float4 ToFloat4(this Quaternion value)
- {
- return new Float4(value.x, value.y, value.z, value.w);
- }
- }
-}
\ No newline at end of file
diff --git a/NebulaAPI/DataStructures/Double3.cs b/NebulaAPI/DataStructures/Double3.cs
index 7706ece86..12ae62458 100644
--- a/NebulaAPI/DataStructures/Double3.cs
+++ b/NebulaAPI/DataStructures/Double3.cs
@@ -1,38 +1,43 @@
-
-namespace NebulaAPI
+#region
+
+using NebulaAPI.Interfaces;
+using NebulaAPI.Packets;
+
+#endregion
+
+namespace NebulaAPI.DataStructures;
+
+[RegisterNestedType]
+public struct Double3 : INetSerializable
{
- [RegisterNestedType]
- public struct Double3 : INetSerializable
+ public double x;
+ public double y;
+ public double z;
+
+ public Double3(double x, double y, double z)
+ {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ public void Serialize(INetDataWriter writer)
+ {
+ writer.Put(x);
+ writer.Put(y);
+ writer.Put(z);
+ }
+
+ public void Deserialize(INetDataReader reader)
+ {
+ x = reader.GetDouble();
+ y = reader.GetDouble();
+ z = reader.GetDouble();
+ }
+
+
+ public override string ToString()
{
- public double x;
- public double y;
- public double z;
-
- public Double3(double x, double y, double z)
- {
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- public void Serialize(INetDataWriter writer)
- {
- writer.Put(x);
- writer.Put(y);
- writer.Put(z);
- }
-
- public void Deserialize(INetDataReader reader)
- {
- x = reader.GetDouble();
- y = reader.GetDouble();
- z = reader.GetDouble();
- }
-
-
- public override string ToString()
- {
- return $"x: {x}, y: {y}, z: {z}";
- }
+ return $"x: {x}, y: {y}, z: {z}";
}
}
diff --git a/NebulaAPI/DataStructures/Float3.cs b/NebulaAPI/DataStructures/Float3.cs
index 6a3abb723..7ab01a259 100644
--- a/NebulaAPI/DataStructures/Float3.cs
+++ b/NebulaAPI/DataStructures/Float3.cs
@@ -1,49 +1,55 @@
-using UnityEngine;
+#region
-namespace NebulaAPI
+using NebulaAPI.Interfaces;
+using NebulaAPI.Packets;
+using UnityEngine;
+
+#endregion
+
+namespace NebulaAPI.DataStructures;
+
+[RegisterNestedType]
+public struct Float3 : INetSerializable
{
- [RegisterNestedType]
- public struct Float3 : INetSerializable
+ public float x;
+ public float y;
+ public float z;
+
+ public Float3(float x, float y, float z)
+ {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ public Float3(Vector3 value)
+ {
+ x = value.x;
+ y = value.y;
+ z = value.z;
+ }
+
+ public Color ToColor()
+ {
+ return new Color(x, y, z);
+ }
+
+ public void Serialize(INetDataWriter writer)
+ {
+ writer.Put(x);
+ writer.Put(y);
+ writer.Put(z);
+ }
+
+ public void Deserialize(INetDataReader reader)
+ {
+ x = reader.GetFloat();
+ y = reader.GetFloat();
+ z = reader.GetFloat();
+ }
+
+ public override string ToString()
{
- public float x;
- public float y;
- public float z;
-
- public Float3(float x, float y, float z)
- {
- this.x = x;
- this.y = y;
- this.z = z;
- }
-
- public Float3(Vector3 value)
- {
- x = value.x;
- y = value.y;
- z = value.z;
- }
- public Color ToColor()
- {
- return new Color(x, y, z);
- }
-
- public void Serialize(INetDataWriter writer)
- {
- writer.Put(x);
- writer.Put(y);
- writer.Put(z);
- }
-
- public void Deserialize(INetDataReader reader)
- {
- x = reader.GetFloat();
- y = reader.GetFloat();
- z = reader.GetFloat();
- }
-
- public override string ToString()
- {
- return $"(x: {x}, y: {y}, z: {z})";
- }
+ return $"(x: {x}, y: {y}, z: {z})";
}
}
diff --git a/NebulaAPI/DataStructures/Float4.cs b/NebulaAPI/DataStructures/Float4.cs
index 8f9d865b2..e73e718fb 100644
--- a/NebulaAPI/DataStructures/Float4.cs
+++ b/NebulaAPI/DataStructures/Float4.cs
@@ -1,85 +1,91 @@
-using UnityEngine;
+#region
-namespace NebulaAPI
+using NebulaAPI.Interfaces;
+using NebulaAPI.Packets;
+using UnityEngine;
+
+#endregion
+
+namespace NebulaAPI.DataStructures;
+
+[RegisterNestedType]
+public struct Float4 : INetSerializable
{
- [RegisterNestedType]
- public struct Float4 : INetSerializable
+ public float x;
+ public float y;
+ public float z;
+ public float w;
+
+ public Float4(float x, float y, float z, float w)
{
- public float x;
- public float y;
- public float z;
- public float w;
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.w = w;
+ }
- public Float4(float x, float y, float z, float w)
- {
- this.x = x;
- this.y = y;
- this.z = z;
- this.w = w;
- }
+ public Float4(Quaternion value)
+ {
+ x = value.x;
+ y = value.y;
+ z = value.z;
+ w = value.w;
+ }
- public Float4(Quaternion value)
- {
- x = value.x;
- y = value.y;
- z = value.z;
- w = value.w;
- }
+ public Color ToColor()
+ {
+ return new Color(x, y, z, w);
+ }
- public Color ToColor()
- {
- return new Color(x, y, z, w);
- }
+ public Color32 ToColor32()
+ {
+ return new Color32((byte)x, (byte)y, (byte)z, (byte)w);
+ }
- public Color32 ToColor32()
+ public static Color32[] ToColor32(Float4[] float4s)
+ {
+ var color32s = new Color32[float4s.Length];
+ for (var i = 0; i < float4s.Length; i++)
{
- return new Color32((byte)x, (byte)y, (byte)z, (byte)w);
+ color32s[i] = float4s[i].ToColor32();
}
+ return color32s;
+ }
- public static Color32[] ToColor32(Float4[] float4s)
- {
- Color32[] color32s = new Color32[float4s.Length];
- for (int i = 0; i < float4s.Length; i++)
- {
- color32s[i] = float4s[i].ToColor32();
- }
- return color32s;
- }
- public static Float4 ToFloat4(Color32 color32)
- {
- return new Float4(color32.r, color32.g, color32.b, color32.a);
- }
+ public static Float4 ToFloat4(Color32 color32)
+ {
+ return new Float4(color32.r, color32.g, color32.b, color32.a);
+ }
- public static Float4[] ToFloat4(Color32[] color32s)
+ public static Float4[] ToFloat4(Color32[] color32s)
+ {
+ var float4s = new Float4[color32s.Length];
+ for (var i = 0; i < color32s.Length; i++)
{
- Float4[] float4s = new Float4[color32s.Length];
- for (int i = 0; i < color32s.Length; i++)
- {
- float4s[i] = new Float4(color32s[i].r, color32s[i].g, color32s[i].b, color32s[i].a);
- }
- return float4s;
+ float4s[i] = new Float4(color32s[i].r, color32s[i].g, color32s[i].b, color32s[i].a);
}
+ return float4s;
+ }
- public void Serialize(INetDataWriter writer)
- {
- writer.Put(x);
- writer.Put(y);
- writer.Put(z);
- writer.Put(w);
- }
+ public void Serialize(INetDataWriter writer)
+ {
+ writer.Put(x);
+ writer.Put(y);
+ writer.Put(z);
+ writer.Put(w);
+ }
- public void Deserialize(INetDataReader reader)
- {
- x = reader.GetFloat();
- y = reader.GetFloat();
- z = reader.GetFloat();
- w = reader.GetFloat();
- }
+ public void Deserialize(INetDataReader reader)
+ {
+ x = reader.GetFloat();
+ y = reader.GetFloat();
+ z = reader.GetFloat();
+ w = reader.GetFloat();
+ }
- public override string ToString()
- {
- return $"x: {x}, y: {y}, z: {z}, w: {w}";
- }
+ public override string ToString()
+ {
+ return $"x: {x}, y: {y}, z: {z}, w: {w}";
}
}
diff --git a/NebulaAPI/DataStructures/IMechaData.cs b/NebulaAPI/DataStructures/IMechaData.cs
index aedf07cf1..7a21aed54 100644
--- a/NebulaAPI/DataStructures/IMechaData.cs
+++ b/NebulaAPI/DataStructures/IMechaData.cs
@@ -1,16 +1,19 @@
-// unset
+#region
-namespace NebulaAPI
+using NebulaAPI.Interfaces;
+
+#endregion
+
+namespace NebulaAPI.DataStructures;
+
+public interface IMechaData : INetSerializable
{
- public interface IMechaData : INetSerializable
- {
- int SandCount { get; set; }
- double CoreEnergy { get; set; }
- double ReactorEnergy { get; set; }
- StorageComponent Inventory { get; set; }
- DeliveryPackage DeliveryPackage { get; set; }
- StorageComponent ReactorStorage { get; set; }
- StorageComponent WarpStorage { get; set; }
- MechaForge Forge { get; set; }
- }
-}
\ No newline at end of file
+ int SandCount { get; set; }
+ double CoreEnergy { get; set; }
+ double ReactorEnergy { get; set; }
+ StorageComponent Inventory { get; set; }
+ DeliveryPackage DeliveryPackage { get; set; }
+ StorageComponent ReactorStorage { get; set; }
+ StorageComponent WarpStorage { get; set; }
+ MechaForge Forge { get; set; }
+}
diff --git a/NebulaAPI/DataStructures/IPlayerTechBonuses.cs b/NebulaAPI/DataStructures/IPlayerTechBonuses.cs
index 1fdae9053..18b3828f5 100644
--- a/NebulaAPI/DataStructures/IPlayerTechBonuses.cs
+++ b/NebulaAPI/DataStructures/IPlayerTechBonuses.cs
@@ -1,37 +1,40 @@
-// unset
+#region
-namespace NebulaAPI
+using NebulaAPI.Interfaces;
+
+#endregion
+
+namespace NebulaAPI.DataStructures;
+
+public interface IPlayerTechBonuses : INetSerializable
{
- public interface IPlayerTechBonuses : INetSerializable
- {
- double coreEnergyCap { get; }
- double corePowerGen { get; }
- double reactorPowerGen { get; }
- double walkPower { get; }
- double jumpEnergy { get; }
- double thrustPowerPerAcc { get; }
- double warpKeepingPowerPerSpeed { get; }
- double warpStartPowerPerSpeed { get; }
- double miningPower { get; }
- double replicatePower { get; }
- double researchPower { get; }
- double droneEjectEnergy { get; }
- double droneEnergyPerMeter { get; }
- int coreLevel { get; }
- int thrusterLevel { get; }
- float miningSpeed { get; }
- float replicateSpeed { get; }
- float walkSpeed { get; }
- float jumpSpeed { get; }
- float maxSailSpeed { get; }
- float maxWarpSpeed { get; }
- float buildArea { get; }
- int droneCount { get; }
- float droneSpeed { get; }
- int droneMovement { get; }
- int inventorySize { get; }
- bool deliveryPackageUnlocked { get; }
- int deliveryPackageColCount { get; set; }
- int deliveryPackageStackSizeMultiplier { get; }
- }
-}
\ No newline at end of file
+ double coreEnergyCap { get; set; }
+ double corePowerGen { get; set; }
+ double reactorPowerGen { get; set; }
+ double walkPower { get; set; }
+ double jumpEnergy { get; set; }
+ double thrustPowerPerAcc { get; set; }
+ double warpKeepingPowerPerSpeed { get; set; }
+ double warpStartPowerPerSpeed { get; set; }
+ double miningPower { get; set; }
+ double replicatePower { get; set; }
+ double researchPower { get; set; }
+ double droneEjectEnergy { get; set; }
+ double droneEnergyPerMeter { get; set; }
+ int coreLevel { get; set; }
+ int thrusterLevel { get; set; }
+ float miningSpeed { get; set; }
+ float replicateSpeed { get; set; }
+ float walkSpeed { get; set; }
+ float jumpSpeed { get; set; }
+ float maxSailSpeed { get; set; }
+ float maxWarpSpeed { get; set; }
+ float buildArea { get; set; }
+ int droneCount { get; set; }
+ float droneSpeed { get; set; }
+ int droneMovement { get; set; }
+ int inventorySize { get; set; }
+ bool deliveryPackageUnlocked { get; set; }
+ int deliveryPackageColCount { get; set; }
+ int deliveryPackageStackSizeMultiplier { get; set; }
+}
diff --git a/NebulaAPI/GameState/IFactoryManager.cs b/NebulaAPI/GameState/IFactoryManager.cs
index a977cf22b..63bba542a 100644
--- a/NebulaAPI/GameState/IFactoryManager.cs
+++ b/NebulaAPI/GameState/IFactoryManager.cs
@@ -1,47 +1,51 @@
-using System;
+#region
+
+using System;
+using NebulaAPI.Interfaces;
using UnityEngine;
-namespace NebulaAPI
+#endregion
+
+namespace NebulaAPI.GameState;
+
+///
+/// Represents data about factory
+///
+public interface IFactoryManager : IDisposable
{
///
- /// Represents data about factory
+ /// Did we receive a packet?
///
- public interface IFactoryManager : IDisposable
- {
- ///
- /// Did we receive a packet?
- ///
- IToggle IsIncomingRequest { get; }
+ IToggle IsIncomingRequest { get; }
- int PacketAuthor { get; set; }
+ int PacketAuthor { get; set; }
- int TargetPlanet { get; set; }
+ int TargetPlanet { get; set; }
- PlanetFactory EventFactory { get; set; }
+ PlanetFactory EventFactory { get; set; }
- ///
- /// Request to load planet
- ///
- void AddPlanetTimer(int planetId);
+ ///
+ /// Request to load planet
+ ///
+ void AddPlanetTimer(int planetId);
- void LoadPlanetData(int planetId);
+ void LoadPlanetData(int planetId);
- void UnloadPlanetData(int planetId);
+ void UnloadPlanetData(int planetId);
- void InitializePrebuildRequests();
+ void InitializePrebuildRequests();
- void SetPrebuildRequest(int planetId, int prebuildId, ushort playerId);
+ void SetPrebuildRequest(int planetId, int prebuildId, ushort playerId);
- bool RemovePrebuildRequest(int planetId, int prebuildId);
+ bool RemovePrebuildRequest(int planetId, int prebuildId);
- bool ContainsPrebuildRequest(int planetId, int prebuildId);
+ bool ContainsPrebuildRequest(int planetId, int prebuildId);
- int GetNextPrebuildId(int planetId);
+ int GetNextPrebuildId(int planetId);
- int GetNextPrebuildId(PlanetFactory factory);
+ int GetNextPrebuildId(PlanetFactory factory);
- void OnNewSetInserterPickTarget(int objId, int otherObjId, int inserterId, int offset, Vector3 pointPos);
+ void OnNewSetInserterPickTarget(int objId, int otherObjId, int inserterId, int offset, Vector3 pointPos);
- void OnNewSetInserterInsertTarget(int objId, int otherObjId, int inserterId, int offset, Vector3 pointPos);
- }
-}
\ No newline at end of file
+ void OnNewSetInserterInsertTarget(int objId, int otherObjId, int inserterId, int offset, Vector3 pointPos);
+}
diff --git a/NebulaAPI/GameState/ILocalPlayer.cs b/NebulaAPI/GameState/ILocalPlayer.cs
index 008d98459..a52eaa97d 100644
--- a/NebulaAPI/GameState/ILocalPlayer.cs
+++ b/NebulaAPI/GameState/ILocalPlayer.cs
@@ -1,17 +1,20 @@
-using System;
+#region
-namespace NebulaAPI
+using System;
+
+#endregion
+
+namespace NebulaAPI.GameState;
+
+///
+/// Represents local player. Allows to send packets.
+///
+public interface ILocalPlayer : IDisposable
{
- ///
- /// Represents local player. Allows to send packets.
- ///
- public interface ILocalPlayer : IDisposable
- {
- bool IsInitialDataReceived { get; }
- bool IsHost { get; }
- bool IsClient { get; }
- bool IsNewPlayer { get; }
- ushort Id { get; }
- IPlayerData Data { get; }
- }
-}
\ No newline at end of file
+ bool IsInitialDataReceived { get; set; }
+ bool IsHost { get; set; }
+ bool IsClient { get; }
+ bool IsNewPlayer { get; set; }
+ ushort Id { get; }
+ IPlayerData Data { get; set; }
+}
diff --git a/NebulaAPI/GameState/IMultiplayerSession.cs b/NebulaAPI/GameState/IMultiplayerSession.cs
index b66a55784..d92b381c5 100644
--- a/NebulaAPI/GameState/IMultiplayerSession.cs
+++ b/NebulaAPI/GameState/IMultiplayerSession.cs
@@ -1,11 +1,10 @@
-namespace NebulaAPI
+namespace NebulaAPI.GameState;
+
+public interface IMultiplayerSession
{
- public interface IMultiplayerSession
- {
- INetworkProvider Network { get; }
- ILocalPlayer LocalPlayer { get; }
- IFactoryManager Factories { get; }
+ INetworkProvider Network { get; set; }
+ ILocalPlayer LocalPlayer { get; set; }
+ IFactoryManager Factories { get; set; }
- bool IsGameLoaded { get; }
- }
-}
\ No newline at end of file
+ bool IsGameLoaded { get; set; }
+}
diff --git a/NebulaAPI/GameState/INebulaPlayer.cs b/NebulaAPI/GameState/INebulaPlayer.cs
index d7d89a25d..15dd4cddc 100644
--- a/NebulaAPI/GameState/INebulaPlayer.cs
+++ b/NebulaAPI/GameState/INebulaPlayer.cs
@@ -1,12 +1,18 @@
-namespace NebulaAPI
+#region
+
+using NebulaAPI.Packets;
+
+#endregion
+
+namespace NebulaAPI.GameState;
+
+public interface INebulaPlayer
{
- public interface INebulaPlayer
- {
- INebulaConnection Connection { get; }
- IPlayerData Data { get; }
- ushort Id { get; }
-
- void SendPacket(T packet) where T : class, new();
- void LoadUserData(IPlayerData data);
- }
-}
\ No newline at end of file
+ INebulaConnection Connection { get; set; }
+ IPlayerData Data { get; set; }
+ ushort Id { get; }
+
+ void SendPacket(T packet) where T : class, new();
+
+ void LoadUserData(IPlayerData data);
+}
diff --git a/NebulaAPI/GameState/INetworkProvider.cs b/NebulaAPI/GameState/INetworkProvider.cs
index 8ef1071dc..d1786cbdc 100644
--- a/NebulaAPI/GameState/INetworkProvider.cs
+++ b/NebulaAPI/GameState/INetworkProvider.cs
@@ -1,42 +1,50 @@
-using System;
+#region
-namespace NebulaAPI
+using System;
+using NebulaAPI.Packets;
+
+#endregion
+
+namespace NebulaAPI.GameState;
+
+public interface INetworkProvider : IDisposable
{
- public interface INetworkProvider : IDisposable
- {
- ///
- /// Send packet to Host (If ran on Client) or all Clients (If ran on Host)
- ///
- void SendPacket(T packet) where T : class, new();
- ///
- /// Broadcast packet to all Players within current star system
- ///
- void SendPacketToLocalStar(T packet) where T : class, new();
- ///
- /// Broadcast packet to all Players within current planet
- ///
- void SendPacketToLocalPlanet(T packet) where T : class, new();
-
- ///
- /// Send packet to all Clients on a planet
- ///
- void SendPacketToPlanet(T packet, int planetId) where T : class, new();
- ///
- /// Send packet to all Clients within star system
- ///
- void SendPacketToStar(T packet, int starId) where T : class, new();
-
- ///
- /// Send packet to all Clients except the excluded client
- ///
- void SendPacketExclude(T packet, INebulaConnection exclude) where T : class, new();
- ///
- /// Send packet to all Clients within star system except the excluded client
- ///
- void SendPacketToStarExclude(T packet, int starId, INebulaConnection exclude) where T : class, new();
-
- IPlayerManager PlayerManager { get; }
-
- void Update();
- }
-}
\ No newline at end of file
+ IPlayerManager PlayerManager { get; set; }
+
+ ///
+ /// Send packet to Host (If ran on Client) or all Clients (If ran on Host)
+ ///
+ void SendPacket(T packet) where T : class, new();
+
+ ///
+ /// Broadcast packet to all Players within current star system
+ ///
+ void SendPacketToLocalStar(T packet) where T : class, new();
+
+ ///
+ /// Broadcast packet to all Players within current planet
+ ///
+ void SendPacketToLocalPlanet(T packet) where T : class, new();
+
+ ///
+ /// Send packet to all Clients on a planet
+ ///
+ void SendPacketToPlanet(T packet, int planetId) where T : class, new();
+
+ ///
+ /// Send packet to all Clients within star system
+ ///
+ void SendPacketToStar(T packet, int starId) where T : class, new();
+
+ ///
+ /// Send packet to all Clients except the excluded client
+ ///
+ void SendPacketExclude(T packet, INebulaConnection exclude) where T : class, new();
+
+ ///
+ /// Send packet to all Clients within star system except the excluded client
+ ///
+ void SendPacketToStarExclude(T packet, int starId, INebulaConnection exclude) where T : class, new();
+
+ void Update();
+}
diff --git a/NebulaAPI/GameState/IPlayerData.cs b/NebulaAPI/GameState/IPlayerData.cs
index 8b81b5186..07e2359af 100644
--- a/NebulaAPI/GameState/IPlayerData.cs
+++ b/NebulaAPI/GameState/IPlayerData.cs
@@ -1,22 +1,28 @@
-namespace NebulaAPI
+#region
+
+using NebulaAPI.DataStructures;
+using NebulaAPI.Interfaces;
+
+#endregion
+
+namespace NebulaAPI.GameState;
+
+public interface IPlayerData : INetSerializable
{
- public interface IPlayerData : INetSerializable
- {
- string Username { get; set; }
- ushort PlayerId { get; set; }
- int LocalPlanetId { get; set; }
- Float3 LocalPlanetPosition { get; set; }
- Double3 UPosition { get; set; }
- Float3 Rotation { get; set; }
- Float3 BodyRotation { get; set; }
- int LocalStarId { get; set; }
+ string Username { get; set; }
+ ushort PlayerId { get; set; }
+ int LocalPlanetId { get; set; }
+ Float3 LocalPlanetPosition { get; set; }
+ Double3 UPosition { get; set; }
+ Float3 Rotation { get; set; }
+ Float3 BodyRotation { get; set; }
+ int LocalStarId { get; set; }
- IMechaData Mecha { get; set; }
- MechaAppearance Appearance { get; set; }
- MechaAppearance DIYAppearance { get; set; }
- int[] DIYItemId { get; set; }
- int[] DIYItemValue { get; set; }
+ IMechaData Mecha { get; set; }
+ MechaAppearance Appearance { get; set; }
+ MechaAppearance DIYAppearance { get; set; }
+ int[] DIYItemId { get; set; }
+ int[] DIYItemValue { get; set; }
- IPlayerData CreateCopyWithoutMechaData();
- }
-}
\ No newline at end of file
+ IPlayerData CreateCopyWithoutMechaData();
+}
diff --git a/NebulaAPI/GameState/IPlayerManager.cs b/NebulaAPI/GameState/IPlayerManager.cs
index 4f51f1f03..a1d7db158 100644
--- a/NebulaAPI/GameState/IPlayerManager.cs
+++ b/NebulaAPI/GameState/IPlayerManager.cs
@@ -1,55 +1,60 @@
-using System.Collections.Generic;
+#region
-namespace NebulaAPI
+using System.Collections.Generic;
+using NebulaAPI.DataStructures;
+using NebulaAPI.Packets;
+
+#endregion
+
+namespace NebulaAPI.GameState;
+
+public interface IPlayerManager
{
- public interface IPlayerManager
- {
- Locker GetPendingPlayers(out Dictionary pendingPlayers);
+ Locker GetPendingPlayers(out Dictionary pendingPlayers);
- Locker GetSyncingPlayers(out Dictionary syncingPlayers);
+ Locker GetSyncingPlayers(out Dictionary syncingPlayers);
- Locker GetConnectedPlayers(out Dictionary connectedPlayers);
+ Locker GetConnectedPlayers(out Dictionary connectedPlayers);
- Locker GetSavedPlayerData(out Dictionary savedPlayerData);
+ Locker GetSavedPlayerData(out Dictionary savedPlayerData);
- IPlayerData[] GetAllPlayerDataIncludingHost();
+ IPlayerData[] GetAllPlayerDataIncludingHost();
- INebulaPlayer GetPlayer(INebulaConnection conn);
+ INebulaPlayer GetPlayer(INebulaConnection conn);
- INebulaPlayer GetSyncingPlayer(INebulaConnection conn);
+ INebulaPlayer GetSyncingPlayer(INebulaConnection conn);
- INebulaPlayer GetPlayerById(ushort playerId);
+ INebulaPlayer GetPlayerById(ushort playerId);
- INebulaPlayer GetConnectedPlayerByUsername(string username);
+ INebulaPlayer GetConnectedPlayerByUsername(string username);
- void SendPacketToAllPlayers(T packet) where T : class, new();
+ void SendPacketToAllPlayers(T packet) where T : class, new();
- void SendPacketToLocalStar(T packet) where T : class, new();
+ void SendPacketToLocalStar(T packet) where T : class, new();
- void SendPacketToLocalPlanet(T packet) where T : class, new();
+ void SendPacketToLocalPlanet(T packet) where T : class, new();
- void SendPacketToPlanet(T packet, int planetId) where T : class, new();
+ void SendPacketToPlanet(T packet, int planetId) where T : class, new();
- void SendPacketToStar(T packet, int starId) where T : class, new();
+ void SendPacketToStar(T packet, int starId) where T : class, new();
- void SendPacketToStarExcept(T packet, int starId, INebulaConnection exclude) where T : class, new();
+ void SendPacketToStarExcept(T packet, int starId, INebulaConnection exclude) where T : class, new();
- void SendRawPacketToStar(byte[] rawPacket, int starId, INebulaConnection sender);
+ void SendRawPacketToStar(byte[] rawPacket, int starId, INebulaConnection sender);
- void SendRawPacketToPlanet(byte[] rawPacket, int planetId, INebulaConnection sender);
+ void SendRawPacketToPlanet(byte[] rawPacket, int planetId, INebulaConnection sender);
- void SendPacketToOtherPlayers(T packet, INebulaConnection exclude) where T : class, new();
+ void SendPacketToOtherPlayers(T packet, INebulaConnection exclude) where T : class, new();
- void SendPacketToOtherPlayers(T packet, INebulaPlayer sender) where T : class, new();
+ void SendPacketToOtherPlayers(T packet, INebulaPlayer sender) where T : class, new();
- INebulaPlayer PlayerConnected(INebulaConnection conn);
+ INebulaPlayer PlayerConnected(INebulaConnection conn);
- void PlayerDisconnected(INebulaConnection conn);
+ void PlayerDisconnected(INebulaConnection conn);
- ushort GetNextAvailablePlayerId();
+ ushort GetNextAvailablePlayerId();
- void UpdateMechaData(IMechaData mechaData, INebulaConnection conn);
+ void UpdateMechaData(IMechaData mechaData, INebulaConnection conn);
- void UpdateSyncedSandCount(int deltaSandCount);
- }
+ void UpdateSyncedSandCount(int deltaSandCount);
}
diff --git a/NebulaAPI/GlobalSuppressions.cs b/NebulaAPI/GlobalSuppressions.cs
index ef5300a0b..c95916daa 100644
--- a/NebulaAPI/GlobalSuppressions.cs
+++ b/NebulaAPI/GlobalSuppressions.cs
@@ -1,8 +1,9 @@
-// This file is used by Code Analysis to maintain SuppressMessage
-// attributes that are applied to this project.
-// Project-level suppressions either have no target or are given
-// a specific target and scoped to a namespace, type, member, etc.
+#region
using System.Diagnostics.CodeAnalysis;
-[assembly: SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Original Field Name", Scope = "namespaceanddescendants", Target = "NebulaAPI")]
+#endregion
+
+[assembly:
+ SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Original Field Name", Scope = "namespaceanddescendants",
+ Target = "~N:NebulaAPI")]
diff --git a/NebulaAPI/Interfaces/BinaryInterfaces.cs b/NebulaAPI/Interfaces/BinaryInterfaces.cs
index 06c710ecb..011a36651 100644
--- a/NebulaAPI/Interfaces/BinaryInterfaces.cs
+++ b/NebulaAPI/Interfaces/BinaryInterfaces.cs
@@ -1,22 +1,26 @@
-using System;
+#region
+
+using System;
using System.IO;
-namespace NebulaAPI
+#endregion
+
+namespace NebulaAPI.Interfaces;
+
+///
+/// Provides access to BinaryWriter with LZ4 compression
+///
+public interface IWriterProvider : IDisposable
{
- ///
- /// Provides access to BinaryWriter with LZ4 compression
- ///
- public interface IWriterProvider : IDisposable
- {
- BinaryWriter BinaryWriter { get; }
- byte[] CloseAndGetBytes();
- }
+ BinaryWriter BinaryWriter { get; }
- ///
- /// Provides access to BinaryReader with LZ4 compression
- ///
- public interface IReaderProvider : IDisposable
- {
- BinaryReader BinaryReader { get; }
- }
-}
\ No newline at end of file
+ byte[] CloseAndGetBytes();
+}
+
+///
+/// Provides access to BinaryReader with LZ4 compression
+///
+public interface IReaderProvider : IDisposable
+{
+ BinaryReader BinaryReader { get; }
+}
diff --git a/NebulaAPI/Interfaces/IMultiplayerMod.cs b/NebulaAPI/Interfaces/IMultiplayerMod.cs
index bcaee5fc2..d2eeaa1bc 100644
--- a/NebulaAPI/Interfaces/IMultiplayerMod.cs
+++ b/NebulaAPI/Interfaces/IMultiplayerMod.cs
@@ -1,22 +1,27 @@
-using System.IO;
+#region
-namespace NebulaAPI
+using System.IO;
+
+#endregion
+
+namespace NebulaAPI.Interfaces;
+
+///
+/// Implement this interface to make sure your mod will be the same version on the host
+///
+public interface IMultiplayerMod
+{
+ string Version { get; }
+
+ bool CheckVersion(string hostVersion, string clientVersion);
+}
+
+///
+/// Implement this interface if you have important settings that clients need to know
+///
+public interface IMultiplayerModWithSettings : IMultiplayerMod
{
- ///
- /// Implement this interface to make sure your mod will be the same version on the host
- ///
- public interface IMultiplayerMod
- {
- string Version { get; }
- bool CheckVersion(string hostVersion, string clientVersion);
- }
+ void Export(BinaryWriter w);
- ///
- /// Implement this interface if you have important settings that clients need to know
- ///
- public interface IMultiplayerModWithSettings : IMultiplayerMod
- {
- void Export(BinaryWriter w);
- void Import(BinaryReader r);
- }
+ void Import(BinaryReader r);
}
diff --git a/NebulaAPI/Interfaces/INetSerializable.cs b/NebulaAPI/Interfaces/INetSerializable.cs
index 7df6ca20c..777597aaa 100644
--- a/NebulaAPI/Interfaces/INetSerializable.cs
+++ b/NebulaAPI/Interfaces/INetSerializable.cs
@@ -1,149 +1,153 @@
-using System;
+#region
+
+using System;
using System.Net;
-namespace NebulaAPI
+#endregion
+
+namespace NebulaAPI.Interfaces;
+
+public interface INetSerializable
{
- public interface INetSerializable
- {
- void Serialize(INetDataWriter writer);
- void Deserialize(INetDataReader reader);
- }
+ void Serialize(INetDataWriter writer);
+
+ void Deserialize(INetDataReader reader);
+}
- public interface INetDataWriter
- {
- void Put(float value);
+public interface INetDataWriter
+{
+ void Put(float value);
- void Put(double value);
+ void Put(double value);
- void Put(long value);
+ void Put(long value);
- void Put(ulong value);
+ void Put(ulong value);
- void Put(int value);
+ void Put(int value);
- void Put(uint value);
+ void Put(uint value);
- void Put(char value);
+ void Put(char value);
- void Put(ushort value);
+ void Put(ushort value);
- void Put(short value);
+ void Put(short value);
- void Put(sbyte value);
+ void Put(sbyte value);
- void Put(byte value);
+ void Put(byte value);
- void Put(byte[] data, int offset, int length);
+ void Put(byte[] data, int offset, int length);
- void Put(byte[] data);
+ void Put(byte[] data);
- void PutSBytesWithLength(sbyte[] data, int offset, int length);
+ void PutSBytesWithLength(sbyte[] data, int offset, int length);
- void PutSBytesWithLength(sbyte[] data);
+ void PutSBytesWithLength(sbyte[] data);
- void PutBytesWithLength(byte[] data, int offset, int length);
+ void PutBytesWithLength(byte[] data, int offset, int length);
- void PutBytesWithLength(byte[] data);
+ void PutBytesWithLength(byte[] data);
- void Put(bool value);
+ void Put(bool value);
- void PutArray(float[] value);
+ void PutArray(float[] value);
- void PutArray(double[] value);
+ void PutArray(double[] value);
- void PutArray(long[] value);
+ void PutArray(long[] value);
- void PutArray(ulong[] value);
+ void PutArray(ulong[] value);
- void PutArray(int[] value);
+ void PutArray(int[] value);
- void PutArray(uint[] value);
+ void PutArray(uint[] value);
- void PutArray(ushort[] value);
+ void PutArray(ushort[] value);
- void PutArray(short[] value);
+ void PutArray(short[] value);
- void PutArray(bool[] value);
+ void PutArray(bool[] value);
- void PutArray(string[] value);
+ void PutArray(string[] value);
- void PutArray(string[] value, int maxLength);
+ void PutArray(string[] value, int maxLength);
- void Put(IPEndPoint endPoint);
+ void Put(IPEndPoint endPoint);
- void Put(string value);
+ void Put(string value);
- void Put(string value, int maxLength);
+ void Put(string value, int maxLength);
- void Put(T obj) where T : INetSerializable;
- }
+ void Put(T obj) where T : INetSerializable;
+}
- public interface INetDataReader
- {
- IPEndPoint GetNetEndPoint();
+public interface INetDataReader
+{
+ IPEndPoint GetNetEndPoint();
- byte GetByte();
+ byte GetByte();
- sbyte GetSByte();
+ sbyte GetSByte();
- bool[] GetBoolArray();
+ bool[] GetBoolArray();
- ushort[] GetUShortArray();
+ ushort[] GetUShortArray();
- short[] GetShortArray();
+ short[] GetShortArray();
- long[] GetLongArray();
+ long[] GetLongArray();
- ulong[] GetULongArray();
+ ulong[] GetULongArray();
- int[] GetIntArray();
+ int[] GetIntArray();
- uint[] GetUIntArray();
+ uint[] GetUIntArray();
- float[] GetFloatArray();
+ float[] GetFloatArray();
- double[] GetDoubleArray();
+ double[] GetDoubleArray();
- string[] GetStringArray();
+ string[] GetStringArray();
- string[] GetStringArray(int maxStringLength);
+ string[] GetStringArray(int maxStringLength);
- bool GetBool();
+ bool GetBool();
- char GetChar();
+ char GetChar();
- ushort GetUShort();
+ ushort GetUShort();
- short GetShort();
+ short GetShort();
- long GetLong();
+ long GetLong();
- ulong GetULong();
+ ulong GetULong();
- int GetInt();
+ int GetInt();
- uint GetUInt();
+ uint GetUInt();
- float GetFloat();
+ float GetFloat();
- double GetDouble();
+ double GetDouble();
- string GetString(int maxLength);
+ string GetString(int maxLength);
- string GetString();
+ string GetString();
- ArraySegment GetRemainingBytesSegment();
+ ArraySegment GetRemainingBytesSegment();
- T Get() where T : INetSerializable, new();
+ T Get() where T : INetSerializable, new();
- byte[] GetRemainingBytes();
+ byte[] GetRemainingBytes();
- void GetBytes(byte[] destination, int start, int count);
+ void GetBytes(byte[] destination, int start, int count);
- void GetBytes(byte[] destination, int count);
+ void GetBytes(byte[] destination, int count);
- sbyte[] GetSBytesWithLength();
+ sbyte[] GetSBytesWithLength();
- byte[] GetBytesWithLength();
- }
+ byte[] GetBytesWithLength();
}
diff --git a/NebulaAPI/Interfaces/IToggle.cs b/NebulaAPI/Interfaces/IToggle.cs
index 35f757294..7c1801716 100644
--- a/NebulaAPI/Interfaces/IToggle.cs
+++ b/NebulaAPI/Interfaces/IToggle.cs
@@ -1,10 +1,14 @@
-using System;
+#region
-namespace NebulaAPI
+using System;
+
+#endregion
+
+namespace NebulaAPI.Interfaces;
+
+public interface IToggle
{
- public interface IToggle
- {
- bool Value { get; }
- IDisposable On();
- }
-}
\ No newline at end of file
+ bool Value { get; }
+
+ IDisposable On();
+}
diff --git a/NebulaAPI/NebulaAPI.csproj b/NebulaAPI/NebulaAPI.csproj
index e34922699..c4c734e04 100644
--- a/NebulaAPI/NebulaAPI.csproj
+++ b/NebulaAPI/NebulaAPI.csproj
@@ -1,12 +1,13 @@
-
- DysonSphereProgram.Modding.NebulaMultiplayerModApi
- Nebula Mod Team
- API for other mods to work with the Nebula Multiplayer Mod for Dyson Sphere Program.
- https://github.com/hubastard/nebula
- $(MSBuildThisFileDirectory)
-
+
+ DysonSphereProgram.Modding.NebulaMultiplayerModApi
+ Nebula Mod Team
+ API for other mods to work with the Nebula Multiplayer Mod for Dyson Sphere Program.
+ https://github.com/hubastard/nebula
+ $(MSBuildThisFileDirectory)
+ netstandard2.0
+
\ No newline at end of file
diff --git a/NebulaAPI/NebulaModAPI.cs b/NebulaAPI/NebulaModAPI.cs
index aab774ac1..743d2dd94 100644
--- a/NebulaAPI/NebulaModAPI.cs
+++ b/NebulaAPI/NebulaModAPI.cs
@@ -1,178 +1,188 @@
-using BepInEx;
-using HarmonyLib;
+#region
+
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
using System.Reflection;
+using BepInEx;
+using BepInEx.Bootstrap;
+using HarmonyLib;
+using NebulaAPI.GameState;
+using NebulaAPI.Interfaces;
+// ReSharper disable UnassignedField.Global
+// ReSharper disable InconsistentNaming
+// ReSharper disable MemberCanBePrivate.Global
+// ReSharper disable IdentifierTypo
-namespace NebulaAPI
-{
- [BepInPlugin(API_GUID, API_NAME, ThisAssembly.AssemblyFileVersion)]
- [BepInDependency(NEBULA_MODID, BepInDependency.DependencyFlags.SoftDependency)]
- public class NebulaModAPI : BaseUnityPlugin
- {
- private static bool nebulaIsInstalled;
-
- private static Type multiplayer;
-
- private static Type binaryWriter;
- private static Type binaryReader;
-
- public static readonly List TargetAssemblies = new List();
-
- public const string NEBULA_MODID = "dsp.nebula-multiplayer";
-
- public const string API_GUID = "dsp.nebula-multiplayer-api";
- public const string API_NAME = "NebulaMultiplayerModApi";
+#endregion
- public static bool NebulaIsInstalled => nebulaIsInstalled;
+namespace NebulaAPI;
- ///
- /// Is this session in multiplayer
- ///
- public static bool IsMultiplayerActive
+[BepInPlugin(API_GUID, API_NAME, ThisAssembly.AssemblyFileVersion)]
+[BepInDependency(NEBULA_MODID, BepInDependency.DependencyFlags.SoftDependency)]
+[SuppressMessage("Usage", "CA2211:Non-constant fields should not be visible")]
+public class NebulaModAPI : BaseUnityPlugin
+{
+ public const string NEBULA_MODID = "dsp.nebula-multiplayer";
+
+ public const string API_GUID = "dsp.nebula-multiplayer-api";
+ public const string API_NAME = "NebulaMultiplayerModApi";
+
+ public const int PLANET_NONE = -2;
+ public const int AUTHOR_NONE = -1;
+ public const int STAR_NONE = -1;
+
+ private static Type multiplayer;
+
+ private static Type binaryWriter;
+ private static Type binaryReader;
+
+ public static readonly List TargetAssemblies = [];
+
+ ///
+ /// Subscribe to receive event when new multiplayer game is started
+ /// (Host sets up a game, or Client establishes connection)
+ ///
+ public static Action OnMultiplayerGameStarted;
+
+ ///
+ /// Subscribe to receive event when multiplayer game end
+ /// (Host ends the game, or Client disconnects)
+ ///
+ public static Action OnMultiplayerGameEnded;
+
+ ///
+ /// Subscribe to receive event when a new star starts loading (client)
+ /// int starIndex - index of star to load
+ ///
+ public static Action OnStarLoadRequest;
+
+ ///
+ /// Subscribe to receive event when a DysonSphere finishes loading (client)
+ /// int starIndex - index of star of dyson sphere to load
+ ///
+ public static Action OnDysonSphereLoadFinished;
+
+ ///
+ /// Subscribe to receive event when a PlanetFactory starts loading (client)
+ /// int planetId - id of planet to load
+ ///
+ public static Action OnPlanetLoadRequest;
+
+ ///
+ /// Subscribe to receive event when a PlanetFactory is finished loading (client)
+ /// int planetId - id of planet to load
+ ///
+ public static Action OnPlanetLoadFinished;
+
+ ///
+ /// Subscribe to receive even when a player joins the game (Host)
+ /// The event fires after the player sync all the data
+ /// - joined player data
+ ///
+ public static Action OnPlayerJoinedGame;
+
+ ///
+ /// Subscribe to receive even when a player leaves the game (Host)
+ /// The event fires after the player disconnect
+ /// - left player data
+ ///
+ public static Action OnPlayerLeftGame;
+
+ public static bool NebulaIsInstalled { get; set; }
+
+ ///
+ /// Is this session in multiplayer
+ ///
+ // ReSharper disable once UnusedMember.Global
+ public static bool IsMultiplayerActive
+ {
+ get
{
- get
+ if (!NebulaIsInstalled)
{
- if (!NebulaIsInstalled)
- {
- return false;
- }
-
- return (bool)multiplayer.GetProperty("IsActive").GetValue(null);
+ return false;
}
+
+ return (bool)multiplayer.GetProperty("IsActive")?.GetValue(null)!;
}
+ }
- ///
- /// Provides access to MultiplayerSession class
- ///
- public static IMultiplayerSession MultiplayerSession
+ ///
+ /// Provides access to MultiplayerSession class
+ ///
+ public static IMultiplayerSession MultiplayerSession
+ {
+ get
{
- get
+ if (!NebulaIsInstalled)
{
- if (!NebulaIsInstalled)
- {
- return null;
- }
-
- return (IMultiplayerSession)multiplayer.GetProperty("Session").GetValue(null);
+ return null;
}
+
+ return (IMultiplayerSession)multiplayer.GetProperty("Session")?.GetValue(null);
}
+ }
- ///
- /// Subscribe to receive event when new multiplayer game is started
- /// (Host sets up a game, or Client establishes connection)
- ///
- public static Action OnMultiplayerGameStarted;
-
- ///
- /// Subscribe to receive event when multiplayer game end
- /// (Host ends the game, or Client disconnects)
- ///
- public static Action OnMultiplayerGameEnded;
-
- ///
- /// Subscribe to receive event when a new star starts loading (client)
- /// int starIndex - index of star to load
- ///
- public static Action OnStarLoadRequest;
-
- ///
- /// Subscribe to receive event when a DysonSphere finishs loading (client)
- /// int starIndex - index of star of dyson sphere to load
- ///
- public static Action OnDysonSphereLoadFinished;
-
- ///
- /// Subscribe to receive event when a PlanetFactory starts loading (client)
- /// int planetId - id of planet to load
- ///
- public static Action OnPlanetLoadRequest;
-
- ///
- /// Subscribe to receive event when a PlanetFactory is finished loading (client)
- /// int planetId - id of planet to load
- ///
- public static Action OnPlanetLoadFinished;
-
- ///
- /// Subscribe to receive even when a player joins the game (Host)
- /// The event fires after the player sync all the data
- /// - joined player data
- ///
- public static Action OnPlayerJoinedGame;
-
- ///
- /// Subscribe to receive even when a player leaves the game (Host)
- /// The event fires after the player disconnect
- /// - left player data
- ///
- public static Action OnPlayerLeftGame;
-
- private void Awake()
- {
- nebulaIsInstalled = false;
+ private void Awake()
+ {
+ NebulaIsInstalled = false;
- foreach (KeyValuePair pluginInfo in BepInEx.Bootstrap.Chainloader.PluginInfos)
- {
- if (pluginInfo.Value.Metadata.GUID == NEBULA_MODID)
- {
- nebulaIsInstalled = true;
- break;
- }
- }
+ foreach (var unused in Chainloader.PluginInfos.Where(pluginInfo => pluginInfo.Value.Metadata.GUID == NEBULA_MODID))
+ {
+ NebulaIsInstalled = true;
+ break;
+ }
- if (!nebulaIsInstalled)
- {
- return;
- }
+ if (!NebulaIsInstalled)
+ {
+ return;
+ }
- multiplayer = AccessTools.TypeByName("NebulaWorld.Multiplayer");
+ multiplayer = AccessTools.TypeByName("NebulaWorld.Multiplayer");
- Type binaryUtils = AccessTools.TypeByName("NebulaModel.Networking.BinaryUtils");
+ var binaryUtils = AccessTools.TypeByName("NebulaModel.Networking.BinaryUtils");
- binaryWriter = binaryUtils.GetNestedType("Writer");
- binaryReader = binaryUtils.GetNestedType("Reader");
+ binaryWriter = binaryUtils.GetNestedType("Writer");
+ binaryReader = binaryUtils.GetNestedType("Reader");
- Logger.LogInfo("Nebula API is ready!");
- }
+ Logger.LogInfo("Nebula API is ready!");
+ }
- public const int PLANET_NONE = -2;
- public const int AUTHOR_NONE = -1;
- public const int STAR_NONE = -1;
+ ///
+ /// Register all packets within assembly
+ ///
+ /// Target assembly
+ public static void RegisterPackets(Assembly assembly)
+ {
+ TargetAssemblies.Add(assembly);
+ }
- ///
- /// Register all packets within assembly
- ///
- /// Target assembly
- public static void RegisterPackets(Assembly assembly)
+ ///
+ /// Provides access to BinaryWriter with LZ4 compression
+ ///
+ public static IWriterProvider GetBinaryWriter()
+ {
+ if (!NebulaIsInstalled)
{
- TargetAssemblies.Add(assembly);
+ return null;
}
- ///
- /// Provides access to BinaryWriter with LZ4 compression
- ///
- public static IWriterProvider GetBinaryWriter()
- {
- if (!NebulaIsInstalled)
- {
- return null;
- }
-
- return (IWriterProvider)binaryWriter.GetConstructor(new Type[0]).Invoke(new object[0]);
- }
+ return (IWriterProvider)binaryWriter.GetConstructor(Type.EmptyTypes)?.Invoke(Array.Empty