Skip to content

Commit

Permalink
Run code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
valkyrienyanko committed Aug 20, 2024
1 parent c3e36e6 commit 4c6615d
Show file tree
Hide file tree
Showing 14 changed files with 139 additions and 140 deletions.
36 changes: 20 additions & 16 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ tab_width = 4

# New line preferences
end_of_line = crlf
insert_final_newline = true
insert_final_newline = false

#### .NET Coding Conventions ####

Expand Down Expand Up @@ -43,13 +43,14 @@ dotnet_style_require_accessibility_modifiers = for_non_interface_members

# Expression-level preferences
dotnet_style_coalesce_expression = true
dotnet_style_collection_initializer = false:silent
dotnet_style_collection_initializer = true
dotnet_style_explicit_tuple_names = true
dotnet_style_namespace_match_folder = true
dotnet_style_null_propagation = true
dotnet_style_object_initializer = false:silent
dotnet_style_object_initializer = true
dotnet_style_operator_placement_when_wrapping = beginning_of_line
dotnet_style_prefer_auto_properties = true
dotnet_style_prefer_collection_expression = when_types_loosely_match
dotnet_style_prefer_compound_assignment = true
dotnet_style_prefer_conditional_expression_over_assignment = true
dotnet_style_prefer_conditional_expression_over_return = true
Expand All @@ -76,19 +77,19 @@ dotnet_style_allow_statement_immediately_after_block_experimental = false
#### C# Coding Conventions ####

# var preferences
csharp_style_var_elsewhere = true
csharp_style_var_for_built_in_types = true
csharp_style_var_when_type_is_apparent = true
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 = true:suggestion
csharp_style_expression_bodied_methods = false
csharp_style_expression_bodied_operators = true:suggestion
csharp_style_expression_bodied_properties = false
csharp_style_expression_bodied_methods = false:suggestion
csharp_style_expression_bodied_operators = true
csharp_style_expression_bodied_properties = true

# Pattern matching preferences
csharp_style_pattern_matching_over_as_with_null_check = true
Expand All @@ -102,14 +103,18 @@ csharp_style_prefer_switch_expression = true
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,required,volatile,async
csharp_prefer_static_anonymous_function = true
csharp_prefer_static_local_function = false:silent
csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async
csharp_style_prefer_readonly_struct = true
csharp_style_prefer_readonly_struct_member = true

# Code-block preferences
csharp_prefer_braces = false
csharp_prefer_braces = true
csharp_prefer_simple_using_statement = true
csharp_style_namespace_declarations = file_scoped
csharp_style_namespace_declarations = file_scoped:error
csharp_style_prefer_method_group_conversion = false
csharp_style_prefer_primary_constructors = true
csharp_style_prefer_top_level_statements = true

# Expression-level preferences
Expand All @@ -132,6 +137,8 @@ csharp_using_directive_placement = outside_namespace

# New line preferences
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false
csharp_style_allow_embedded_statements_on_same_line_experimental = true

Expand Down Expand Up @@ -223,6 +230,3 @@ dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.required_suffix =
dotnet_naming_style.begins_with_i.word_separator =
dotnet_naming_style.begins_with_i.capitalization = pascal_case

# Default severity for all analyzer diagnostics
dotnet_analyzer_diagnostic.severity = none
6 changes: 3 additions & 3 deletions Scripts/Autoloads/AudioManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static void PlayMusic(AudioStream song, bool instant = true, double fadeO
});

// Fade in to current song
var volume = Options.MusicVolume;
float volume = Options.MusicVolume;
var volumeRemapped = volume == 0 ? -80 : volume.Remap(0, 100, -40, 0);
tween.Animate("volume_db", volumeRemapped, fadeIn)
.SetTrans(Tween.TransitionType.Sine)
Expand All @@ -54,9 +54,9 @@ public static void PlaySFX(AudioStream sound)
};

// Randomize the pitch
var rng = new RandomNumberGenerator();
RandomNumberGenerator rng = new();
rng.Randomize();
var pitch = rng.RandfRange(0.8f, 1.2f);
float pitch = rng.RandfRange(0.8f, 1.2f);

// Ensure the current pitch is not the same as the last
while (Mathf.Abs(pitch - LastPitch) < 0.1f)
Expand Down
34 changes: 17 additions & 17 deletions Scripts/Autoloads/OptionsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ public partial class OptionsManager : Node

public static void SaveOptions()
{
var error = ResourceSaver.Save(OptionsManager.Options, "user://options.tres");
Error error = ResourceSaver.Save(OptionsManager.Options, "user://options.tres");

if (error != Error.Ok)
GD.Print(error);
}

public static void SaveHotkeys()
{
var error = ResourceSaver.Save(OptionsManager.Hotkeys, "user://hotkeys.tres");
Error error = ResourceSaver.Save(OptionsManager.Hotkeys, "user://hotkeys.tres");

if (error != Error.Ok)
GD.Print(error);
Expand All @@ -34,11 +34,11 @@ public static void ResetHotkeys()
// Deep clone default hotkeys over
Hotkeys.Actions = new();

foreach (var element in DefaultHotkeys)
foreach (KeyValuePair<StringName, Array<InputEvent>> element in DefaultHotkeys)
{
var arr = new Array<InputEvent>();
Array<InputEvent> arr = new();

foreach (var item in DefaultHotkeys[element.Key])
foreach (InputEvent item in DefaultHotkeys[element.Key])
{
arr.Add((InputEvent)item.Duplicate());
}
Expand Down Expand Up @@ -85,38 +85,38 @@ public override void _Input(InputEvent @event)

private void LoadOptions()
{
var fileExists = FileAccess.FileExists("user://options.tres");
bool fileExists = FileAccess.FileExists("user://options.tres");

Options = fileExists ?
GD.Load<ResourceOptions>("user://options.tres") : new();
}

private static void LoadInputMap(Dictionary<StringName, Array<InputEvent>> hotkeys)
{
var actions = InputMap.GetActions();
Array<StringName> actions = InputMap.GetActions();

foreach (var action in actions)
foreach (StringName action in actions)
InputMap.EraseAction(action);

foreach (var action in hotkeys.Keys)
foreach (StringName action in hotkeys.Keys)
{
InputMap.AddAction(action);

foreach (var @event in hotkeys[action])
foreach (InputEvent @event in hotkeys[action])
InputMap.ActionAddEvent(action, @event);
}
}

private void GetDefaultHotkeys()
{
// Get all the default actions defined in the input map
var actions = new Dictionary<StringName, Array<InputEvent>>();
Dictionary<StringName, Array<InputEvent>> actions = new();

foreach (var action in InputMap.GetActions())
foreach (StringName action in InputMap.GetActions())
{
actions.Add(action, new Array<InputEvent>());

foreach (var actionEvent in InputMap.ActionGetEvents(action))
foreach (InputEvent actionEvent in InputMap.ActionGetEvents(action))
actions[action].Add(actionEvent);
}

Expand All @@ -125,7 +125,7 @@ private void GetDefaultHotkeys()

private void LoadHotkeys()
{
var fileExists = FileAccess.FileExists("user://hotkeys.tres");
bool fileExists = FileAccess.FileExists("user://hotkeys.tres");

if (fileExists)
{
Expand Down Expand Up @@ -164,9 +164,9 @@ private void SetWinSize()
DisplayServer.WindowSetSize(Options.WindowSize);

// center window
var screenSize = DisplayServer.ScreenGetSize();
var winSize = DisplayServer.WindowGetSize();
DisplayServer.WindowSetPosition(screenSize / 2 - winSize / 2);
Vector2I screenSize = DisplayServer.ScreenGetSize();
Vector2I winSize = DisplayServer.WindowGetSize();
DisplayServer.WindowSetPosition((screenSize / 2) - (winSize / 2));
}
}

Expand Down
4 changes: 2 additions & 2 deletions Scripts/CameraController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ private void Rotate(InputEventMouseMotion motion)
if (!HoldingLeftClick)
return;

var vel = motion.Relative * Sensitivity;
Vector2 vel = motion.Relative * Sensitivity;

var rot = Rotation;
Vector3 rot = Rotation;

rot.X -= vel.Y;
rot.Y -= vel.X;
Expand Down
Loading

0 comments on commit 4c6615d

Please sign in to comment.