#if HAVE_NODECANVAS
using System;
using System.Text;
using UnityEngine;
using ParadoxNotion.Design;
using NodeCanvas.Framework;
using Framework.Actors;
using Framework.Selection;
namespace Game.Actors {
/// Toggles the look highlighter, enabling or disabling object selection
[Category("Actors")]
[Description("Enable or disable selection for the actor")]
public class ToggleSelectionTask : ActionTask {
/// Actor in which the highlighter will be toggled
[RequiredField]
public BBParameter Actor;
/// Whether to enable or disable selection
public bool EnableSelection = true;
/// Whether to enable or disable highlighting
public bool EnableHighlighting = true;
/// Summary of what this action does
protected override string info {
get {
if (this.EnableHighlighting && this.EnableSelection) {
return "Enable selection and highlighting on " + this.Actor.name;
}
if(!this.EnableHighlighting && !this.EnableSelection) {
return "Disable selection and highlighting on " + this.Actor.name;
}
if (this.EnableSelection) {
return "Enable selection and disable highlighting on " + this.Actor.name;
} else {
return "Dsiable selection and enable highlighting on " + this.Actor.name;
}
}
}
/// Called once when the action is executed
protected override void OnExecute() {
SelectionTracker selectionTracker = this.Actor.value.GetComponent();
if(selectionTracker == null) {
Debug.LogWarning(
"Could not toggle highlighting or selection on '" + this.Actor.name + "' " +
"because the actor does not have a SelectionTracker."
);
return;
}
selectionTracker.CanHighlight = this.EnableHighlighting;
selectionTracker.CanSelect = this.EnableSelection;
EndAction();
}
}
} // namespace namespace Game.Actors
#endif // HAVE_NODECANVAS