/* * @Author: 白哉 * @Description: * @Date: 2025年06月06日 星期五 19:06:16 * @Modify: */ using System; using System.Collections.Generic; using Logic.AI; using NodeCanvas.Framework; using ParadoxNotion.Design; using RuntimeData; namespace NodeCanvas.Tasks.Actions { [Name("随机概率")] [Category("AI节点")] [Serializable] public class AIParamRandom : BaseActionTask { public float Ratio = 50f; protected override string desc => $"随机概率 >= {Ratio}"; protected override void OnExecute() { base.OnExecute(); // 直接从Blackboard获取AICalculatorData var data = blackboard.GetVariable("Data"); if (data?.value == null) { EndAction(false); return; } var random = new System.Random(); EndAction(random.NextDouble() * 100f >= Ratio); } } }