QZXURLSF73UL67TIXDHMVS7DCFZLQJAPJ6BAGRGXOHH46VMNKGPQC fileFormatVersion: 2guid: 8199d88d544c7364e82d8e4f717fcae9MonoImporter:externalObjects: {}serializedVersion: 2defaultReferences: []executionOrder: 0icon: {instanceID: 0}userData:assetBundleName:assetBundleVariant:
using System;using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.AI;public class MoveToAction : IAction{Vector3 _lastTargetPosition;NavMeshAgent _agent;float _originalStoppingDistance;float _desiredStoppingDistance;bool _isFirstAdvance = true;public MoveToAction(Weaver unit, Vector3 target, float stoppingDistance) {if (unit == null) {throw new ArgumentNullException("unit");}if (stoppingDistance < 0) {throw new ArgumentException("Cannot be < 0", "stoppingDistance");}if (unit.TryGetComponent(out _agent) == false) {throw new ArgumentException("Missing NavMeshAgent", "unit");}_lastTargetPosition = target;_originalStoppingDistance = _agent.stoppingDistance;_desiredStoppingDistance = stoppingDistance;}public bool Advance() {if (_isFirstAdvance) {_agent.stoppingDistance = _desiredStoppingDistance;_agent.isStopped = false;_agent.SetDestination(_lastTargetPosition);_isFirstAdvance = false;}return _agent.pathPending || _agent.remainingDistance > _agent.stoppingDistance;}public bool Cancel() {_agent.isStopped = true;_agent.stoppingDistance = _originalStoppingDistance;_agent.ResetPath();return true;}public float CompletionStatus() {return 0;}public override string ToString() {return $"Move -> {_lastTargetPosition}";}}
}public void SetWatched(IAction action) {_watched = action;if (_watched == null) {_status.fillAmount = 0;} else {_status.fillAmount = _watched.CompletionStatus();
public void SetWatched(IAction action) {_watched = action;if (_watched == null) {_status.fillAmount = 0;}else {_status.fillAmount = _watched.CompletionStatus();}
public int Index { get; set; }TMP_Text ActionName;[SerializeField] EventAggregator _eventAggregator;void Start() {ActionName = GetComponentInChildren<TMP_Text>();}public void OnPointerClick(PointerEventData eventData) {switch (eventData.button) {case PointerEventData.InputButton.Left:break;case PointerEventData.InputButton.Right:HandleRemoveFromPlannedActions();break;
public int Index { get; set; }TMP_Text ActionName;[SerializeField] EventAggregator _eventAggregator;void Start() {ActionName = GetComponentInChildren<TMP_Text>();}public void OnPointerClick(PointerEventData eventData) {switch (eventData.button) {case PointerEventData.InputButton.Left:break;case PointerEventData.InputButton.Right:HandleRemoveFromPlannedActions();break;}
OnUnitMove?.Invoke(this, new UnitMoveArgs(hit.point));
if (Input.GetKey(KeyCode.LeftControl)) {OnUnitMove?.Invoke(this, new UnitMoveArgs(hit.point));}else {eventAggregator.InvokeOnClearPlannedActions(this, EventArgs.Empty);OnUnitMove?.Invoke(this, new UnitMoveArgs(hit.point));}