Working gardener saveable behavior tree

This commit is contained in:
Michal Pikulski
2025-11-03 01:34:34 +01:00
parent 14416e141e
commit 3b7bc76757
23 changed files with 2373 additions and 61 deletions

View File

@@ -1,21 +1,15 @@
using System.Security.Cryptography.X509Certificates;
using Core;
using Core.SaveLoad;
using Pixelplacement;
using UnityEngine;
public class GardenerBehaviour : MonoBehaviour
public class GardenerBehaviour : SaveableStateMachine
{
private StateMachine stateMachineRef;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
stateMachineRef = GetComponent<StateMachine>();
}
public void stateSwitch (string StateName)
{
Logging.Debug("State Switch to: " + StateName);
stateMachineRef.ChangeState(StateName);
ChangeState(StateName);
}
}

View File

@@ -1,17 +1,9 @@
using Core;
using UnityEngine;
using Core.SaveLoad;
using Pixelplacement;
public class LawnMowerBehaviour : MonoBehaviour
public class LawnMowerBehaviour : SaveableStateMachine
{
private StateMachine stateMachineRef;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
stateMachineRef = GetComponent<StateMachine>();
}
public void mowerTouched()
{
Logging.Debug("Mower Touched");
@@ -20,6 +12,6 @@ public class LawnMowerBehaviour : MonoBehaviour
public void stateSwitch(string StateName)
{
Logging.Debug("State Switch to: " + StateName);
stateMachineRef.ChangeState(StateName);
ChangeState(StateName);
}
}

View File

@@ -1,7 +1,8 @@
using Core.SaveLoad;
using UnityEngine;
using Pixelplacement;
public class LawnMowerChaseBehaviour : MonoBehaviour
public class LawnMowerChaseBehaviour : SaveableState
{
public Spline ChaseSpline;
public Transform LawnMowerObject;
@@ -23,7 +24,7 @@ public class LawnMowerChaseBehaviour : MonoBehaviour
public bool gardenerChasing = true;
public GardenerAudioController gardenerAudioController;
void Start()
public override void OnEnterState()
{
LawnMowerObject.position = ChaseSpline.GetPosition(startPercentage);
@@ -66,6 +67,11 @@ public class LawnMowerChaseBehaviour : MonoBehaviour
_initialTweenActive = true;
}
public override void OnRestoreState(string data)
{
OnEnterState();
}
void Update()
{
float percentage = ChaseSpline.ClosestPoint(LawnMowerObject.position);