92 lines
1.8 KiB
C#
Raw Normal View History

2022-03-18 20:49:44 +00:00
using GhostEnums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace QSB.EchoesOfTheEye.Ghosts.Actions;
2022-03-19 00:03:06 +00:00
public class QSBElevatorWalkAction : QSBGhostAction
2022-03-18 20:49:44 +00:00
{
private bool _reachedEndOfPath;
private bool _calledToElevator;
private bool _hasUsedElevator;
private GhostNode _elevatorNode;
public bool reachedEndOfPath
{
get
{
return this._reachedEndOfPath;
}
}
public override GhostAction.Name GetName()
{
return GhostAction.Name.ElevatorWalk;
}
public override float CalculateUtility()
{
2022-04-02 10:54:12 +01:00
if (this._calledToElevator && !this._hasUsedElevator && (_data.interestedPlayer == null || !this._data.interestedPlayer.isPlayerLocationKnown))
2022-03-18 20:49:44 +00:00
{
return 100f;
}
2022-04-02 10:54:12 +01:00
2022-03-18 20:49:44 +00:00
if (this._calledToElevator && !this._hasUsedElevator)
{
return 70f;
}
2022-04-02 10:54:12 +01:00
2022-03-18 20:49:44 +00:00
return -100f;
}
public void UseElevator()
{
this._hasUsedElevator = true;
}
public void CallToUseElevator()
{
this._calledToElevator = true;
2022-04-07 08:57:51 +01:00
if (this._controller.AttachedObject.GetNodeMap().GetPathNodes().Length > 1)
2022-03-18 20:49:44 +00:00
{
2022-04-07 08:57:51 +01:00
this._elevatorNode = this._controller.AttachedObject.GetNodeMap().GetPathNodes()[1];
2022-03-18 20:49:44 +00:00
this._controller.PathfindToNode(this._elevatorNode, MoveType.PATROL);
return;
}
Debug.LogError("MissingElevatorNode");
}
protected override void OnEnterAction()
{
this._controller.SetLanternConcealed(true, true);
this._controller.FaceVelocity();
2022-04-14 13:00:24 +01:00
this._effects.PlayDefaultAnimation();
2022-04-14 12:38:34 +01:00
this._effects.SetMovementStyle(GhostEffects.MovementStyle.Normal);
2022-03-18 20:49:44 +00:00
if (this._elevatorNode != null)
{
this._controller.PathfindToNode(this._elevatorNode, MoveType.PATROL);
}
}
protected override void OnExitAction()
{
}
public override bool Update_Action()
{
return true;
}
public override void OnArriveAtPosition()
{
this._reachedEndOfPath = true;
}
}