refactor file scoped namespace

pull/3/head
HumanoidSandvichDispenser 2023-06-03 18:21:46 -07:00
parent 96fd6f5c26
commit 706354e813
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
48 changed files with 2118 additions and 2166 deletions

View File

@ -1,11 +1,10 @@
using Godot;
using SupaLidlGame.Utils;
namespace SupaLidlGame.BoundingBoxes
namespace SupaLidlGame.BoundingBoxes;
public abstract partial class BoundingBox : Area2D, IFaction
{
public abstract partial class BoundingBox : Area2D, IFaction
{
[Export]
public ushort Faction { get; set; }
}
}

View File

@ -2,10 +2,10 @@ using Godot;
using System;
using SupaLidlGame.Characters;
namespace SupaLidlGame.BoundingBoxes
namespace SupaLidlGame.BoundingBoxes;
public partial class ConnectorBox : Area2D
{
public partial class ConnectorBox : Area2D
{
[Signal]
public delegate void RequestedEnterEventHandler(
ConnectorBox box,
@ -68,5 +68,4 @@ namespace SupaLidlGame.BoundingBoxes
base._Process(delta);
}
}
}

View File

@ -3,10 +3,10 @@ using Godot;
using SupaLidlGame.Characters;
using SupaLidlGame.Items;
namespace SupaLidlGame.BoundingBoxes
namespace SupaLidlGame.BoundingBoxes;
public partial class Hitbox : BoundingBox
{
public partial class Hitbox : BoundingBox
{
private HashSet<BoundingBox> _ignoreList = new HashSet<BoundingBox>();
[Signal]
@ -101,5 +101,4 @@ namespace SupaLidlGame.BoundingBoxes
{
get => _ignoreList;
}
}
}

View File

@ -2,10 +2,10 @@ using Godot;
using SupaLidlGame.Characters;
using SupaLidlGame.Utils;
namespace SupaLidlGame.BoundingBoxes
namespace SupaLidlGame.BoundingBoxes;
public partial class Hurtbox : BoundingBox, IFaction
{
public partial class Hurtbox : BoundingBox, IFaction
{
[Signal]
public delegate void ReceivedDamageEventHandler(
float damage,
@ -36,5 +36,4 @@ namespace SupaLidlGame.BoundingBoxes
knockback,
knockbackOrigin, knockbackVector);
}
}
}

View File

@ -4,10 +4,10 @@ using SupaLidlGame.Items;
using SupaLidlGame.Utils;
using SupaLidlGame.State.Character;
namespace SupaLidlGame.Characters
namespace SupaLidlGame.Characters;
public partial class Character : CharacterBody2D, IFaction
{
public partial class Character : CharacterBody2D, IFaction
{
[Export]
public float Speed { get; protected set; } = 32.0f;
@ -220,5 +220,4 @@ namespace SupaLidlGame.Characters
sound.At(GlobalPosition).WithPitchDeviation(0.125f).Play();
}
}
}
}

View File

@ -1,10 +1,10 @@
using Godot;
using System;
namespace SupaLidlGame.Characters
namespace SupaLidlGame.Characters;
public partial class Enemy : NPC
{
public partial class Enemy : NPC
{
public override void _Ready()
{
Inventory.SelectedItem = Inventory.GetNode<Items.Item>("Sword");
@ -15,5 +15,4 @@ namespace SupaLidlGame.Characters
{
base.Die();
}
}
}

View File

@ -3,10 +3,10 @@ using SupaLidlGame.Extensions;
using SupaLidlGame.Items;
using System;
namespace SupaLidlGame.Characters
namespace SupaLidlGame.Characters;
public partial class NPC : Character
{
public partial class NPC : Character
{
/// <summary>
/// Time in seconds it takes for the NPC to think FeelsDankCube
/// </summary>
@ -225,5 +225,4 @@ namespace SupaLidlGame.Characters
}
}
}
}
}

View File

@ -1,10 +1,10 @@
using Godot;
using SupaLidlGame.Utils;
namespace SupaLidlGame.Characters
namespace SupaLidlGame.Characters;
public partial class Player : Character
{
public partial class Player : Character
{
private AnimatedSprite2D _sprite;
private string _spriteAnim;
@ -18,8 +18,8 @@ namespace SupaLidlGame.Characters
{
// the Player.Animation property might be set before this node is
// even ready, so if _sprite is null, then we just hold the new
// animation in a temp value, which will be assigned once this
// node is ready
// animation in a temp value, which will be assigned once this node
// is ready
if (_sprite is null)
{
_spriteAnim = value;
@ -61,5 +61,4 @@ namespace SupaLidlGame.Characters
GD.Print("died");
//base.Die();
}
}
}

View File

@ -1,10 +1,9 @@
namespace SupaLidlGame.Characters.Thinkers
namespace SupaLidlGame.Characters.Thinkers;
public class Thinker
{
public class Thinker
{
public virtual void Think()
{
}
}
}

View File

@ -1,10 +1,10 @@
using Godot;
using System;
namespace SupaLidlGame.Entities
namespace SupaLidlGame.Entities;
public partial class Campfire : StaticBody2D
{
public partial class Campfire : StaticBody2D
{
private PointLight2D _light;
[Signal]
@ -20,5 +20,4 @@ namespace SupaLidlGame.Entities
_light.Energy += (GD.Randf() - 0.5f) * 8 * (float)delta;
_light.Energy = Math.Clamp(_light.Energy, 1.2f, 2.0f);
}
}
}

View File

@ -2,10 +2,10 @@ using Godot;
using SupaLidlGame.Characters;
using SupaLidlGame.BoundingBoxes;
namespace SupaLidlGame.Entities
namespace SupaLidlGame.Entities;
public partial class Projectile : RigidBody2D
{
public partial class Projectile : RigidBody2D
{
public Vector2 Velocity => Direction * Speed;
[Export]
@ -48,5 +48,4 @@ namespace SupaLidlGame.Entities
);
}
}
}
}

View File

@ -2,10 +2,10 @@ using Godot;
using System;
using SupaLidlGame.Utils;
namespace SupaLidlGame.Extensions
namespace SupaLidlGame.Extensions;
public static class AudioStreamPlayer2DExtensions
{
public static class AudioStreamPlayer2DExtensions
{
public static AudioStreamPlayer2D Clone(
this AudioStreamPlayer2D audio)
{
@ -69,5 +69,4 @@ namespace SupaLidlGame.Extensions
audio.PitchScale = (float)GD.Randfn(audio.PitchScale, deviation);
return audio;
}
}
}

View File

@ -1,9 +1,9 @@
using Godot;
namespace SupaLidlGame.Extensions
namespace SupaLidlGame.Extensions;
public static class NodeExtensions
{
public static class NodeExtensions
{
/// <summary>
/// Iterates through each ancestor until it finds an ancestor of type
/// <c>T</c>
@ -37,5 +37,4 @@ namespace SupaLidlGame.Extensions
{
return node.GetNode(name) as T;
}
}
}

View File

@ -1,13 +1,12 @@
using Godot;
namespace SupaLidlGame.Extensions
namespace SupaLidlGame.Extensions;
public static class Node2DExtensions
{
public static class Node2DExtensions
{
public static void RayCast(this Node2D node, Vector2 ray)
{
//var spaceState = node.GetWorld2d().DirectSpaceState;
//var result = spaceState.IntersectRay();
}
}
}

View File

@ -1,9 +1,9 @@
using Godot;
namespace SupaLidlGame.Extensions
namespace SupaLidlGame.Extensions;
public static class Vector2Extensions
{
public static class Vector2Extensions
{
public static Vector2 Midpoint(this Vector2 vector, Vector2 other)
{
return new Vector2((vector.X + other.X) / 2,
@ -37,5 +37,4 @@ namespace SupaLidlGame.Extensions
{
return new Vector2(vector.Y, -vector.X);
}
}
}

View File

@ -2,10 +2,10 @@ using Godot;
using SupaLidlGame.Characters;
using Godot.Collections;
namespace SupaLidlGame.Items
namespace SupaLidlGame.Items;
public partial class Inventory : Node2D
{
public partial class Inventory : Node2D
{
public Character Character { get; private set; }
[Export]
@ -142,5 +142,4 @@ namespace SupaLidlGame.Items
var e = SelectedItem = item;
throw new System.NotImplementedException();
}
}
}

View File

@ -1,10 +1,10 @@
using Godot;
using SupaLidlGame.Characters;
namespace SupaLidlGame.Items
namespace SupaLidlGame.Items;
public abstract partial class Item : Node2D
{
public abstract partial class Item : Node2D
{
[Export]
public string ItemName { get; set; }
@ -49,5 +49,4 @@ namespace SupaLidlGame.Items
public abstract void Use();
public abstract void Deuse();
}
}

View File

@ -2,10 +2,10 @@ using Godot;
using SupaLidlGame.BoundingBoxes;
using SupaLidlGame.Characters;
namespace SupaLidlGame.Items
namespace SupaLidlGame.Items;
public abstract partial class Weapon : Item
{
public abstract partial class Weapon : Item
{
public double RemainingUseTime { get; protected set; } = 0;
public override bool IsUsing => RemainingUseTime > 0;
@ -106,5 +106,4 @@ namespace SupaLidlGame.Items
hurtbox.InflictDamage(Damage, Character, Knockback);
}
}
}
}

View File

@ -1,10 +1,9 @@
namespace SupaLidlGame.Items.Weapons
namespace SupaLidlGame.Items.Weapons;
public interface IParryable
{
public interface IParryable
{
public bool IsParryable { get; }
public bool IsParried { get; }
public ulong ParryTimeOrigin { get; }
public void Stun();
}
}

View File

@ -1,10 +1,10 @@
using Godot;
using SupaLidlGame.Extensions;
namespace SupaLidlGame.Items.Weapons
namespace SupaLidlGame.Items.Weapons;
public partial class Railgun : Ranged
{
public partial class Railgun : Ranged
{
public override void Attack()
{
// create projectile
@ -18,5 +18,4 @@ namespace SupaLidlGame.Items.Weapons
this.GetAncestor<SupaLidlGame.Scenes.Map>()
.Entities.AddChild(projectile);
}
}
}

View File

@ -1,9 +1,9 @@
using Godot;
namespace SupaLidlGame.Items.Weapons
namespace SupaLidlGame.Items.Weapons;
public abstract partial class Ranged : Weapon
{
public abstract partial class Ranged : Weapon
{
[Export]
public float AngleDeviation { get; set; }
@ -39,5 +39,4 @@ namespace SupaLidlGame.Items.Weapons
}
public abstract void Attack();
}
}

View File

@ -4,10 +4,10 @@ using SupaLidlGame.Characters;
using SupaLidlGame.Extensions;
using SupaLidlGame.State.Weapon;
namespace SupaLidlGame.Items.Weapons
namespace SupaLidlGame.Items.Weapons;
public partial class Sword : Weapon, IParryable
{
public partial class Sword : Weapon, IParryable
{
public bool IsAttacking { get; protected set; }
public override bool IsUsing => StateMachine.CurrentState
@ -233,5 +233,4 @@ namespace SupaLidlGame.Items.Weapons
{
AnimationTree.Set("parameters/conditions/" + condition, value);
}
}
}

View File

@ -3,7 +3,6 @@
[ext_resource type="Script" path="res://Utils/World.cs" id="1_1k6ew"]
[ext_resource type="PackedScene" uid="uid://bxtpv6jqodj4v" path="res://Scenes/Maps/Hills.tscn" id="2_juio7"]
[node name="World" type="Node2D" node_paths=PackedStringArray("CurrentPlayer")]
[node name="World" type="Node2D"]
script = ExtResource("1_1k6ew")
StartingArea = ExtResource("2_juio7")
CurrentPlayer = NodePath("")

View File

@ -1,10 +1,10 @@
using Godot;
using System;
namespace SupaLidlGame.Scenes
namespace SupaLidlGame.Scenes;
public partial class Map : TileMap
{
public partial class Map : TileMap
{
[Export]
public Node2D Entities { get; set; }
@ -44,5 +44,4 @@ namespace SupaLidlGame.Scenes
{
base._Process(delta);
}
}
}

View File

@ -1,9 +1,9 @@
using Godot;
namespace SupaLidlGame.State.Character
namespace SupaLidlGame.State.Character;
public abstract partial class CharacterState : Node, IState<CharacterState>
{
public abstract partial class CharacterState : Node, IState<CharacterState>
{
[Export]
public Characters.Character Character { get; set; }
@ -66,5 +66,4 @@ namespace SupaLidlGame.State.Character
}
public virtual CharacterState Input(InputEvent @event) => null;
}
}

View File

@ -1,9 +1,9 @@
using Godot;
namespace SupaLidlGame.State.Character
namespace SupaLidlGame.State.Character;
public partial class CharacterStateMachine : StateMachine<CharacterState>
{
public partial class CharacterStateMachine : StateMachine<CharacterState>
{
[Export]
public override CharacterState InitialState { get; set; }
@ -36,5 +36,4 @@ namespace SupaLidlGame.State.Character
ChangeState(state);
}
}
}
}

View File

@ -1,9 +1,9 @@
using Godot;
namespace SupaLidlGame.State.Character
namespace SupaLidlGame.State.Character;
public partial class NPCIdleState : NPCState
{
public partial class NPCIdleState : NPCState
{
[Export]
public CharacterState MoveState { get; set; }
@ -22,5 +22,4 @@ namespace SupaLidlGame.State.Character
Character.Sprite.Play("idle");
return base.Enter(previousState);
}
}
}

View File

@ -1,9 +1,9 @@
using Godot;
namespace SupaLidlGame.State.Character
namespace SupaLidlGame.State.Character;
public partial class NPCMoveState : NPCState
{
public partial class NPCMoveState : NPCState
{
[Export]
public CharacterState IdleState { get; set; }
@ -22,5 +22,4 @@ namespace SupaLidlGame.State.Character
Character.Sprite.Play("move");
return base.Enter(prev);
}
}
}

View File

@ -1,7 +1,7 @@
namespace SupaLidlGame.State.Character
namespace SupaLidlGame.State.Character;
public abstract partial class NPCState : CharacterState
{
public abstract partial class NPCState : CharacterState
{
protected Characters.NPC _npc => Character as Characters.NPC;
public override CharacterState Process(double delta)
@ -9,5 +9,4 @@ namespace SupaLidlGame.State.Character
_npc.ThinkProcess(delta);
return base.Process(delta);
}
}
}

View File

@ -1,9 +1,9 @@
using Godot;
namespace SupaLidlGame.State.Character
namespace SupaLidlGame.State.Character;
public partial class PlayerIdleState : PlayerState
{
public partial class PlayerIdleState : PlayerState
{
[Export]
public CharacterState MoveState { get; set; }
@ -34,5 +34,4 @@ namespace SupaLidlGame.State.Character
}
return null;
}
}
}

View File

@ -1,9 +1,9 @@
using Godot;
namespace SupaLidlGame.State.Character
namespace SupaLidlGame.State.Character;
public partial class PlayerMoveState : PlayerState
{
public partial class PlayerMoveState : PlayerState
{
[Export]
public PlayerRollState RollState { get; set; }
@ -42,5 +42,4 @@ namespace SupaLidlGame.State.Character
}
return base.Input(@event);
}
}
}

View File

@ -1,9 +1,9 @@
using Godot;
namespace SupaLidlGame.State.Character
namespace SupaLidlGame.State.Character;
public partial class PlayerRollState : PlayerState
{
public partial class PlayerRollState : PlayerState
{
private double _timeLeftToRoll = 0;
private Vector2 _rollDirection = Vector2.Zero;
@ -35,5 +35,4 @@ namespace SupaLidlGame.State.Character
}
return null;
}
}
}

View File

@ -1,10 +1,10 @@
using Godot;
using SupaLidlGame.Characters;
namespace SupaLidlGame.State.Character
namespace SupaLidlGame.State.Character;
public abstract partial class PlayerState : CharacterState
{
public abstract partial class PlayerState : CharacterState
{
protected Player _player => Character as Player;
[Export]
@ -68,5 +68,4 @@ namespace SupaLidlGame.State.Character
return base.Process(delta);
}
}
}

View File

@ -1,7 +1,7 @@
namespace SupaLidlGame.State
namespace SupaLidlGame.State;
public interface IState<T> where T : IState<T>
{
public interface IState<T> where T : IState<T>
{
/// <summary>
/// Called when this state is entered
/// </summary>
@ -19,5 +19,4 @@ namespace SupaLidlGame.State
public void Exit(IState<T> nextState);
public IState<T> Process(double delta) => null;
}
}

View File

@ -1,9 +1,9 @@
using Godot;
namespace SupaLidlGame.State
namespace SupaLidlGame.State;
public abstract partial class StateMachine<T> : Node where T : IState<T>
{
public abstract partial class StateMachine<T> : Node where T : IState<T>
{
public T CurrentState { get; protected set; }
public abstract T InitialState { get; set; }
@ -37,5 +37,4 @@ namespace SupaLidlGame.State
return true;
}
}
}

View File

@ -1,9 +1,9 @@
using Godot;
namespace SupaLidlGame.State.Weapon
namespace SupaLidlGame.State.Weapon;
public partial class RangedFireState : WeaponState
{
public partial class RangedFireState : WeaponState
{
[Export]
public Items.Weapons.Ranged Weapon { get; set; }
@ -34,5 +34,4 @@ namespace SupaLidlGame.State.Weapon
{
}
}
}

View File

@ -1,9 +1,9 @@
using Godot;
namespace SupaLidlGame.State.Weapon
namespace SupaLidlGame.State.Weapon;
public partial class RangedIdleState : WeaponState
{
public partial class RangedIdleState : WeaponState
{
[Export]
public RangedFireState FireState { get; set; }
@ -25,5 +25,4 @@ namespace SupaLidlGame.State.Weapon
{
Weapon.Visible = true;
}
}
}

View File

@ -1,9 +1,9 @@
using Godot;
namespace SupaLidlGame.State.Weapon
namespace SupaLidlGame.State.Weapon;
public partial class SwordAnticipateState : WeaponState
{
public partial class SwordAnticipateState : WeaponState
{
[Export]
public SupaLidlGame.Items.Weapons.Sword Sword { get; set; }
@ -42,5 +42,4 @@ namespace SupaLidlGame.State.Weapon
}
return null;
}
}
}

View File

@ -1,9 +1,9 @@
using Godot;
namespace SupaLidlGame.State.Weapon
namespace SupaLidlGame.State.Weapon;
public partial class SwordAttackState : WeaponState
{
public partial class SwordAttackState : WeaponState
{
[Export]
public SupaLidlGame.Items.Weapons.Sword Sword { get; set; }
@ -85,5 +85,4 @@ namespace SupaLidlGame.State.Weapon
return null;
}
}
}

View File

@ -1,9 +1,9 @@
using Godot;
namespace SupaLidlGame.State.Weapon
namespace SupaLidlGame.State.Weapon;
public partial class SwordIdleState : WeaponState
{
public partial class SwordIdleState : WeaponState
{
[Export]
public SwordAnticipateState AnticipateState { get; set; }
@ -48,5 +48,4 @@ namespace SupaLidlGame.State.Weapon
return null;
}
}
}

View File

@ -1,9 +1,9 @@
using Godot;
namespace SupaLidlGame.State.Weapon
namespace SupaLidlGame.State.Weapon;
public abstract partial class WeaponState : Node, IState<WeaponState>
{
public abstract partial class WeaponState : Node, IState<WeaponState>
{
public virtual WeaponState Use() => null;
public virtual WeaponState Deuse() => null;
@ -16,5 +16,4 @@ namespace SupaLidlGame.State.Weapon
}
public virtual IState<WeaponState> Process(double delta) => null;
}
}

View File

@ -1,9 +1,9 @@
using Godot;
namespace SupaLidlGame.State.Weapon
namespace SupaLidlGame.State.Weapon;
public partial class WeaponStateMachine : StateMachine<WeaponState>
{
public partial class WeaponStateMachine : StateMachine<WeaponState>
{
[Export]
public override WeaponState InitialState { get; set; }
@ -33,5 +33,4 @@ namespace SupaLidlGame.State.Weapon
ChangeState(s);
}
}
}
}

View File

@ -2,10 +2,10 @@ using Godot;
using SupaLidlGame.Extensions;
using System;
namespace SupaLidlGame.Prototyping
namespace SupaLidlGame.Prototyping;
public partial class ContextBasedSteering : Node2D
{
public partial class ContextBasedSteering : Node2D
{
public float PreferredDistance { get; set; } = 256.0f;
Vector2 _direction;
@ -54,5 +54,4 @@ namespace SupaLidlGame.Prototyping
{
DrawLine(Vector2.Zero, _direction * 256, Colors.Green);
}
}
}

View File

@ -1,10 +1,10 @@
using Godot;
using System;
namespace SupaLidlGame.UI
namespace SupaLidlGame.UI;
public partial class FloatingText : Node2D
{
public partial class FloatingText : Node2D
{
private Label _label;
[Export]
@ -47,5 +47,4 @@ namespace SupaLidlGame.UI
{
QueueFree();
}
}
}

View File

@ -1,13 +1,12 @@
using Godot;
namespace SupaLidlGame.Utils
namespace SupaLidlGame.Utils;
public interface IFaction
{
public interface IFaction
{
/// <summary>
/// The faction index that this entity belongs to.
/// </summary>
[Export]
public ushort Faction { get; set; }
}
}

View File

@ -1,10 +1,10 @@
using Godot;
using System;
namespace SupaLidlGame.Utils
namespace SupaLidlGame.Utils;
public partial class PlayerCamera : Camera2D
{
public partial class PlayerCamera : Camera2D
{
protected float _intensity;
protected double _timeLeft;
@ -46,5 +46,4 @@ namespace SupaLidlGame.Utils
ret.Y = (rng.Randf() - 0.5f) * intensity;
return ret;
}
}
}

View File

@ -2,10 +2,10 @@ using Godot;
using Godot.Collections;
using SupaLidlGame.Extensions;
namespace SupaLidlGame.Utils
namespace SupaLidlGame.Utils;
public partial class Spawner : Node2D
{
public partial class Spawner : Node2D
{
[Export]
public Area2D SpawnArea { get; set; }
@ -55,5 +55,4 @@ namespace SupaLidlGame.Utils
this.GetAncestor<Scenes.Map>().Entities.AddChild(chr);
}
}
}
}

View File

@ -5,10 +5,10 @@ using SupaLidlGame.Extensions;
using System.Collections.Generic;
using System.Linq;
namespace SupaLidlGame.Utils
namespace SupaLidlGame.Utils;
public partial class World : Node2D
{
public partial class World : Node2D
{
[Export]
public PackedScene StartingArea { get; set; }
@ -146,5 +146,4 @@ namespace SupaLidlGame.Utils
{
throw new System.NotImplementedException();
}
}
}