-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
The Dreamer
committed
Jan 18, 2021
1 parent
b928793
commit 98a77f4
Showing
13 changed files
with
244 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEditor; | ||
using UnityEngine; | ||
using IAUS.ECS2.Component; | ||
using IAUS.ECS2; | ||
using Global.Component; | ||
using SpawnerSystem.Editors; | ||
using IAUS.SO.Interfaces; | ||
using Components.MovementSystem; | ||
namespace IAUS.SO.editor | ||
{ | ||
public sealed partial class NPCEditor : EditorWindow { | ||
|
||
void DisplayNPCSOForEditing(NPCSO SO) { | ||
editorState = EditorState.EditExisting; | ||
if (SO.Model) | ||
{ | ||
GetModel = SO.Model; | ||
createRandomCharacter = false; | ||
} | ||
else | ||
createRandomCharacter = true; | ||
GetPatrol = SO.GetPatrol; | ||
GetRetreat = SO.GetRetreat; | ||
GetTargetType = SO.Self.Type; | ||
|
||
GetWait = SO.GetWait; | ||
} | ||
NPCSO GetNPCSO; | ||
void DisplayListOfExistingSO() { | ||
EditorGUILayout.BeginVertical("Box"); | ||
if (!NPCSODatabase.IsLoaded) | ||
NPCSODatabase.LoadDatabase(); | ||
foreach (NPCSO SO in NPCSODatabase.NPCs) | ||
{ | ||
EditorGUILayout.BeginHorizontal(); | ||
//add names | ||
if (GUILayout.Button("testing")) | ||
GetNPCSO = SO; | ||
DisplayNPCSOForEditing(SO); | ||
// delete SO | ||
GUILayout.Button("X", GUILayout.Width(20)); | ||
EditorGUILayout.EndHorizontal(); | ||
} | ||
if (GUILayout.Button("Create New SO")) | ||
{ | ||
editorState = EditorState.CreateNew; | ||
//reset to start values; | ||
} | ||
|
||
EditorGUILayout.EndVertical(); | ||
} | ||
void SaveChanges() { | ||
|
||
List<AIStates> StatesToAdd = new List<AIStates>(); | ||
for (int i = 0; i < showBtn.Length; i++) | ||
{ | ||
if (showBtn[i]) | ||
{ | ||
switch ((AIStates)i) | ||
{ | ||
case AIStates.Patrol: | ||
StatesToAdd.Add(AIStates.Patrol); | ||
break; | ||
case AIStates.Wait: | ||
StatesToAdd.Add(AIStates.Wait); | ||
break; | ||
|
||
} | ||
|
||
} | ||
} | ||
|
||
GetNPCSO.Setup(GetModel, new AITarget() { Type = GetTargetType }, StatesToAdd, GetMove, | ||
GetPatrol, GetWait, GetRetreat | ||
); | ||
SetStartValues(); | ||
|
||
} | ||
|
||
|
||
enum EditorState { | ||
CreateNew, EditExisting | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
Assets/Scripts/IAUS/Scripts/Archetypes Prefabs/NPCSODatabase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace IAUS.SO | ||
{ | ||
public static class NPCSODatabase | ||
{ | ||
static public List<NPCSO> NPCs; | ||
static public bool IsLoaded { get; private set; } = false; | ||
|
||
static private void ValidateDatebase() | ||
{ | ||
if (NPCs == null) NPCs = new List<NPCSO>(); | ||
} | ||
|
||
static public void LoadDatabase() | ||
{ | ||
if (IsLoaded) | ||
return; | ||
LoadDatabaseForce(); | ||
} | ||
static public void LoadDatabaseForce() | ||
{ | ||
ValidateDatebase(); | ||
IsLoaded = true; | ||
NPCSO[] resources = Resources.LoadAll<NPCSO>(@"NPC SO AI"); | ||
foreach (NPCSO squad in resources) | ||
{ | ||
if (!NPCs.Contains(squad)) | ||
NPCs.Add(squad); | ||
} | ||
} | ||
|
||
static public void ClearDatabase() | ||
{ | ||
IsLoaded = false; | ||
NPCs.Clear(); | ||
} | ||
|
||
static public NPCSO GetEnemy(int SpawnID) | ||
{ | ||
ValidateDatebase(); | ||
LoadDatabase(); | ||
foreach (NPCSO squad in NPCs) | ||
{ | ||
if (squad.SpawnID == SpawnID) | ||
return ScriptableObject.Instantiate(squad) as NPCSO; | ||
} | ||
return null; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Assets/Scripts/IAUS/Scripts/Archetypes Prefabs/NPCSODatabase.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
Assets/Systems/InfluenceSystem/Scripts/Influnce System/Component/LeaderInfluence.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters