Skip to content

Commit

Permalink
style: dotnet format
Browse files Browse the repository at this point in the history
  • Loading branch information
nattb8 committed May 28, 2024
1 parent e30b3ed commit 0d9d433
Show file tree
Hide file tree
Showing 42 changed files with 124 additions and 123 deletions.
6 changes: 3 additions & 3 deletions Assets/Core/Scripts/EventSystem/AppPauseDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ public class AppPauseDetector : MonoBehaviour
{
[SerializeField]
AbstractGameEvent m_PauseEvent;

/// <summary>
/// Returns the current pause state of the application
/// </summary>
public bool IsPaused { get; private set; }

void OnApplicationFocus(bool hasFocus)
{
IsPaused = !hasFocus;
Expand All @@ -29,7 +29,7 @@ void OnApplicationFocus(bool hasFocus)
void OnApplicationPause(bool pauseStatus)
{
IsPaused = pauseStatus;

if (IsPaused)
m_PauseEvent.Raise();
}
Expand Down
4 changes: 2 additions & 2 deletions Assets/Core/Scripts/StateMachine/AbstractState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public abstract class AbstractState : IState
/// </summary>
public virtual string Name { get; set; }

readonly List<ILink> m_Links = new ();
readonly List<ILink> m_Links = new();

public virtual void Enter()
{
Expand Down Expand Up @@ -74,7 +74,7 @@ public void EnableLinks()
link.Enable();
}
}

public void DisableLinks()
{
foreach (var link in m_Links)
Expand Down
2 changes: 1 addition & 1 deletion Assets/Core/Scripts/StateMachine/DelayState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class DelayState : AbstractState
public override string Name => nameof(DelayState);

readonly float m_DelayInSeconds;

/// <param name="delayInSeconds">delay in seconds</param>
public DelayState(float delayInSeconds)
{
Expand Down
8 changes: 4 additions & 4 deletions Assets/Core/Scripts/StateMachine/EventLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class EventLink : ILink, IGameEventListener
IState m_NextState;
AbstractGameEvent m_GameEvent;
bool m_EventRaised;

/// <param name="gameEvent">the event this link listens to</param>
/// <param name="nextState">the next state</param>
public EventLink(AbstractGameEvent gameEvent, IState nextState)
Expand All @@ -25,13 +25,13 @@ public bool Validate(out IState nextState)
{
nextState = null;
bool result = false;

if (m_EventRaised)
{
nextState = m_NextState;
result = true;
}

return result;
}

Expand All @@ -45,7 +45,7 @@ public void Enable()
m_GameEvent.AddListener(this);
m_EventRaised = false;
}

public void Disable()
{
m_GameEvent.RemoveListener(this);
Expand Down
8 changes: 4 additions & 4 deletions Assets/Core/Scripts/StateMachine/ILink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ public interface ILink
/// <param name="nextState">The next state that this link points to</param>
/// <returns>true: the link is open for transition</returns>
bool Validate(out IState nextState);

/// <summary>
/// Activates the link
/// </summary>
void Enable(){}
void Enable() { }

/// <summary>
/// Deactivates the link
/// </summary>
void Disable(){}
void Disable() { }
}
}
2 changes: 1 addition & 1 deletion Assets/Core/Scripts/StateMachine/Link.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace HyperCasual.Core
public class Link : ILink
{
readonly IState m_NextState;

/// <param name="nextState">the next state</param>
public Link(IState nextState)
{
Expand Down
6 changes: 3 additions & 3 deletions Assets/Core/Scripts/StateMachine/LoadSceneState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ public class LoadSceneState : AbstractState
readonly string m_Scene;
readonly SceneController m_SceneController;
readonly Action m_OnLoadCompleted;

public override string Name => $"{nameof(LoadSceneState)}: {m_Scene}";

/// <param name="sceneController">The SceneController for the current loading operation</param>
/// <param name="scene">The path to the scene</param>
/// <param name="onLoadCompleted">An action that is invoked when scene loading is finished</param>
Expand All @@ -25,7 +25,7 @@ public LoadSceneState(SceneController sceneController, string scene, Action onLo
m_SceneController = sceneController;
m_OnLoadCompleted = onLoadCompleted;
}

public override IEnumerator Execute()
{
yield return m_SceneController.LoadScene(m_Scene);
Expand Down
6 changes: 3 additions & 3 deletions Assets/Core/Scripts/StateMachine/PauseState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ namespace HyperCasual.Core
public class PauseState : AbstractState
{
readonly Action m_OnPause;

public override string Name => $"{nameof(PauseState)}";

/// <param name="onPause">The action that is invoked when the game loop paused</param>
public PauseState(Action onPause)
{
Expand All @@ -30,7 +30,7 @@ public override IEnumerator Execute()
{
yield return null;
}

public override void Exit()
{
Time.timeScale = 1f;
Expand Down
2 changes: 1 addition & 1 deletion Assets/Core/Scripts/StateMachine/State.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace HyperCasual.Core
public class State : AbstractState
{
readonly Action m_OnExecute;

/// <param name="onExecute">An event that is invoked when the state is executed</param>
public State(Action onExecute)
{
Expand Down
28 changes: 14 additions & 14 deletions Assets/Core/Scripts/StateMachine/StateMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace HyperCasual.Core
public class StateMachine
{
public IState CurrentState { get; private set; }

/// <summary>
/// Finalizes the previous state and then runs the new state
/// </summary>
Expand All @@ -22,12 +22,12 @@ public virtual void SetCurrentState(IState state)
if (state == null)
throw new ArgumentNullException(nameof(state));

if (CurrentState != null && m_CurrentPlayCoroutine != null)
if (CurrentState != null && m_CurrentPlayCoroutine != null)
{
//interrupt currently executing state
Skip();
}

CurrentState = state;
Coroutines.StartCoroutine(Play());
}
Expand All @@ -43,14 +43,14 @@ IEnumerator Play()
if (!m_PlayLock)
{
m_PlayLock = true;

CurrentState.Enter();

//keep a ref to execute coroutine of the current state
//to support stopping it later.
m_CurrentPlayCoroutine = Coroutines.StartCoroutine(CurrentState.Execute());
yield return m_CurrentPlayCoroutine;

m_CurrentPlayCoroutine = null;
}
}
Expand All @@ -63,7 +63,7 @@ void Skip()
{
if (CurrentState == null)
throw new Exception($"{nameof(CurrentState)} is null!");

if (m_CurrentPlayCoroutine != null)
{
Coroutines.StopCoroutine(ref m_CurrentPlayCoroutine);
Expand All @@ -73,24 +73,24 @@ void Skip()
m_PlayLock = false;
}
}

public virtual void Run(IState state)
{
SetCurrentState(state);
Run();
}

Coroutine m_LoopCoroutine;
/// <summary>
/// Turns on the main loop of the StateMachine.
/// This method does not resume previous state if called after Stop()
/// and the client needs to set the state manually.
/// </summary>
public virtual void Run()
public virtual void Run()
{
if (m_LoopCoroutine != null) //already running
return;

m_LoopCoroutine = Coroutines.StartCoroutine(Loop());
}

Expand All @@ -101,13 +101,13 @@ public void Stop()
{
if (m_LoopCoroutine == null) //already stopped
return;
if (CurrentState != null && m_CurrentPlayCoroutine != null)

if (CurrentState != null && m_CurrentPlayCoroutine != null)
{
//interrupt currently executing state
Skip();
}

Coroutines.StopCoroutine(ref m_LoopCoroutine);
CurrentState = null;
}
Expand All @@ -133,7 +133,7 @@ protected virtual IEnumerator Loop()
}
CurrentState.DisableLinks();
SetCurrentState(nextState);
CurrentState.EnableLinks();
CurrentState.EnableLinks();
}
}

Expand Down
2 changes: 1 addition & 1 deletion Assets/Core/Scripts/StateMachine/UnloadLastSceneState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public UnloadLastSceneState(SceneController sceneController)
{
m_SceneController = sceneController;
}

public override IEnumerator Execute()
{
yield return m_SceneController.UnloadLastScene();
Expand Down
4 changes: 2 additions & 2 deletions Assets/Core/Scripts/UI/UIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public class UIManager : AbstractSingleton<UIManager>

View m_CurrentView;

readonly Stack<View> m_History = new ();
readonly Stack<View> m_History = new();

void Start()
{
m_Views = m_Root.GetComponentsInChildren<View>(true).ToList();
Init();

// m_ViewLayer.ResizeToSafeArea(m_Canvas);
}

Expand Down
2 changes: 1 addition & 1 deletion Assets/Core/Scripts/UI/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public abstract class View : MonoBehaviour
public virtual void Initialize()
{
}

/// <summary>
/// Makes the View visible
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions Assets/Core/Scripts/Utils/CoroutineUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ namespace HyperCasual.Core
/// It instantiates a hidden GameObject and adds an empty MonoBehaviour component
/// to it that is used for starting/stopping coroutines.
/// </summary>
public static class Coroutines
public static class Coroutines
{
public class CoroutineHelper : MonoBehaviour { }

static MonoBehaviour s_Instance;

static MonoBehaviour Instance
Expand All @@ -32,7 +32,7 @@ static MonoBehaviour Instance
return s_Instance;
}
}

/// <summary>
/// Starts a coroutine
/// </summary>
Expand Down
12 changes: 6 additions & 6 deletions Assets/Core/Scripts/Utils/SceneController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class SceneController
{
Scene m_LastScene;
readonly Scene m_NeverUnloadScene;

/// <param name="neverUnloadScene">The scene we instantiate all level-independent managers in it and never unloads.</param>
public SceneController(Scene neverUnloadScene)
{
Expand All @@ -36,7 +36,7 @@ public IEnumerator LoadScene(string scene)

yield return LoadSceneAdditive(scene);
}

/// <summary>
/// Creates and Loads a new empty scene of the given name and unloads others.
/// </summary>
Expand All @@ -51,12 +51,12 @@ public IEnumerator LoadNewScene(string scene)

LoadNewSceneAdditive(scene);
}

IEnumerator UnloadScene(Scene scene)
{
if (!m_LastScene.IsValid())
if (!m_LastScene.IsValid())
yield break;

var asyncUnload = SceneManager.UnloadSceneAsync(scene);
while (!asyncUnload.isDone)
{
Expand All @@ -76,7 +76,7 @@ IEnumerator LoadSceneAdditive(string scenePath)
m_LastScene = SceneManager.GetSceneByPath(scenePath);
SceneManager.SetActiveScene(m_LastScene);
}

void LoadNewSceneAdditive(string sceneName)
{
var scene = SceneManager.CreateScene(sceneName);
Expand Down
4 changes: 2 additions & 2 deletions Assets/Editor/CustomEditors/SceneRefEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ namespace HyperCasual.CustomEditors
public class ScenePickerEditor : Editor
{
const string k_PropertyName = "m_ScenePath";

public override void OnInspectorGUI()
{
var sceneRef = target as SceneRef;

if (sceneRef == null)
return;

var oldScene = AssetDatabase.LoadAssetAtPath<SceneAsset>(sceneRef.m_ScenePath);

serializedObject.Update();
Expand Down
2 changes: 1 addition & 1 deletion Assets/Runner/Scripts/CameraManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ bool GetCameraLockStatus()
Vector3 GetPlayerPosition()
{
Vector3 playerPosition = Vector3.up;
if (PlayerController.Instance != null)
if (PlayerController.Instance != null)
{
playerPosition = PlayerController.Instance.GetPlayerTop();
}
Expand Down
Loading

0 comments on commit 0d9d433

Please sign in to comment.