Added Feel plugin

This commit is contained in:
journaliciouz
2025-12-11 14:49:16 +01:00
parent 97dce4aaf6
commit 1942a531d4
2820 changed files with 257786 additions and 9 deletions

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1671a5a55391bd24eb553baa8042d7fb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,84 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
namespace MoreMountains.Tools
{
[CustomPropertyDrawer(typeof(AIAction))]
public class AIActionPropertyInspector : PropertyDrawer
{
const float LineHeight = 16f;
#if UNITY_EDITOR
/// <summary>
/// Draws
/// </summary>
/// <param name="rect"></param>
/// <param name="prop"></param>
/// <param name="label"></param>
public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
{
// determines the height of the Action property
var height = Mathf.Max(LineHeight, EditorGUI.GetPropertyHeight(prop));
Rect position = rect;
position.height = height;
// draws the dropdown
DrawSelectionDropdown(position, prop);
// draws the base field
position.y += height;
EditorGUI.PropertyField(position, prop);
}
#endif
/// <summary>
/// Draws a selector letting the user pick any action associated with the AIBrain this action is on
/// </summary>
/// <param name="position"></param>
/// <param name="prop"></param>
protected virtual void DrawSelectionDropdown(Rect position, SerializedProperty prop)
{
AIAction thisAction = prop.objectReferenceValue as AIAction;
AIAction[] actions = (prop.serializedObject.targetObject as AIBrain).GetAttachedActions();
int selected = 0;
int i = 1;
string[] options = new string[actions.Length + 1];
options[0] = "None";
foreach (AIAction action in actions)
{
string name = string.IsNullOrEmpty(action.Label) ? action.GetType().Name : action.Label;
options[i] = i.ToString() + " - " + name;
if (action == thisAction)
{
selected = i;
}
i++;
}
EditorGUI.BeginChangeCheck();
selected = EditorGUI.Popup(position, selected, options);
if (EditorGUI.EndChangeCheck())
{
prop.objectReferenceValue = (selected == 0) ? null : actions[selected - 1];
prop.serializedObject.ApplyModifiedProperties();
EditorUtility.SetDirty(prop.serializedObject.targetObject);
}
}
/// <summary>
/// Returns the height of the full property
/// </summary>
/// <param name="property"></param>
/// <param name="label"></param>
/// <returns></returns>
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
var h = Mathf.Max(LineHeight, EditorGUI.GetPropertyHeight(property));
float height = h * 2; // 2 lines, one for the dropdown, one for the property field
return height;
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 702bfb9f7cc2a2849a2c16f4087d1c55
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMTools/Foundation/Editor/MMAI/AIActionInspectorDrawer.cs
uploadId: 830868

View File

@@ -0,0 +1,74 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace MoreMountains.Tools
{
[CanEditMultipleObjects]
[CustomEditor(typeof(AIBrain), true)]
public class AIBrainEditor : Editor
{
protected MMReorderableList _list;
protected SerializedProperty _brainActive;
protected SerializedProperty _resetBrainOnEnable;
protected SerializedProperty _resetBrainOnStart;
protected SerializedProperty _timeInThisState;
protected SerializedProperty _target;
protected SerializedProperty _owner;
protected SerializedProperty _actionsFrequency;
protected SerializedProperty _decisionFrequency;
protected SerializedProperty _randomizeFrequencies;
protected SerializedProperty _randomActionFrequency;
protected SerializedProperty _randomDecisionFrequency;
protected virtual void OnEnable()
{
_list = new MMReorderableList(serializedObject.FindProperty("States"));
_list.elementNameProperty = "States";
_list.elementDisplayType = MMReorderableList.ElementDisplayType.Expandable;
_brainActive = serializedObject.FindProperty("BrainActive");
_resetBrainOnEnable = serializedObject.FindProperty("ResetBrainOnEnable");
_resetBrainOnStart = serializedObject.FindProperty("ResetBrainOnStart");
_timeInThisState = serializedObject.FindProperty("TimeInThisState");
_target = serializedObject.FindProperty("Target");
_owner = serializedObject.FindProperty("Owner");
_actionsFrequency = serializedObject.FindProperty("ActionsFrequency");
_decisionFrequency = serializedObject.FindProperty("DecisionFrequency");
_randomizeFrequencies = serializedObject.FindProperty("RandomizeFrequencies");
_randomActionFrequency = serializedObject.FindProperty("RandomActionFrequency");
_randomDecisionFrequency = serializedObject.FindProperty("RandomDecisionFrequency");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
_list.DoLayoutList();
EditorGUILayout.PropertyField(_timeInThisState);
EditorGUILayout.PropertyField(_owner);
EditorGUILayout.PropertyField(_target);
EditorGUILayout.PropertyField(_brainActive);
EditorGUILayout.PropertyField(_resetBrainOnEnable);
EditorGUILayout.PropertyField(_resetBrainOnStart);
EditorGUILayout.PropertyField(_actionsFrequency);
EditorGUILayout.PropertyField(_decisionFrequency);
EditorGUILayout.PropertyField(_randomizeFrequencies);
if (_randomizeFrequencies.boolValue)
{
EditorGUILayout.PropertyField(_randomActionFrequency);
EditorGUILayout.PropertyField(_randomDecisionFrequency);
}
serializedObject.ApplyModifiedProperties();
AIBrain brain = (AIBrain)target;
if (brain.CurrentState != null)
{
EditorGUILayout.Space();
EditorGUILayout.LabelField("Current State", brain.CurrentState.StateName);
}
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 7cd42026e6a9da7479e4c826b64a4df9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMTools/Foundation/Editor/MMAI/AIBrainEditor.cs
uploadId: 830868

View File

@@ -0,0 +1,126 @@
using UnityEngine;
using UnityEditor;
using System.Collections;
namespace MoreMountains.Tools
{
[CustomPropertyDrawer(typeof(AITransition))]
public class AITransitionPropertyInspector : PropertyDrawer
{
const float LineHeight = 16f;
#if UNITY_EDITOR
/// <summary>
/// Draws a Transition inspector, a transition is one or more action(s), one or more decision(s) and associated true/false states
/// </summary>
/// <param name="rect"></param>
/// <param name="prop"></param>
/// <param name="label"></param>
public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
{
Rect position = rect;
foreach (SerializedProperty a in prop)
{
var height = Mathf.Max(LineHeight, EditorGUI.GetPropertyHeight(a));
position.height = height;
if(a.name == "Decision")
{
// draw the decision dropdown
DrawSelectionDropdown(position, prop);
// draw the base decision field
position.y += height;
EditorGUI.PropertyField(position, a, new GUIContent(a.name));
position.y += height;
/*var @object = a.objectReferenceValue;
AIDecision @typedObject = @object as AIDecision;
if (@typedObject != null && !string.IsNullOrEmpty(@typedObject.Label))
{
EditorGUI.LabelField(position, "Label", @typedObject.Label);
position.y += height;
}
else
{
EditorGUIUtility.GetControlID(FocusType.Passive);
}*/
}
else
{
EditorGUI.PropertyField(position, a, new GUIContent(a.name));
position.y += height;
}
}
}
#endif
/// <summary>
/// Draws a selector letting the user pick any decision associated with the AIBrain this transition is on
/// </summary>
/// <param name="position"></param>
/// <param name="prop"></param>
protected virtual void DrawSelectionDropdown(Rect position, SerializedProperty prop)
{
AIDecision thisDecision = prop.objectReferenceValue as AIDecision;
AIDecision[] decisions = (prop.serializedObject.targetObject as AIBrain).GetAttachedDecisions();
int selected = 0;
int i = 1;
string[] options = new string[decisions.Length + 1];
options[0] = "None";
foreach (AIDecision decision in decisions)
{
string name = string.IsNullOrEmpty(decision.Label) ? decision.GetType().Name : decision.Label;
options[i] = i.ToString() + " - " + name;
if (decision == thisDecision)
{
selected = i;
}
i++;
}
EditorGUI.BeginChangeCheck();
selected = EditorGUI.Popup(position, selected, options);
if (EditorGUI.EndChangeCheck())
{
prop.objectReferenceValue = (selected == 0) ? null : decisions[selected - 1];
prop.serializedObject.ApplyModifiedProperties();
EditorUtility.SetDirty(prop.serializedObject.targetObject);
}
}
/// <summary>
/// Determines the height of the transition property
/// </summary>
/// <param name="property"></param>
/// <param name="label"></param>
/// <returns></returns>
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
float height = 0;
foreach (SerializedProperty a in property)
{
var h = Mathf.Max(LineHeight, EditorGUI.GetPropertyHeight(a));
if(a.name == "Decision")
{
height += h * 2;
/*var @object = a.objectReferenceValue;
AIDecision @typedObject = @object as AIDecision;
if (@typedObject != null && !string.IsNullOrEmpty(@typedObject.Label))
{
height += h;
}*/
}
else
{
height += h;
}
}
return height;
}
}
}

View File

@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 40eb84ddcba91054fa1432576815aa6b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMTools/Foundation/Editor/MMAI/AITransitionInspectorDrawer.cs
uploadId: 830868

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1917f0eaf05900748b6f700d0fd6c321
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
using UnityEngine;
using UnityEditor;
namespace MoreMountains.Tools
{
[CustomEditor(typeof(MMAchievementList),true)]
/// <summary>
/// Custom inspector for the MMAchievementList scriptable object.
/// </summary>
public class MMAchievementListInspector : Editor
{
/// <summary>
/// When drawing the GUI, adds a "Reset Achievements" button, that does exactly what you think it does.
/// </summary>
public override void OnInspectorGUI()
{
DrawDefaultInspector ();
MMAchievementList achievementList = (MMAchievementList)target;
if(GUILayout.Button("Reset Achievements"))
{
achievementList.ResetAchievements();
}
EditorUtility.SetDirty (achievementList);
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 70d3db55e641fa4428b605f636e0015b
timeCreated: 1480263802
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMTools/Foundation/Editor/MMAchievements/MMAchievementListInspector.cs
uploadId: 830868

View File

@@ -0,0 +1,19 @@
using UnityEngine;
using System.Collections;
using MoreMountains.Tools;
using UnityEditor;
namespace MoreMountains.Tools
{
public static class MMAchievementMenu
{
[MenuItem("Tools/More Mountains/Reset all achievements", false,21)]
/// <summary>
/// Adds a menu item to enable help
/// </summary>
private static void EnableHelpInInspectors()
{
MMAchievementManager.ResetAllAchievements ();
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: a1d53c42aa1029048b98580478952105
timeCreated: 1482318762
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMTools/Foundation/Editor/MMAchievements/MMAchievementMenu.cs
uploadId: 830868

View File

@@ -0,0 +1,3 @@
{
"reference": "GUID:d9dbf313afb206f458581847ac758375"
}

View File

@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: e08d8cde70b2ab541adf3efc246ef16a
AssemblyDefinitionReferenceImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 183370
packageName: Feel
packageVersion: 5.9.1
assetPath: Assets/Feel/MMTools/Foundation/Editor/MoreMountains.Tools.Foundation.Editor.asmref
uploadId: 830868