using System.Collections; using System.Linq; using System.Collections.Generic; using UnityEngine; using Sirenix.OdinInspector; using KairoEngine.Core; namespace KairoEngine.Core.GameActions { [System.Serializable, HideReferenceObjectPicker] public class CompareBoolGameActionCondition : GameActionCondition { public override string name { get { return $"x equals y"; } } public override GameActionsController controller { get => _controller; set { _controller = value; typeName = "CompareBoolGameActionCondition"; GetCompatibleVariablenames(); } } public override string GetTypeName() => "CompareBoolGameActionCondition"; public override string GetActionName() => "Compare Booleans"; [IconFoldoutGroup("@name","Assets/Plugins/KairoEngine/Core/Editor/Icons/CompareBoolGameActionConditionIcon.png")] [ValueDropdown("possibleVariables", IsUniqueList = false)] public string variable; [IconFoldoutGroup("@name")] public bool result = true; [IconFoldoutGroup("@name")] public bool equals = true; private IEnumerable possibleVariables = new ValueDropdownList(); public override bool Evaluate() { return true; } private void GetCompatibleVariablenames() { possibleVariables = _controller.context.variables .Where(x => x.GetTypeName() == "GameActioncontextBool") .Select(x => new ValueDropdownItem(x.name, x.name)); } public static CompareBoolGameActionCondition JSONToCompareBoolGameActionCondition(string data) { return JsonUtility.FromJson(data); } private CompareBoolGameActionCondition Duplicate() { CompareBoolGameActionCondition condition = new CompareBoolGameActionCondition(); condition.controller = controller; condition.result = result; condition.equals = equals; condition.variable = variable; return condition; } private bool GetVariable(string title) { for (int i = 0; i < controller.context.variables.Count; i++) { if(controller.context.variables[i].name == title) { return controller.context.variables[i].GetValue(false); } } return false; } private void LogMessage(string value, DebugLogGameActionlogType logType) { switch (logType) { case DebugLogGameActionlogType.Log: Debug.Log(value); break; case DebugLogGameActionlogType.Warning: Debug.LogWarning(value); break; case DebugLogGameActionlogType.Error: Debug.LogError(value); break; default: break; } } } }