using System.Runtime.InteropServices.WindowsRuntime; using NodeCanvas.Framework; using ParadoxNotion.Design; using UnityEngine; namespace Reset.Items{ [Category("Reset/Combat")] [Description("Check if the provided value matches the weapon actor's variable")] public class CheckWeaponActorVariable : ConditionTask where T : class{ public BBParameter variable; public BBParameter value; WeaponActor actor; protected override string info{ get{ return $"weapon actor variable {variable.value} is {value.value}"; } } //Use for initialization. This is called only once in the lifetime of the task. //Return null if init was successfull. Return an error string otherwise protected override string OnInit(){ return null; } //Called whenever the condition gets enabled. protected override void OnEnable(){ actor = agent.GetComponent(); } //Called whenever the condition gets disabled. protected override void OnDisable(){ } //Called once per frame while the condition is active. //Return whether the condition is success or failure. protected override bool OnCheck(){ if (!actor) { Debug.LogError( $"No weapon actor variable found on this player. Cannot check for value of {variable.value}.", agent); return false; } if (actor.weaponVariables.ContainsKey(variable.value)) { T valueAsType = value.value; Debug.Log((T)actor.weaponVariables[variable.value]); Debug.Log(valueAsType); return ((T)actor.weaponVariables[variable.value]).Equals(valueAsType); } else { Debug.LogError($"No variable found by name {variable.value} on the weapon actor", agent); return false; } } } }