Skip to content

Commit

Permalink
Convert ALL tabs to spaces for ALL files
Browse files Browse the repository at this point in the history
  • Loading branch information
valkyrienyanko committed Mar 11, 2023
1 parent 3e0dc05 commit b87b0bd
Show file tree
Hide file tree
Showing 56 changed files with 2,262 additions and 2,262 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ root = true

# Indentation and spacing
indent_size = 4
indent_style = tab
indent_style = space
tab_width = 4

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

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

Expand Down
100 changes: 50 additions & 50 deletions Scripts/Entities/Animations/EntityAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,69 @@

public enum EntityAnimationType
{
None = 0,
Idle,
Walking,
Running,
PreJumpStart,
JumpStart,
JumpFall,
Dash
None = 0,
Idle,
Walking,
Running,
PreJumpStart,
JumpStart,
JumpFall,
Dash
}

public abstract class EntityAnimation<T> where T : MovingEntity<T>
{
protected T Entity { get; set; }
protected T Entity { get; set; }

public EntityAnimation(T entity)
{
Entity = entity;
}
public EntityAnimation(T entity)
{
Entity = entity;
}

//private int Counter { get; set; }
//private int Counter { get; set; }

protected void SwitchState(EntityAnimationType animation)
{
//Logger.Log($"[{Counter++}][{Entity}] Switching to {animation}");
protected void SwitchState(EntityAnimationType animation)
{
//Logger.Log($"[{Counter++}][{Entity}] Switching to {animation}");

if (!Entity.Animations.ContainsKey(animation))
{
Logger.LogWarning($"{animation} for {Entity} has not been setup yet");
return;
}
if (!Entity.Animations.ContainsKey(animation))
{
Logger.LogWarning($"{animation} for {Entity} has not been setup yet");
return;
}

Entity.Animations[Entity.CurrentAnimation].Exit();
Entity.CurrentAnimation = animation;
Entity.Animations[Entity.CurrentAnimation].Enter();
}
Entity.Animations[Entity.CurrentAnimation].Exit();
Entity.CurrentAnimation = animation;
Entity.Animations[Entity.CurrentAnimation].Enter();
}

protected void FlipSpriteOnDirection()
{
if (Entity.MoveDir.X != 0)
{
Entity.AnimatedSprite.FlipH = Entity.MoveDir.X < 0; // flip sprite if moving left
}
}
protected void FlipSpriteOnDirection()
{
if (Entity.MoveDir.X != 0)
{
Entity.AnimatedSprite.FlipH = Entity.MoveDir.X < 0; // flip sprite if moving left
}
}

/// <summary>
/// Setup and start the animation
/// </summary>
public virtual void Enter() { }
/// <summary>
/// Setup and start the animation
/// </summary>
public virtual void Enter() { }

/// <summary>
/// Update the current animation
/// </summary>
public virtual void Update() { }
/// <summary>
/// Update the current animation
/// </summary>
public virtual void Update() { }

/// <summary>
/// Potentially transition to a new state
/// </summary>
public virtual void HandleTransitions() { }
/// <summary>
/// Potentially transition to a new state
/// </summary>
public virtual void HandleTransitions() { }

/// <summary>
/// Cleanly exit the animation state
/// </summary>
public virtual void Exit() { }
/// <summary>
/// Cleanly exit the animation state
/// </summary>
public virtual void Exit() { }

public override string ToString() => GetType().Name.Replace("EntityAnimation", "");
public override string ToString() => GetType().Name.Replace("EntityAnimation", "");
}
34 changes: 17 additions & 17 deletions Scripts/Entities/Animations/EntityAnimationIdle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@

public class EntityAnimationIdle<T> : EntityAnimation<T> where T : MovingEntity<T>
{
public EntityAnimationIdle(T entity) : base(entity) { }
public EntityAnimationIdle(T entity) : base(entity) { }

public override void Enter() => Entity.AnimatedSprite.Play("idle");
public override void Enter() => Entity.AnimatedSprite.Play("idle");

/// <summary>
/// <br>Idle -> JumpStart</br>
/// <br>Idle -> JumpFall</br>
/// </summary>
public override void HandleTransitions()
{
if (!Entity.IsNearGround() && Entity.IsFalling())
HandleTransitionsFalling();
else if (!Entity.IsNearGround())
HandleTransitionsNotNearGround();
}
/// <summary>
/// <br>Idle -> JumpStart</br>
/// <br>Idle -> JumpFall</br>
/// </summary>
public override void HandleTransitions()
{
if (!Entity.IsNearGround() && Entity.IsFalling())
HandleTransitionsFalling();
else if (!Entity.IsNearGround())
HandleTransitionsNotNearGround();
}

public virtual void HandleTransitionsFalling() =>
SwitchState(EntityAnimationType.JumpFall);
public virtual void HandleTransitionsFalling() =>
SwitchState(EntityAnimationType.JumpFall);

public virtual void HandleTransitionsNotNearGround() =>
SwitchState(EntityAnimationType.JumpStart);
public virtual void HandleTransitionsNotNearGround() =>
SwitchState(EntityAnimationType.JumpStart);
}
34 changes: 17 additions & 17 deletions Scripts/Entities/Animations/EntityAnimationJumpFall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@

public class EntityAnimationJumpFall<T> : EntityAnimation<T> where T : MovingEntity<T>
{
public EntityAnimationJumpFall(T entity) : base(entity) { }
public EntityAnimationJumpFall(T entity) : base(entity) { }

public override void Enter() => Entity.AnimatedSprite.Play("jump_fall");
public override void Enter() => Entity.AnimatedSprite.Play("jump_fall");

/// <summary>
/// <br>JumpFall -> Idle</br>
/// <br>JumpFall -> JumpStart</br>
/// </summary>
public override void HandleTransitions()
{
if (Entity.IsNearGround())
HandleTransitionsNearGround();
else if (!Entity.IsFalling() && Entity.Velocity.Y != 0)
HandleTransitionsFalling();
}
/// <summary>
/// <br>JumpFall -> Idle</br>
/// <br>JumpFall -> JumpStart</br>
/// </summary>
public override void HandleTransitions()
{
if (Entity.IsNearGround())
HandleTransitionsNearGround();
else if (!Entity.IsFalling() && Entity.Velocity.Y != 0)
HandleTransitionsFalling();
}

public virtual void HandleTransitionsNearGround() =>
SwitchState(EntityAnimationType.Idle);
public virtual void HandleTransitionsNearGround() =>
SwitchState(EntityAnimationType.Idle);

public virtual void HandleTransitionsFalling() =>
SwitchState(EntityAnimationType.JumpStart);
public virtual void HandleTransitionsFalling() =>
SwitchState(EntityAnimationType.JumpStart);
}
50 changes: 25 additions & 25 deletions Scripts/Entities/Animations/EntityAnimationJumpStart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@

public class EntityAnimationJumpStart<T> : EntityAnimation<T> where T : MovingEntity<T>
{
private GTimer TimerDontCheckOnGround { get; set; }
private GTimer TimerDontCheckOnGround { get; set; }

public EntityAnimationJumpStart(T entity) : base(entity) { }
public EntityAnimationJumpStart(T entity) : base(entity) { }

public override void Enter()
{
TimerDontCheckOnGround = Entity.Timers.CreateTimer(100);
Entity.AnimatedSprite.Play("jump_start");
}
public override void Enter()
{
TimerDontCheckOnGround = Entity.Timers.CreateTimer(100);
Entity.AnimatedSprite.Play("jump_start");
}

/// <summary>
/// <br>JumpStart -> Idle</br>
/// <br>JumpStart -> JumpFall</br>
/// </summary>
public override void HandleTransitions()
{
if (Entity.IsNearGround() && Entity.MoveDir == Vector2.Zero && !TimerDontCheckOnGround.IsActive())
HandleTransitionsIdleNearGround();
else if (Entity.IsNearGround() && !TimerDontCheckOnGround.IsActive())
SwitchState(EntityAnimationType.Walking);
else if (Entity.IsFalling())
HandleTransitionsFalling();
}
/// <summary>
/// <br>JumpStart -> Idle</br>
/// <br>JumpStart -> JumpFall</br>
/// </summary>
public override void HandleTransitions()
{
if (Entity.IsNearGround() && Entity.MoveDir == Vector2.Zero && !TimerDontCheckOnGround.IsActive())
HandleTransitionsIdleNearGround();
else if (Entity.IsNearGround() && !TimerDontCheckOnGround.IsActive())
SwitchState(EntityAnimationType.Walking);
else if (Entity.IsFalling())
HandleTransitionsFalling();
}

public virtual void HandleTransitionsFalling() =>
SwitchState(EntityAnimationType.JumpFall);
public virtual void HandleTransitionsFalling() =>
SwitchState(EntityAnimationType.JumpFall);

public virtual void HandleTransitionsIdleNearGround() =>
SwitchState(EntityAnimationType.Idle);
public virtual void HandleTransitionsIdleNearGround() =>
SwitchState(EntityAnimationType.Idle);
}
2 changes: 1 addition & 1 deletion Scripts/Entities/Animations/EntityAnimationNone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

public class EntityAnimationNone<T> : EntityAnimation<T> where T : MovingEntity<T>
{
public EntityAnimationNone(T entity) : base(entity) { }
public EntityAnimationNone(T entity) : base(entity) { }
}
Loading

0 comments on commit b87b0bd

Please sign in to comment.