adjustments on saving duration and trigger action belt.

This commit is contained in:
Nilton Constantino 2026-07-02 09:25:51 +01:00
parent 8419962160
commit 2e953f858a
No known key found for this signature in database
11 changed files with 14432 additions and 14412 deletions

View File

@ -234,6 +234,7 @@ MonoBehaviour:
- {fileID: 11400000, guid: 7d96731b441634a59ac45755cd094fff, type: 2}
behaviourTags:
- {fileID: 11400000, guid: ff27007b070ec4488a70def46d82e505, type: 2}
minTimeToTrigger: 0.5
callables:
- {fileID: 2827466454217994421}
--- !u!114 &2827466454217994421

View File

@ -15,4 +15,4 @@ MonoBehaviour:
mode: 0
direction: 1
soundEffect: {fileID: 0}
animationSpeed: 2
animationSpeed: 1

View File

@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6f2337b04d5e44dba892ac6b72ae7e44, type: 3}
m_Name: action-belt.window.hide
m_EditorClassIdentifier: Intrepid General Utilities::Intrepid.Window.Data.WindowAnimationData
mode: 3
mode: 2
direction: 1
soundEffect: {fileID: 0}
animationSpeed: 3
animationSpeed: 4

View File

@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 6f2337b04d5e44dba892ac6b72ae7e44, type: 3}
m_Name: action-belt.window.show
m_EditorClassIdentifier: Intrepid General Utilities::Intrepid.Window.Data.WindowAnimationData
mode: 3
mode: 2
direction: 0
soundEffect: {fileID: 0}
animationSpeed: 3
animationSpeed: 4

View File

@ -15,4 +15,4 @@ MonoBehaviour:
mode: 0
direction: 0
soundEffect: {fileID: 0}
animationSpeed: 2
animationSpeed: 1

View File

@ -15,4 +15,4 @@ MonoBehaviour:
mode: 0
direction: 3
soundEffect: {fileID: 0}
animationSpeed: 2
animationSpeed: 1

View File

@ -15,4 +15,4 @@ MonoBehaviour:
mode: 0
direction: 2
soundEffect: {fileID: 0}
animationSpeed: 2
animationSpeed: 1

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using Intrepid.Core.Tags;
using Intrepid.Utilities;

View File

@ -4,7 +4,6 @@ using Intrepid.Core.Entities;
using Intrepid.Core.Tags;
using Intrepid.GameManagers;
using Intrepid.Gameplay.Entities.Player.ActionBelt.Events;
using Intrepid.Gameplay.Entities.Player.Tags;
using Intrepid.Utilities;
using Sirenix.OdinInspector;
using UnityEngine;
@ -16,12 +15,42 @@ namespace Intrepid.Gameplay.Entities.Player.ActionBelt
{
public class ActionBeltTrigger : EntityTrigger
{
[GroupConfigurations, SerializeField, PropertySpace, PropertyOrder(11), Range(0, 3)] private float minTimeToTrigger = 1.5f;
[GroupConfigurations, SerializeField, PropertySpace, PropertyOrder(12)] private List<ActionCallable> callables;
private Timer Timer { get; } = new();
private bool Triggered { get; set; } = false;
protected override void WhenRaiseEnterEvent(Collider other, EntitySensor entitySensor, List<BehaviourTag> behaviourTags)
{
if (entitySensor.EntityTag is PlayerTag)
Timer.Start();
Triggered = false;
}
protected override void WhenRaiseExitEvent(Collider other, EntitySensor entitySensor)
{
if (!Triggered)
{
Timer.Stop();
return;
}
foreach (var callable in callables)
{
if (callable.IsNull()) continue;
Proxy.Instance.EventBus.Raise(new ActionBeltRemoveByIdEvent
{
ActionId = callable.Id,
});
}
}
private void Update()
{
if (Timer.IsNotRunning) return;
Timer.Update(Timer.ScaledTime);
if (Timer.Check(minTimeToTrigger))
{
Timer.Stop();
foreach (var callable in callables)
{
if (callable.IsNull()) continue;
@ -31,20 +60,7 @@ namespace Intrepid.Gameplay.Entities.Player.ActionBelt
ActionEnvelope = callable.BuildEnvelope(),
});
}
}
}
protected override void WhenRaiseExitEvent(Collider other, EntitySensor entitySensor)
{
if (entitySensor.EntityTag is PlayerTag)
{
foreach (var callable in callables)
{
Proxy.Instance.EventBus.Raise(new ActionBeltRemoveByIdEvent
{
ActionId = callable.Id,
});
}
Triggered = true;
}
}

View File

@ -13,9 +13,10 @@ namespace Intrepid.Gameplay.Entities.Player.Sentinel.StateMachine.States
public class SentinelStateSavingStation : SentinelState
{
[GroupInjections, SerializeField] private AnimationClip savingStation;
[GroupInjections, SerializeField, Range(0, 3)] private float minSavingStationDuration = 1f;
[GroupInjections, SerializeField, Range(0, 5)] private float minSavingStationDuration = 3f;
private Timer Timer { get; } = new();
private bool IsSavingGameIOFinished { get; set; }
public override SentinelStateType GetStateKey()
{
@ -26,12 +27,12 @@ namespace Intrepid.Gameplay.Entities.Player.Sentinel.StateMachine.States
{
Subscribe<SavingGameDataBeginEvent>(_ =>
{
DLogger.LogDebug("Saving started");
DLogger.LogDebug("saving game IO process is going to start!");
});
Subscribe<SavingGameDataEndEvent>(_ =>
{
DLogger.LogDebug("Saving ended");
Timer.Start();
DLogger.LogDebug("saving game IO process is over!");
IsSavingGameIOFinished = true;
});
}
@ -48,13 +49,15 @@ namespace Intrepid.Gameplay.Entities.Player.Sentinel.StateMachine.States
Brain.Entity.Position = deploymentPoint;
Brain.Entity.ChangeOrientation(Vector2.down);
Brain.Entity.ModelAnimation.Play(savingStation);
Timer.Stop();
Timer.Start();
IsSavingGameIOFinished = false;
GameManager.Instance.GameSlotPersistenceService.SaveCurrentGameData();
}
protected override void RunOnExit()
{
Timer.Stop();
IsSavingGameIOFinished = false;
Proxy.Instance.EventBus.Raise(new ActionBeltShowEvent());
}
@ -62,9 +65,11 @@ namespace Intrepid.Gameplay.Entities.Player.Sentinel.StateMachine.States
{
if (Timer.IsNotRunning) return;
Timer.Update(Timer.ScaledTime);
if (Timer.Check(minSavingStationDuration))
if (Timer.Check(minSavingStationDuration) && IsSavingGameIOFinished)
{
DLogger.LogDebug($"Total saving time: {Timer.ElapsedTime:F2}s");
Timer.Stop();
IsSavingGameIOFinished = false;
InputService.Instance.ChangeInputSchema(InputSchema.Sentinel);
Brain.ChangeState(SentinelStateType.Idle);
}