REname to AppleMachine
This commit is contained in:
@@ -157,7 +157,7 @@ namespace Editor
|
|||||||
var componentType = component.GetType();
|
var componentType = component.GetType();
|
||||||
if (componentType.Name == "StateMachine" && componentType.Namespace == "Pixelplacement")
|
if (componentType.Name == "StateMachine" && componentType.Namespace == "Pixelplacement")
|
||||||
{
|
{
|
||||||
bool isAlreadySaveable = component is SaveableStateMachine;
|
bool isAlreadySaveable = component is AppleMachine;
|
||||||
foundStateMachines.Add(new StateMachineInfo
|
foundStateMachines.Add(new StateMachineInfo
|
||||||
{
|
{
|
||||||
name = component.gameObject.name,
|
name = component.gameObject.name,
|
||||||
@@ -189,7 +189,7 @@ namespace Editor
|
|||||||
var componentType = component.GetType();
|
var componentType = component.GetType();
|
||||||
if (componentType.Name == "StateMachine" && componentType.Namespace == "Pixelplacement")
|
if (componentType.Name == "StateMachine" && componentType.Namespace == "Pixelplacement")
|
||||||
{
|
{
|
||||||
bool isAlreadySaveable = component is SaveableStateMachine;
|
bool isAlreadySaveable = component is AppleMachine;
|
||||||
foundStateMachines.Add(new StateMachineInfo
|
foundStateMachines.Add(new StateMachineInfo
|
||||||
{
|
{
|
||||||
name = component.gameObject.name,
|
name = component.gameObject.name,
|
||||||
@@ -336,7 +336,7 @@ namespace Editor
|
|||||||
var componentType = component.GetType();
|
var componentType = component.GetType();
|
||||||
if (componentType.Name == "StateMachine" &&
|
if (componentType.Name == "StateMachine" &&
|
||||||
componentType.Namespace == "Pixelplacement" &&
|
componentType.Namespace == "Pixelplacement" &&
|
||||||
!(component is SaveableStateMachine))
|
!(component is AppleMachine))
|
||||||
{
|
{
|
||||||
if (MigrateComponent(component.gameObject, component))
|
if (MigrateComponent(component.gameObject, component))
|
||||||
{
|
{
|
||||||
@@ -369,7 +369,7 @@ namespace Editor
|
|||||||
var componentType = component.GetType();
|
var componentType = component.GetType();
|
||||||
if (componentType.Name == "StateMachine" &&
|
if (componentType.Name == "StateMachine" &&
|
||||||
componentType.Namespace == "Pixelplacement" &&
|
componentType.Namespace == "Pixelplacement" &&
|
||||||
!(component is SaveableStateMachine))
|
!(component is AppleMachine))
|
||||||
{
|
{
|
||||||
bool success = MigrateComponent(gameObject, component);
|
bool success = MigrateComponent(gameObject, component);
|
||||||
|
|
||||||
@@ -412,7 +412,7 @@ namespace Editor
|
|||||||
Object.DestroyImmediate(oldComponent);
|
Object.DestroyImmediate(oldComponent);
|
||||||
|
|
||||||
// Add new component
|
// Add new component
|
||||||
var newSM = gameObject.AddComponent<SaveableStateMachine>();
|
var newSM = gameObject.AddComponent<AppleMachine>();
|
||||||
|
|
||||||
// Restore data using SerializedObject
|
// Restore data using SerializedObject
|
||||||
SerializedObject newSO = new SerializedObject(newSM);
|
SerializedObject newSO = new SerializedObject(newSM);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using Core.SaveLoad;
|
|||||||
using Pixelplacement;
|
using Pixelplacement;
|
||||||
using UnityEngine.Serialization;
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
public class GardenerChaseBehavior : SaveableState
|
public class GardenerChaseBehavior : AppleState
|
||||||
{
|
{
|
||||||
private static readonly int Property = Animator.StringToHash("IsIdle?");
|
private static readonly int Property = Animator.StringToHash("IsIdle?");
|
||||||
public Spline chaseSpline;
|
public Spline chaseSpline;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace Core.SaveLoad
|
|||||||
/// Inherits from Pixelplacement.StateMachine and adds save/load functionality.
|
/// Inherits from Pixelplacement.StateMachine and adds save/load functionality.
|
||||||
/// Use SaveableState (not State) for child states to get save/load hooks.
|
/// Use SaveableState (not State) for child states to get save/load hooks.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SaveableStateMachine : StateMachine, ISaveParticipant
|
public class AppleMachine : StateMachine, ISaveParticipant
|
||||||
{
|
{
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
[Tooltip("Optional custom save ID. If empty, will auto-generate from scene name and hierarchy path.")]
|
[Tooltip("Optional custom save ID. If empty, will auto-generate from scene name and hierarchy path.")]
|
||||||
@@ -36,7 +36,7 @@ namespace Core.SaveLoad
|
|||||||
// If not restoring and change was successful, call OnEnterState
|
// If not restoring and change was successful, call OnEnterState
|
||||||
if (!IsRestoring && result != null && currentState != null)
|
if (!IsRestoring && result != null && currentState != null)
|
||||||
{
|
{
|
||||||
var saveableState = currentState.GetComponent<SaveableState>();
|
var saveableState = currentState.GetComponent<AppleState>();
|
||||||
if (saveableState != null)
|
if (saveableState != null)
|
||||||
{
|
{
|
||||||
saveableState.OnEnterState();
|
saveableState.OnEnterState();
|
||||||
@@ -53,7 +53,7 @@ namespace Core.SaveLoad
|
|||||||
// If not restoring and change was successful, call OnEnterState
|
// If not restoring and change was successful, call OnEnterState
|
||||||
if (!IsRestoring && result != null && currentState != null)
|
if (!IsRestoring && result != null && currentState != null)
|
||||||
{
|
{
|
||||||
var saveableState = currentState.GetComponent<SaveableState>();
|
var saveableState = currentState.GetComponent<AppleState>();
|
||||||
if (saveableState != null)
|
if (saveableState != null)
|
||||||
{
|
{
|
||||||
saveableState.OnEnterState();
|
saveableState.OnEnterState();
|
||||||
@@ -70,7 +70,7 @@ namespace Core.SaveLoad
|
|||||||
// If not restoring and change was successful, call OnEnterState
|
// If not restoring and change was successful, call OnEnterState
|
||||||
if (!IsRestoring && result != null && currentState != null)
|
if (!IsRestoring && result != null && currentState != null)
|
||||||
{
|
{
|
||||||
var saveableState = currentState.GetComponent<SaveableState>();
|
var saveableState = currentState.GetComponent<AppleState>();
|
||||||
if (saveableState != null)
|
if (saveableState != null)
|
||||||
{
|
{
|
||||||
saveableState.OnEnterState();
|
saveableState.OnEnterState();
|
||||||
@@ -158,8 +158,8 @@ namespace Core.SaveLoad
|
|||||||
return JsonUtility.ToJson(new StateMachineSaveData { stateName = "", stateData = "" });
|
return JsonUtility.ToJson(new StateMachineSaveData { stateName = "", stateData = "" });
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveableState saveableState = currentState.GetComponent<SaveableState>();
|
AppleState appleState = currentState.GetComponent<AppleState>();
|
||||||
string stateData = saveableState?.SerializeState() ?? "";
|
string stateData = appleState?.SerializeState() ?? "";
|
||||||
|
|
||||||
var saveData = new StateMachineSaveData
|
var saveData = new StateMachineSaveData
|
||||||
{
|
{
|
||||||
@@ -203,10 +203,10 @@ namespace Core.SaveLoad
|
|||||||
// Now explicitly call OnRestoreState with the saved data
|
// Now explicitly call OnRestoreState with the saved data
|
||||||
if (currentState != null)
|
if (currentState != null)
|
||||||
{
|
{
|
||||||
SaveableState saveableState = currentState.GetComponent<SaveableState>();
|
AppleState appleState = currentState.GetComponent<AppleState>();
|
||||||
if (saveableState != null)
|
if (appleState != null)
|
||||||
{
|
{
|
||||||
saveableState.OnRestoreState(saveData.stateData);
|
appleState.OnRestoreState(saveData.stateData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ namespace Core.SaveLoad
|
|||||||
/// Base class for states that need save/load functionality.
|
/// Base class for states that need save/load functionality.
|
||||||
/// Inherit from this instead of Pixelplacement.State for states in SaveableStateMachines.
|
/// Inherit from this instead of Pixelplacement.State for states in SaveableStateMachines.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class SaveableState : State
|
public class AppleState : State
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when this state is entered during normal gameplay.
|
/// Called when this state is entered during normal gameplay.
|
||||||
@@ -5,7 +5,7 @@ using Pixelplacement;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
||||||
public class GardenerBehaviour : SaveableStateMachine
|
public class GardenerBehaviour : AppleMachine
|
||||||
{
|
{
|
||||||
public void stateSwitch (string StateName)
|
public void stateSwitch (string StateName)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ using Core;
|
|||||||
using Core.SaveLoad;
|
using Core.SaveLoad;
|
||||||
using Pixelplacement;
|
using Pixelplacement;
|
||||||
|
|
||||||
public class LawnMowerBehaviour : SaveableStateMachine
|
public class LawnMowerBehaviour : AppleMachine
|
||||||
{
|
{
|
||||||
public void mowerTouched()
|
public void mowerTouched()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ using Core.SaveLoad;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Pixelplacement;
|
using Pixelplacement;
|
||||||
|
|
||||||
public class LawnMowerChaseBehaviour : SaveableState
|
public class LawnMowerChaseBehaviour : AppleState
|
||||||
{
|
{
|
||||||
public Spline ChaseSpline;
|
public Spline ChaseSpline;
|
||||||
public Transform LawnMowerObject;
|
public Transform LawnMowerObject;
|
||||||
|
|||||||
Reference in New Issue
Block a user