init 1.1.2

This commit is contained in:
2025-07-20 10:01:29 +08:00
commit 2afbbf9be4
1327 changed files with 1596159 additions and 0 deletions
@@ -0,0 +1,115 @@
using UnityEngine;
using UnityEditor;
namespace EmeraldAI.Utility
{
[CustomEditor(typeof(EmeraldGeneralTargetBridge))]
[CanEditMultipleObjects]
public class EmeraldGeneralTargetBridgeEditor : Editor
{
GUIStyle FoldoutStyle;
Texture HealthEditorIcon;
SerializedProperty StartHealthProp, ImmortalProp, OnTakeDamageProp, OnDeathProp, HideSettingsFoldout, HealthSettingsFoldout;
void OnEnable()
{
if (HealthEditorIcon == null) HealthEditorIcon = Resources.Load("Editor Icons/EmeraldHealth") as Texture;
HideSettingsFoldout = serializedObject.FindProperty("HideSettingsFoldout");
StartHealthProp = serializedObject.FindProperty("StartingHealth");
ImmortalProp = serializedObject.FindProperty("Immortal");
OnTakeDamageProp = serializedObject.FindProperty("OnTakeDamage");
OnDeathProp = serializedObject.FindProperty("OnDeath");
HealthSettingsFoldout = serializedObject.FindProperty("HealthSettingsFoldout");
}
public override void OnInspectorGUI()
{
FoldoutStyle = CustomEditorProperties.UpdateEditorStyles();
EmeraldGeneralTargetBridge self = (EmeraldGeneralTargetBridge)target;
serializedObject.Update();
CustomEditorProperties.BeginScriptHeaderNew("Target Bridge", HealthEditorIcon, new GUIContent(), HideSettingsFoldout);
if (!HideSettingsFoldout.boolValue)
{
EditorGUILayout.Space();
HealthSetting(self);
EditorGUILayout.Space();
}
serializedObject.ApplyModifiedProperties();
CustomEditorProperties.EndScriptHeader();
}
void HealthSetting (EmeraldGeneralTargetBridge self)
{
HealthSettingsFoldout.boolValue = EditorGUILayout.Foldout(HealthSettingsFoldout.boolValue, "Health Settings", true, FoldoutStyle);
if (HealthSettingsFoldout.boolValue)
{
CustomEditorProperties.BeginFoldoutWindowBox();
CustomEditorProperties.TextTitleWithDescription("Faction Settings", "Allows AI to identify this gameobject without having to rely on Unity's Tag system. This means all potential targets can share the same Unity Tag and Unity Layer.", true);
CustomEditorProperties.CustomPropertyField(ImmortalProp, "Immortal", "Controls whether or not an AI is immune to damage and is unkillable.", true);
EditorGUI.BeginDisabledGroup(self.Immortal);
CustomEditorProperties.CustomPropertyField(StartHealthProp, "Start Health", "Controls the health this AI will start with.", true);
CustomEditorProperties.CustomHelpLabelField("Triggers an event when this target is damaged.", false);
EditorGUILayout.PropertyField(OnTakeDamageProp, new GUIContent("On Take Damage Event"));
EditorGUILayout.Space();
//CustomEditorProperties.CustomPropertyField(OnTakeDamageProp, "On Take Damage Event", "Triggers an event when this target is damaged.", true);
CustomEditorProperties.CustomHelpLabelField("Triggers an event when this target is dies.", false);
EditorGUILayout.PropertyField(OnDeathProp, new GUIContent("On Death Event"));
//CustomEditorProperties.CustomPropertyField(OnDeathProp, "On Death Event", "Triggers an event when this target is dies.", true);
EditorGUI.EndDisabledGroup();
DrawHealthBar(self);
EditorGUILayout.Space();
CustomEditorProperties.EndFoldoutWindowBox();
}
}
void DrawHealthBar(EmeraldGeneralTargetBridge self)
{
GUILayout.Space(45);
GUIStyle LabelStyle = new GUIStyle();
LabelStyle.alignment = TextAnchor.MiddleCenter;
LabelStyle.padding.bottom = 4;
LabelStyle.fontStyle = FontStyle.Bold;
LabelStyle.normal.textColor = Color.white;
Rect r = EditorGUILayout.BeginVertical();
GUI.backgroundColor = Color.white;
float CurrentHealth = ((float)self.Health / (float)self.StartHealth);
if (!Application.isPlaying)
{
self.Health = self.StartHealth;
}
if (CurrentHealth <= 0)
{
CurrentHealth = 0;
}
EditorGUI.DrawRect(new Rect(r.x, r.position.y - 39f, ((r.width)), 32), new Color(0.05f, 0.05f, 0.05f, 0.5f)); //Health Bar BG Outline
EditorGUI.DrawRect(new Rect(r.x + 4, r.position.y - 35f, ((r.width - 8)), 24), new Color(0.16f, 0.16f, 0.16f, 1f)); //Health Bar BG
Color HealthBarColor = Color.Lerp(new Color(0.6f, 0.1f, 0.1f, 1f), new Color(0.15f, 0.42f, 0.15f, 1f), CurrentHealth);
EditorGUI.DrawRect(new Rect(r.x + 4, r.position.y - 35f, ((r.width - 8) * CurrentHealth), 24), HealthBarColor); //Health Bar Main
if (CurrentHealth > 0)
{
EditorGUI.LabelField(new Rect(r.x, r.position.y - 35f, (r.width), 26), "Current Health: " + self.Health + "/" + self.StartHealth, LabelStyle);
}
else
{
EditorGUI.LabelField(new Rect(r.x, r.position.y - 35f, (r.width), 26), "Current Health: " + 0 + "/" + self.StartHealth + " (Dead)", LabelStyle);
}
EditorGUILayout.EndVertical();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0f2200ad73c77b8418c10a2808a92e67
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,91 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEngine.SceneManagement;
using UnityEditor.SceneManagement;
using UnityEditorInternal;
namespace EmeraldAI.Utility
{
[CustomEditor(typeof(FactionExtension))]
[CanEditMultipleObjects]
public class FactionExtensionEditor : Editor
{
GUIStyle FoldoutStyle;
Texture FactionExtensionEditorIcon;
SerializedProperty CurrentFactionProp, HideSettingsFoldout, FactionFoldout;
void OnEnable()
{
if (FactionExtensionEditorIcon == null) FactionExtensionEditorIcon = Resources.Load("Editor Icons/FactionExtension") as Texture;
HideSettingsFoldout = serializedObject.FindProperty("HideSettingsFoldout");
CurrentFactionProp = serializedObject.FindProperty("CurrentFaction");
FactionFoldout = serializedObject.FindProperty("FactionFoldout");
LoadFactionData();
}
public override void OnInspectorGUI()
{
FoldoutStyle = CustomEditorProperties.UpdateEditorStyles();
FactionExtension self = (FactionExtension)target;
serializedObject.Update();
CustomEditorProperties.BeginScriptHeaderNew("Faction Extension", FactionExtensionEditorIcon, new GUIContent(), HideSettingsFoldout);
if (!HideSettingsFoldout.boolValue)
{
EditorGUILayout.Space();
FactionSetting(self);
EditorGUILayout.Space();
}
serializedObject.ApplyModifiedProperties();
CustomEditorProperties.EndScriptHeader();
}
void FactionSetting (FactionExtension self)
{
FactionFoldout.boolValue = EditorGUILayout.Foldout(FactionFoldout.boolValue, "Faction Settings", true, FoldoutStyle);
if (FactionFoldout.boolValue)
{
CustomEditorProperties.BeginFoldoutWindowBox();
CustomEditorProperties.TextTitleWithDescription("Faction Settings", "Allows AI to identify this gameobject without having to rely on Unity's Tag system. This means all potential targets can share the same Unity Tag and Unity Layer.", true);
CustomEditorProperties.FactionListEnum(new Rect(), new GUIContent(), CurrentFactionProp, "Faction", FactionExtension.StringFactionList);
CustomEditorProperties.CustomHelpLabelField("This Faction is used to identify this gameobject and is indended to be used on non-AI objects such as players. This is the name that AI will use when " +
"looking for targets.", true);
CustomEditorProperties.CustomHelpLabelField("Factions can be created and removed using the Faction Manager. ", false);
if (GUILayout.Button("Open Faction Manager"))
{
EditorWindow APS = EditorWindow.GetWindow(typeof(EmeraldFactionManager));
APS.minSize = new Vector2(600f, 775f);
}
EditorGUILayout.Space();
CustomEditorProperties.EndFoldoutWindowBox();
}
}
void LoadFactionData()
{
FactionExtension.StringFactionList.Clear();
string path = AssetDatabase.GetAssetPath(Resources.Load("Faction Data"));
EmeraldFactionData FactionData = (EmeraldFactionData)AssetDatabase.LoadAssetAtPath(path, typeof(EmeraldFactionData));
if (FactionData != null)
{
foreach (string s in FactionData.FactionNameList)
{
if (!FactionExtension.StringFactionList.Contains(s) && s != "")
{
FactionExtension.StringFactionList.Add(s);
}
}
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 680006eba67e3cd4ba330ff9d13654be
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: