From 87cbba225ee2eb614b8202710dfe4f37e6853b4a Mon Sep 17 00:00:00 2001 From: "D. Moonfire" Date: Mon, 5 Sep 2022 23:02:36 -0500 Subject: [PATCH] build: removing commitlint --- .editorconfig | 189 +++++++++---------------------------------- .envrc | 3 - .woodpecker.yml | 36 +++++++++ commitlint.config.js | 6 -- docs/entity.md | 55 +++++++++++++ docs/index.md | 12 +++ flake.lock | 12 +-- flake.nix | 2 +- lefthook.yml | 21 +++-- mfgames-project.json | 7 ++ 10 files changed, 169 insertions(+), 174 deletions(-) create mode 100644 .woodpecker.yml delete mode 100644 commitlint.config.js create mode 100644 docs/entity.md create mode 100644 docs/index.md create mode 100644 mfgames-project.json diff --git a/.editorconfig b/.editorconfig index fccb81d..819c8e1 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,6 +1,7 @@ -root = true # EditorConfig is awesome: https://EditorConfig.org +root = true + [*] charset = utf-8 end_of_line = lf @@ -11,128 +12,47 @@ indent_size = 4 # Microsoft .NET properties csharp_new_line_before_members_in_object_initializers = false csharp_preferred_modifier_order = public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion -csharp_style_var_elsewhere = false:suggestion -csharp_style_var_for_built_in_types = false:suggestion -csharp_style_var_when_type_is_apparent = true:suggestion +csharp_space_after_cast = false +csharp_style_var_elsewhere = false:hint +csharp_style_var_for_built_in_types = false:hint +csharp_style_var_when_type_is_apparent = true:hint csharp_preserve_single_line_statements = false -dotnet_naming_rule.event_rule.import_to_resharper = as_predefined -dotnet_naming_rule.event_rule.severity = warning -dotnet_naming_rule.event_rule.style = upper_camel_case_underscore_tolerant_style -dotnet_naming_rule.event_rule.symbols = event_symbols -dotnet_naming_rule.local_constants_rule.import_to_resharper = as_predefined -dotnet_naming_rule.local_constants_rule.severity = warning -dotnet_naming_rule.local_constants_rule.style = upper_camel_case_style -dotnet_naming_rule.local_constants_rule.symbols = local_constants_symbols -dotnet_naming_rule.private_constants_rule.import_to_resharper = as_predefined -dotnet_naming_rule.private_constants_rule.severity = warning -dotnet_naming_rule.private_constants_rule.style = upper_camel_case_style -dotnet_naming_rule.private_constants_rule.symbols = private_constants_symbols -dotnet_naming_rule.private_instance_fields_rule.import_to_resharper = as_predefined -dotnet_naming_rule.private_instance_fields_rule.severity = warning -dotnet_naming_rule.private_instance_fields_rule.style = lower_camel_case_style -dotnet_naming_rule.private_instance_fields_rule.symbols = private_instance_fields_symbols -dotnet_naming_rule.private_static_fields_override_rule.import_to_resharper = False -dotnet_naming_rule.private_static_fields_override_rule.severity = warning -dotnet_naming_rule.private_static_fields_override_rule.style = upper_camel_case_style -dotnet_naming_rule.private_static_fields_override_rule.symbols = private_static_fields_override_symbols -dotnet_naming_rule.private_static_fields_rule.import_to_resharper = as_predefined -dotnet_naming_rule.private_static_fields_rule.resharper_style = AaBb, aaBb -dotnet_naming_rule.private_static_fields_rule.severity = warning -dotnet_naming_rule.private_static_fields_rule.style = upper_camel_case_style -dotnet_naming_rule.private_static_fields_rule.symbols = private_static_fields_symbols -dotnet_naming_rule.private_static_fields_rule_1.import_to_resharper = True -dotnet_naming_rule.private_static_fields_rule_1.resharper_description = PrivateStaticFields -dotnet_naming_rule.private_static_fields_rule_1.resharper_guid = 2ec29786-2764-45cc-849e-7a476ce55db8 -dotnet_naming_rule.private_static_fields_rule_1.resharper_style = AaBb, aaBb -dotnet_naming_rule.private_static_fields_rule_1.severity = warning -dotnet_naming_rule.private_static_fields_rule_1.style = upper_camel_case_style -dotnet_naming_rule.private_static_fields_rule_1.symbols = private_static_fields_symbols_1 -dotnet_naming_rule.private_static_readonly_rule.import_to_resharper = as_predefined -dotnet_naming_rule.private_static_readonly_rule.severity = warning -dotnet_naming_rule.private_static_readonly_rule.style = upper_camel_case_style -dotnet_naming_rule.private_static_readonly_rule.symbols = private_static_readonly_symbols -dotnet_naming_style.lower_camel_case_style.capitalization = camel_case -dotnet_naming_style.upper_camel_case_style.capitalization = pascal_case -dotnet_naming_style.upper_camel_case_underscore_tolerant_style.capitalization = pascal_case -dotnet_naming_style.upper_camel_case_underscore_tolerant_style.word_separator = _ -dotnet_naming_symbols.event_symbols.applicable_accessibilities = * -dotnet_naming_symbols.event_symbols.applicable_kinds = event -dotnet_naming_symbols.local_constants_symbols.applicable_accessibilities = * -dotnet_naming_symbols.local_constants_symbols.applicable_kinds = local -dotnet_naming_symbols.local_constants_symbols.required_modifiers = const -dotnet_naming_symbols.private_constants_symbols.applicable_accessibilities = private -dotnet_naming_symbols.private_constants_symbols.applicable_kinds = field -dotnet_naming_symbols.private_constants_symbols.required_modifiers = const -dotnet_naming_symbols.private_instance_fields_symbols.applicable_accessibilities = private -dotnet_naming_symbols.private_instance_fields_symbols.applicable_kinds = field -dotnet_naming_symbols.private_static_fields_override_symbols.applicable_accessibilities = local, private -dotnet_naming_symbols.private_static_fields_override_symbols.applicable_kinds = field -dotnet_naming_symbols.private_static_fields_override_symbols.required_modifiers = const, static -dotnet_naming_symbols.private_static_fields_symbols.applicable_accessibilities = private -dotnet_naming_symbols.private_static_fields_symbols.applicable_kinds = field -dotnet_naming_symbols.private_static_fields_symbols.required_modifiers = static -dotnet_naming_symbols.private_static_fields_symbols_1.applicable_accessibilities = local, private -dotnet_naming_symbols.private_static_fields_symbols_1.applicable_kinds = field -dotnet_naming_symbols.private_static_fields_symbols_1.required_modifiers = static -dotnet_naming_symbols.private_static_fields_symbols_1.resharper_applicable_kinds = field -dotnet_naming_symbols.private_static_fields_symbols_1.resharper_required_modifiers = static -dotnet_naming_symbols.private_static_readonly_symbols.applicable_accessibilities = private -dotnet_naming_symbols.private_static_readonly_symbols.applicable_kinds = field -dotnet_naming_symbols.private_static_readonly_symbols.required_modifiers = static, readonly -dotnet_separate_import_directive_groups = true -dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none -dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:none -dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none -dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion -dotnet_style_predefined_type_for_member_access = true:suggestion -dotnet_style_qualification_for_event = true:suggestion -dotnet_style_qualification_for_field = true:suggestion -dotnet_style_qualification_for_method = true:suggestion -dotnet_style_qualification_for_property = true:suggestion -dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion +csharp_preserve_single_line_blocks = true +dotnet_style_predefined_type_for_locals_parameters_members = true:hint +dotnet_style_predefined_type_for_member_access = true:hint +dotnet_style_qualification_for_event = true:hint +dotnet_style_qualification_for_field = true:hint +dotnet_style_qualification_for_method = true:hint +dotnet_style_qualification_for_property = true:hint +dotnet_style_require_accessibility_modifiers = for_non_interface_members:hint # ReSharper properties resharper_alignment_tab_fill_style = optimal_fill -resharper_align_multiline_binary_expressions_chain = false -resharper_align_multiline_statement_conditions = false resharper_apply_on_completion = true resharper_blank_lines_after_control_transfer_statements = 1 -resharper_blank_lines_after_multiline_statements = 1 resharper_blank_lines_around_single_line_auto_property = 1 resharper_blank_lines_around_single_line_property = 1 -resharper_blank_lines_before_control_transfer_statements = 1 -resharper_blank_lines_before_multiline_statements = 1 resharper_blank_lines_before_single_line_comment = 1 +resharper_blank_lines_between_using_groups = 1 resharper_braces_for_for = required resharper_braces_for_foreach = required resharper_braces_for_ifelse = required resharper_braces_for_while = required resharper_can_use_global_alias = false -resharper_continuous_indent_multiplier = 1 -resharper_cpp_alignment_tab_fill_style = optimal_fill -resharper_cpp_insert_final_newline = true -resharper_csharp_alignment_tab_fill_style = use_spaces resharper_csharp_blank_lines_around_single_line_field = 1 resharper_csharp_blank_lines_around_single_line_invocable = 1 -resharper_csharp_indent_style = space +resharper_csharp_indent_style = tab resharper_csharp_insert_final_newline = true resharper_csharp_keep_blank_lines_in_code = 1 resharper_csharp_keep_blank_lines_in_declarations = 1 -resharper_csharp_max_line_length = 120 -resharper_csharp_naming_rule.method_property_event = AaBb_AaBb -resharper_csharp_naming_rule.private_constants = AaBb -resharper_csharp_naming_rule.private_static_fields = AaBb, aaBb -resharper_csharp_naming_rule.private_static_readonly = AaBb -resharper_csharp_stick_comment = false +resharper_csharp_new_line_before_while = true +resharper_csharp_use_indent_from_vs = false resharper_csharp_wrap_arguments_style = chop_if_long -resharper_csharp_wrap_before_binary_opsign = true resharper_csharp_wrap_extends_list_style = chop_if_long resharper_csharp_wrap_parameters_style = chop_if_long -resharper_css_insert_final_newline = true -resharper_default_exception_variable_name = exception +resharper_css_insert_final_newline = false resharper_enforce_line_ending_style = true -resharper_event_handler_pattern_long = On$event$ -resharper_html_alignment_tab_fill_style = optimal_fill +resharper_html_insert_final_newline = false resharper_indent_nested_fixed_stmt = true resharper_js_indent_style = tab resharper_js_insert_final_newline = true @@ -142,51 +62,28 @@ resharper_js_use_indent_from_vs = false resharper_js_wrap_before_binary_opsign = true resharper_js_wrap_chained_method_calls = chop_if_long resharper_keep_blank_lines_between_declarations = 1 -resharper_keep_existing_declaration_block_arrangement = true -resharper_keep_existing_declaration_parens_arrangement = false -resharper_keep_existing_embedded_block_arrangement = true -resharper_keep_existing_enum_arrangement = true -resharper_keep_existing_linebreaks = true -resharper_keep_user_linebreaks = true resharper_min_blank_lines_after_imports = 1 -resharper_nested_ternary_style = expanded -resharper_new_line_before_while = true -resharper_place_attribute_on_same_line = false +resharper_place_attribute_on_same_line = False resharper_place_constructor_initializer_on_same_line = false resharper_place_type_constraints_on_same_line = false -resharper_protobuf_insert_final_newline = true +resharper_protobuf_insert_final_newline = false resharper_qualified_using_at_nested_scope = true -resharper_resx_alignment_tab_fill_style = optimal_fill -resharper_t4_alignment_tab_fill_style = optimal_fill -resharper_t4_insert_final_newline = true -resharper_use_continuous_indent_inside_initializer_braces = false +resharper_resx_insert_final_newline = false +resharper_space_within_single_line_array_initializer_braces = true resharper_use_indents_from_main_language_in_file = false -resharper_use_indent_from_vs = false -resharper_vb_alignment_tab_fill_style = optimal_fill +resharper_vb_insert_final_newline = false resharper_wrap_after_declaration_lpar = true resharper_wrap_after_invocation_lpar = true -resharper_wrap_array_initializer_style = chop_if_long resharper_wrap_before_extends_colon = true resharper_wrap_before_first_type_parameter_constraint = true resharper_wrap_before_type_parameter_langle = true -resharper_wrap_chained_binary_expressions = chop_if_long -resharper_wrap_chained_method_calls = chop_always -resharper_wrap_object_and_collection_initializer_style = chop_always -resharper_xmldoc_alignment_tab_fill_style = optimal_fill resharper_xmldoc_indent_child_elements = ZeroIndent resharper_xmldoc_indent_text = ZeroIndent -resharper_xmldoc_max_line_length = 80 -resharper_xml_alignment_tab_fill_style = optimal_fill +resharper_xmldoc_insert_final_newline = false +resharper_xml_insert_final_newline = false # ReSharper inspection severities -resharper_arrange_redundant_parentheses_highlighting = hint -resharper_arrange_this_qualifier_highlighting = hint -resharper_arrange_type_member_modifiers_highlighting = hint -resharper_arrange_type_modifiers_highlighting = hint -resharper_built_in_type_reference_style_for_member_access_highlighting = hint -resharper_built_in_type_reference_style_highlighting = hint resharper_check_namespace_highlighting = none -resharper_class_never_instantiated_global_highlighting = none resharper_convert_to_auto_property_highlighting = none resharper_localizable_element_highlighting = none resharper_redundant_comma_in_attribute_list_highlighting = none @@ -194,16 +91,9 @@ resharper_redundant_comma_in_enum_declaration_highlighting = none resharper_redundant_comma_in_initializer_highlighting = none resharper_string_compare_to_is_culture_specific_highlighting = none resharper_string_index_of_is_culture_specific_1_highlighting = none -resharper_suggest_var_or_type_built_in_types_highlighting = hint -resharper_suggest_var_or_type_elsewhere_highlighting = hint -resharper_suggest_var_or_type_simple_types_highlighting = hint resharper_use_null_propagation_highlighting = none resharper_use_object_or_collection_initializer_highlighting = hint resharper_use_string_interpolation_highlighting = hint -resharper_web_config_module_not_resolved_highlighting = warning -resharper_web_config_type_not_resolved_highlighting = warning -resharper_web_config_wrong_module_highlighting = warning -trim_trailing_whitespace = false # Matches the exact files either package.json or .travis.yml [{package.json,.travis.yml}] @@ -211,6 +101,16 @@ indent_style = space indent_size = 2 tab_width = 2 +[*.{cs,js,json,jsx,proto,resjson,ts,tsx}] +indent_style = space +indent_size = 4 +tab_width = 4 + +[*.{asax,ascx,aspx,cshtml,css,htm,html,master,razor,skin,vb,xaml,xamlx,xoml}] +indent_style = space +indent_size = 4 +tab_width = 4 + [*.{appxmanifest,build,config,csproj,dbml,discomap,dtd,jsproj,lsproj,njsproj,nuspec,proj,props,resw,resx,StyleCop,targets,tasks,vbproj,xml,xsd}] indent_style = space indent_size = 2 @@ -220,18 +120,3 @@ tab_width = 2 indent_style = space indent_size = 2 tab_width = 2 - -[*.cs] -indent_style = space -indent_size = 4 -tab_width = 4 - -[*.{appxmanifest,asax,ascx,aspx,axaml,build,cg,cginc,compute,cs,cshtml,dtd,hlsl,hlsli,hlslinc,master,nuspec,paml,razor,resw,resx,skin,usf,ush,vb,xaml,xamlx,xoml,xsd}] -indent_style = space -indent_size = 4 -tab_width = 4 - -[*.{appxmanifest,asax,ascx,aspx,axaml,build,c,c++,cc,cginc,compute,cp,cpp,cs,cshtml,cu,cuh,cxx,dtd,fx,fxh,h,hh,hlsl,hlsli,hlslinc,hpp,hxx,inc,inl,ino,ipp,master,mpp,mq4,mq5,mqh,nuspec,paml,razor,resw,resx,skin,tpp,usf,ush,vb,xaml,xamlx,xoml,xsd}] -indent_style = space -indent_size = 4 -tab_width = 4 \ No newline at end of file diff --git a/.envrc b/.envrc index 1be825c..5816063 100644 --- a/.envrc +++ b/.envrc @@ -1,5 +1,2 @@ -# Insert our scripts into the path. export PATH=$PWD/scripts:$PATH - -# Nix flakes are awesome. use flake || use nix diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 0000000..3f25d63 --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1,36 @@ +clone: + git: + image: woodpeckerci/plugin-git + settings: + tags: true + +pipeline: + build: + image: registry.gitlab.com/dmoonfire/nix-flake-docker:latest + commands: + - nix develop --command scripts/build.sh + when: + event: [push, pull_request, tag] + tag: v* + + test: + image: registry.gitlab.com/dmoonfire/nix-flake-docker:latest + commands: + - nix develop --command scripts/test.sh + when: + event: [push, pull_request] + #paths: + # - ./**/*test-result.xml + # - ./coverage/Cobertura.xml + # - ./coverage/Summary.* + # - ./**/*.nupkg + + release-main: + image: registry.gitlab.com/dmoonfire/nix-flake-docker:latest + commands: + - nix develop --command scripts/release.sh + secrets: + - gitea_token + when: + event: push + branch: main diff --git a/commitlint.config.js b/commitlint.config.js deleted file mode 100644 index 1080a13..0000000 --- a/commitlint.config.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - extends: ["@commitlint/config-conventional"], - rules: { - "body-max-line-length": [0], - }, -}; diff --git a/docs/entity.md b/docs/entity.md new file mode 100644 index 0000000..b74b9f5 --- /dev/null +++ b/docs/entity.md @@ -0,0 +1,55 @@ +# Entity + +The `Entity` class is a simplistic data structure that contains only two +properties: a semi-unique identifier and a collection of components. It is +immutable and thread-safe. + +## Identifier + +Creating a new entity without any parameters will assign a new id, this is +currently implemented as an `int` that is initialized by a static property +managed by the `Interlock` to make it a thread-safe operation. + +```csharp +Entity entity = new(); +``` + +_NOTE: This means there is an effective limitation of 4.3 billion entities. The +current reasoning is that most games don't need to have that many concurrent +objects and will rarely roll over._ + +In situations were a more custom identifier management is needed, one of the +constructors takes the `int` as a parameter. + +```csharp +var idManager; +Entity entity = new(idManager.GetNext()); +``` + +In addition, there is a copy constructor that takes another entity and copies +both the identifier and the components of the entity. + +```csharp +Entity entity1 = new(); +Entity entity2 = new(entity1); + +Assert.Equal(entity1.Id, entity2.Id); +``` + +## Components + +In addition to the identifier, entities have a collection of components. This is +exposed as an immutable collection. Adding, removing, and setting components are immutable operations that create a new `Entity` object with the same identifier and a new collection of components. + +```csharp +Entity entity1 = new(); +Entity entity2 = entity1.Add(23).Add("string value"); +Entity entity3 = entity2.Set(56); + +Assert.Equal(entity1.Id, entity2.Id); +Assert.Equal(entity1.Id, entity3.Id); +Assert.Equal(2, entity2.Components.Count); +Assert.Equal(2, entity3.Components.Count); +Assert.Equal(23, entity2.Get()); +Assert.Equal(56, entity3.Get()); +``` diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..942f294 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,12 @@ +# Gallium CIL + +Gallium is a C# simplistic Entity-Component-System (ECS) that is intended to use +the patterns and terminology used by `System.Linq` while using C# data +structures instead of creating custom ones. It uses the familiar methods like +`.Where()` or `.Select()` to work with components. + +## Entities + +The basic unit is an [Entity](./entity.md), a class that had a semi-unique +identifier (`entity.Id`) and an immutable collection of components. The entity itself is immutable with all operations returning a new `Entity` object with the +same identifier with the modified components based on the operation. diff --git a/flake.lock b/flake.lock index 1146b23..b67b61d 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "flake-utils": { "locked": { - "lastModified": 1649676176, - "narHash": "sha256-OWKJratjt2RW151VUlJPRALb7OU2S5s+f0vLj4o1bHM=", + "lastModified": 1659877975, + "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", "owner": "numtide", "repo": "flake-utils", - "rev": "a4b154ebbdc88c8498a5c7b01589addc9e9cb678", + "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", "type": "github" }, "original": { @@ -17,11 +17,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1651558728, - "narHash": "sha256-8HzyRnWlgZluUrVFNOfZAOlA1fghpOSezXvxhalGMUo=", + "lastModified": 1662019588, + "narHash": "sha256-oPEjHKGGVbBXqwwL+UjsveJzghWiWV0n9ogo1X6l4cw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "cbe587c735b734405f56803e267820ee1559e6c1", + "rev": "2da64a81275b68fdad38af669afeda43d401e94b", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index fe5ad6b..3de25d3 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "A .NET core library for building tools"; + description = "A .NET core library for easily building CLI tools"; inputs = { nixpkgs.url = "nixpkgs/nixos-unstable"; diff --git a/lefthook.yml b/lefthook.yml index dbc1c63..43a0f2b 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -1,13 +1,22 @@ -pre-push: - parallel: true - commands: - commit-check: - run: convco check - pre-commit: parallel: true commands: + dotnet-format: + glob: "*.cs" + run: dotnet format prettier: run: prettier . --write --loglevel warn nixfmt: run: nixfmt flake.nix + +commit-msg: + commands: + commit-check: + run: convco check -n 1 + +skip_output: + - meta # Skips lefthook version printing + - summary # Skips summary block (successful and failed steps) printing + - success # Skips successful steps printing + - failure # Skips failed steps printing + - execution # Skips printing successfully executed commands and their output (but still prints failed executions) diff --git a/mfgames-project.json b/mfgames-project.json new file mode 100644 index 0000000..ff1db3d --- /dev/null +++ b/mfgames-project.json @@ -0,0 +1,7 @@ +{ + "title": "Gallium CIL", + "slug": "gallium-cil", + "status": "Active", + "maturity": "Unstable", + "summary": "An entity-component-system (ECS) framework." +}