feat/state #2

Merged
jers merged 3 commits from feat/state into main 2026-04-24 18:57:07 +00:00
6 changed files with 58 additions and 5 deletions
Showing only changes of commit a75f8a7a6a - Show all commits

View File

@ -5,9 +5,7 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="60468364-7d9c-427f-83f9-f6cd83ef8783" name="Changes" comment=""> <list default="true" id="60468364-7d9c-427f-83f9-f6cd83ef8783" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/Assets/Scenes/SampleScene.unity" beforeDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/.idea.SpringJam2026/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.SpringJam2026/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scenes/SampleScene.unity.meta" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/ProjectSettings/EditorBuildSettings.asset" beforeDir="false" afterPath="$PROJECT_DIR$/ProjectSettings/EditorBuildSettings.asset" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -34,7 +32,7 @@
"ModuleVcsDetector.initialDetectionPerformed": "true", "ModuleVcsDetector.initialDetectionPerformed": "true",
"RunOnceActivity.ShowReadmeOnStart": "true", "RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true", "RunOnceActivity.git.unshallow": "true",
"git-widget-placeholder": "feature/services", "git-widget-placeholder": "main",
"ignore.virus.scanning.warn.message": "true", "ignore.virus.scanning.warn.message": "true",
"node.js.detected.package.eslint": "true", "node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true", "node.js.detected.package.tslint": "true",
@ -108,7 +106,7 @@
<option name="number" value="Default" /> <option name="number" value="Default" />
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1777050991106</updated> <updated>1777050991106</updated>
<workItem from="1777050993247" duration="1296000" /> <workItem from="1777050993247" duration="1899000" />
</task> </task>
<servers /> <servers />
</component> </component>

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 67f88045e5c39dd42af3559790c4c117
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,17 @@
using UnityEngine;
namespace State
{
public class GameState
{
protected Machine StateMachine;
public virtual void OnEnter(Machine machine)
{
StateMachine = machine;
}
public virtual void OnExit() {}
public virtual void OnUpdate(float deltaTime) {}
public virtual void OnFixedUpdate(float deltaTime) {}
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: aece5e36c5691b84592b559518dc979c

View File

@ -0,0 +1,26 @@
using UnityEngine;
namespace State
{
public class Machine : MonoBehaviour
{
private GameState _currentState;
public void Update()
{
_currentState?.OnUpdate(Time.deltaTime);
}
public void FixedUpdate()
{
_currentState?.OnFixedUpdate(Time.fixedDeltaTime);
}
public void ChangeState(GameState newState)
{
_currentState?.OnExit();
_currentState = newState;
_currentState.OnEnter(this);
}
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c58c43f9d69af404f997461c6348049d