NodeCanvas Forums › Support › CheckInt in Blackboard › Reply To: CheckInt in Blackboard
Hello,
No they are indeed missing, but I’ve added them in the current update.
Here they are:
CheckInt.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
using UnityEngine; using NodeCanvas.Variables; namespace NodeCanvas.Conditions{ [Category("✫ Blackboard")] public class CheckInt : ConditionTask{ public enum CheckTypes { EqualTo, GreaterThan, LessThan } public BBInt valueA = new BBInt{blackboardOnly = true}; public CheckTypes checkType = CheckTypes.EqualTo; public BBInt valueB; protected override string info{ get { string symbol = " == "; if (checkType == CheckTypes.GreaterThan) symbol = " > "; if (checkType == CheckTypes.LessThan) symbol = " < "; return valueA + symbol + valueB; } } protected override bool OnCheck(){ if (checkType == CheckTypes.EqualTo){ if (valueA.value == valueB.value) return true; return false; } if (checkType == CheckTypes.GreaterThan){ if (valueA.value > valueB.value) return true; return false; } if (checkType == CheckTypes.LessThan){ if (valueA.value < valueB.value) return true; return false; } return true; } } } |
SetInt.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
using UnityEngine; using System.Collections; using NodeCanvas.Variables; namespace NodeCanvas.Actions{ [Category("✫ Blackboard")] [Description("Set a blackboard float variable")] public class SetInt : ActionTask{ public enum SetMode { SET, ADD, SUBTRACT, MULTIPLY } public BBInt valueA = new BBInt{blackboardOnly = true}; public SetMode Operation = SetMode.SET; public BBInt valueB; protected override string info{ get { if (Operation == SetMode.SET) return "Set " + valueA + " = " + valueB; if (Operation == SetMode.ADD) return "Set " + valueA + " += " + valueB; if (Operation == SetMode.SUBTRACT) return "Set " + valueA + " -= " + valueB; if (Operation == SetMode.MULTIPLY) return "Set " + valueA + " *= " + valueB; return string.Empty; } } protected override void OnExecute(){ if (Operation == SetMode.SET){ valueA.value = valueB.value; } else if (Operation == SetMode.ADD){ valueA.value += valueB.value; } else if (Operation == SetMode.SUBTRACT){ valueA.value -= valueB.value; } else if (Operation == SetMode.MULTIPLY){ valueA.value *= valueB.value; } EndAction(true); } } } |
Cheers 🙂
Join us on Discord: https://discord.gg/97q2Rjh