From 05e8f0e6fd05f813960217e1acfa29c205058adb Mon Sep 17 00:00:00 2001 From: Damien Date: Wed, 27 May 2020 22:04:52 +0400 Subject: [PATCH] version 0.5 --- .../Content/Prefabs/Ui/[Ui root].prefab | 65 ------------------- .../Prefabs/Ui/characterPortraitWidget.prefab | 30 ++++++--- .../Assets/Content/Prefabs/npc/Chomper.prefab | 18 +---- .../Characters/Ai/CharacterBrain.cs | 10 +++ .../Characters/Ai/CharacterBrain.cs.meta | 11 ++++ .../RpgStation/Characters/BaseCharacter.cs | 31 +++++---- .../Characters/Builders/DefaultNpcBuilder.cs | 2 +- .../Builders/PlayerCharacterBuilder.cs | 2 +- 8 files changed, 63 insertions(+), 106 deletions(-) create mode 100644 station/Assets/RpgStation/Characters/Ai/CharacterBrain.cs create mode 100644 station/Assets/RpgStation/Characters/Ai/CharacterBrain.cs.meta diff --git a/station/Assets/Content/Prefabs/Ui/[Ui root].prefab b/station/Assets/Content/Prefabs/Ui/[Ui root].prefab index 8a1c0be5..45588585 100644 --- a/station/Assets/Content/Prefabs/Ui/[Ui root].prefab +++ b/station/Assets/Content/Prefabs/Ui/[Ui root].prefab @@ -11861,11 +11861,6 @@ PrefabInstance: propertyPath: m_SizeDelta.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 2518230151577645777, guid: 1ab78d5fa53f44cb2ae59ff4797ab4fb, - type: 3} - propertyPath: m_RaycastTarget - value: 0 - objectReference: {fileID: 0} - target: {fileID: 2518230151577645790, guid: 1ab78d5fa53f44cb2ae59ff4797ab4fb, type: 3} propertyPath: m_AnchorMax.x @@ -11876,16 +11871,6 @@ PrefabInstance: propertyPath: m_AnchorMax.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 2518230151704592167, guid: 1ab78d5fa53f44cb2ae59ff4797ab4fb, - type: 3} - propertyPath: m_RaycastTarget - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 2518230151954484969, guid: 1ab78d5fa53f44cb2ae59ff4797ab4fb, - type: 3} - propertyPath: m_RaycastTarget - value: 0 - objectReference: {fileID: 0} - target: {fileID: 2518230151954484982, guid: 1ab78d5fa53f44cb2ae59ff4797ab4fb, type: 3} propertyPath: m_AnchorMax.x @@ -11896,11 +11881,6 @@ PrefabInstance: propertyPath: m_AnchorMax.y value: 0 objectReference: {fileID: 0} - - target: {fileID: 2518230153111852060, guid: 1ab78d5fa53f44cb2ae59ff4797ab4fb, - type: 3} - propertyPath: m_RaycastTarget - value: 0 - objectReference: {fileID: 0} - target: {fileID: 2518230153378732568, guid: 1ab78d5fa53f44cb2ae59ff4797ab4fb, type: 3} propertyPath: m_Name @@ -12011,51 +11991,6 @@ PrefabInstance: propertyPath: m_Pivot.y value: 1 objectReference: {fileID: 0} - - target: {fileID: 5527041148368899741, guid: 1ab78d5fa53f44cb2ae59ff4797ab4fb, - type: 3} - propertyPath: AnimationModels.Array.size - value: 2 - objectReference: {fileID: 0} - - target: {fileID: 5527041148368899741, guid: 1ab78d5fa53f44cb2ae59ff4797ab4fb, - type: 3} - propertyPath: AnimationModels.Array.data[0].AnimationClipModels.Array.size - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 5527041148368899741, guid: 1ab78d5fa53f44cb2ae59ff4797ab4fb, - type: 3} - propertyPath: AnimationModels.Array.data[1].AnimationClipModels.Array.size - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 5527041148368899741, guid: 1ab78d5fa53f44cb2ae59ff4797ab4fb, - type: 3} - propertyPath: AnimationModels.Array.data[0].State - value: alive - objectReference: {fileID: 0} - - target: {fileID: 5527041148368899741, guid: 1ab78d5fa53f44cb2ae59ff4797ab4fb, - type: 3} - propertyPath: AnimationModels.Array.data[0].AnimationClipModels.Array.data[0].Clip - value: - objectReference: {fileID: 7400000, guid: 78f5034ce476a45358aa796324097f9a, type: 2} - - target: {fileID: 5527041148368899741, guid: 1ab78d5fa53f44cb2ae59ff4797ab4fb, - type: 3} - propertyPath: AnimationModels.Array.data[0].AnimationClipModels.Array.data[0].Weight - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 5527041148368899741, guid: 1ab78d5fa53f44cb2ae59ff4797ab4fb, - type: 3} - propertyPath: AnimationModels.Array.data[1].State - value: dead - objectReference: {fileID: 0} - - target: {fileID: 5527041148368899741, guid: 1ab78d5fa53f44cb2ae59ff4797ab4fb, - type: 3} - propertyPath: AnimationModels.Array.data[1].AnimationClipModels.Array.data[0].Clip - value: - objectReference: {fileID: 7400000, guid: 6a68448bb148547199974cbc43fa2b31, type: 2} - - target: {fileID: 5527041148368899741, guid: 1ab78d5fa53f44cb2ae59ff4797ab4fb, - type: 3} - propertyPath: AnimationModels.Array.data[1].AnimationClipModels.Array.data[0].Weight - value: 1 - objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 1ab78d5fa53f44cb2ae59ff4797ab4fb, type: 3} --- !u!114 &6083342869955061713 stripped diff --git a/station/Assets/Content/Prefabs/Ui/characterPortraitWidget.prefab b/station/Assets/Content/Prefabs/Ui/characterPortraitWidget.prefab index a68d3a93..5c8973c4 100644 --- a/station/Assets/Content/Prefabs/Ui/characterPortraitWidget.prefab +++ b/station/Assets/Content/Prefabs/Ui/characterPortraitWidget.prefab @@ -193,7 +193,7 @@ MonoBehaviour: m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 0.0141509175, g: 0.63997257, b: 1, a: 0.8666667} - m_RaycastTarget: 1 + m_RaycastTarget: 0 m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] @@ -242,9 +242,9 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 51.4, y: -4} - m_SizeDelta: {x: 94.8, y: 11.43} - m_Pivot: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 5, y: -4} + m_SizeDelta: {x: 80, y: 11.43} + m_Pivot: {x: 0, y: 0.5} --- !u!222 &2518230151635291578 CanvasRenderer: m_ObjectHideFlags: 0 @@ -307,7 +307,7 @@ MonoBehaviour: m_fontSizeMin: 18 m_fontSizeMax: 72 m_fontStyle: 1 - m_textAlignment: 65535 + m_textAlignment: 257 m_characterSpacing: 0 m_wordSpacing: 0 m_lineSpacing: 0 @@ -496,7 +496,7 @@ MonoBehaviour: m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 0.1509434, g: 0.1509434, b: 0.1509434, a: 1} - m_RaycastTarget: 1 + m_RaycastTarget: 0 m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] @@ -582,7 +582,7 @@ MonoBehaviour: m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 1, g: 0, b: 0, a: 0.8666667} - m_RaycastTarget: 1 + m_RaycastTarget: 0 m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] @@ -696,7 +696,7 @@ MonoBehaviour: m_fontSizeMin: 18 m_fontSizeMax: 72 m_fontStyle: 2 - m_textAlignment: 65535 + m_textAlignment: 260 m_characterSpacing: 0 m_wordSpacing: 0 m_lineSpacing: 0 @@ -998,7 +998,7 @@ MonoBehaviour: m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 0.1509434, g: 0.1509434, b: 0.1509434, a: 1} - m_RaycastTarget: 1 + m_RaycastTarget: 0 m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] @@ -1184,7 +1184,17 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 8cea1f122be2f4ca58fdae85d4bdab5b, type: 3} m_Name: m_EditorClassIdentifier: - AnimationModels: [] + AnimationModels: + - State: alive + AnimationClipModels: + - Clip: {fileID: 7400000, guid: 78f5034ce476a45358aa796324097f9a, type: 2} + Weight: 1 + LayerIndex: 0 + - State: dead + AnimationClipModels: + - Clip: {fileID: 7400000, guid: 6a68448bb148547199974cbc43fa2b31, type: 2} + Weight: 1 + LayerIndex: 0 UseDefaultState: 0 DefaultState: --- !u!111 &2800660740833538975 diff --git a/station/Assets/Content/Prefabs/npc/Chomper.prefab b/station/Assets/Content/Prefabs/npc/Chomper.prefab index 6680871b..8e502b3e 100644 --- a/station/Assets/Content/Prefabs/npc/Chomper.prefab +++ b/station/Assets/Content/Prefabs/npc/Chomper.prefab @@ -2952,7 +2952,6 @@ GameObject: - component: {fileID: 3128725688212506763} - component: {fileID: 5268744292986777152} - component: {fileID: 3232383768615095540} - - component: {fileID: 6076973911399063055} m_Layer: 9 m_Name: Chomper m_TagString: Player @@ -3027,6 +3026,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 526cdf1baba6241abb563dd121e21c69, type: 3} m_Name: m_EditorClassIdentifier: + FloatingPopupAnchor: {fileID: 0} _inputHandler: {fileID: 3128725688212506763} _characterVisual: {fileID: 807293061399403082} --- !u!114 &9074964469764159522 @@ -3043,9 +3043,6 @@ MonoBehaviour: m_EditorClassIdentifier: _movementSettings: _acceleration: 10 - _walkSpeed: 2 - _jogSpeed: 4 - _sprintSpeed: 6 _jumpForce: 10 _gravitySettings: gravityStrength: 27 @@ -3095,19 +3092,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 6fc9d87f2260d47b895850fac9514cf1, type: 3} m_Name: m_EditorClassIdentifier: ---- !u!114 &6076973911399063055 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 8007653114716165723} - m_Enabled: 0 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 4667d50ea7b424dd9b885b60a08dab95, type: 3} - m_Name: - m_EditorClassIdentifier: - input: {fileID: 5268744292986777152} --- !u!1 &8083002350899495092 GameObject: m_ObjectHideFlags: 0 diff --git a/station/Assets/RpgStation/Characters/Ai/CharacterBrain.cs b/station/Assets/RpgStation/Characters/Ai/CharacterBrain.cs new file mode 100644 index 00000000..3b0e1276 --- /dev/null +++ b/station/Assets/RpgStation/Characters/Ai/CharacterBrain.cs @@ -0,0 +1,10 @@ +using UnityEngine; + +namespace Station +{ + public abstract class CharacterBrain : MonoBehaviour + { + public abstract void Setup(BaseCharacter owner); + public abstract void TickBrain(); + } +} diff --git a/station/Assets/RpgStation/Characters/Ai/CharacterBrain.cs.meta b/station/Assets/RpgStation/Characters/Ai/CharacterBrain.cs.meta new file mode 100644 index 00000000..b28fc352 --- /dev/null +++ b/station/Assets/RpgStation/Characters/Ai/CharacterBrain.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 99aee4cbdf7c3400e89573e2e6b13c24 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/station/Assets/RpgStation/Characters/BaseCharacter.cs b/station/Assets/RpgStation/Characters/BaseCharacter.cs index 2e19005f..982c67db 100644 --- a/station/Assets/RpgStation/Characters/BaseCharacter.cs +++ b/station/Assets/RpgStation/Characters/BaseCharacter.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using UnityEngine; namespace Station @@ -44,6 +43,8 @@ public class BaseCharacter : MonoBehaviour private ActionHandler _action = null; public ActionHandler Action => _action; + private CharacterBrain _brain; + private bool _isDead; public bool IsDead @@ -144,17 +145,15 @@ private void OnDestroy() _action.Unsubscribe(); } - public void Init(string characterId, string raceId, string factionId, string genderId, CharacterCalculation instance, string characterName, Dictionary meta = null) + public void Init( + string characterId, + string raceId, + string factionId, + string genderId, + CharacterCalculation instance, + string characterName, + CharacterBrain brain) { - - - if (meta != null) - { - foreach (var entry in meta) - { - AddMeta(entry.Key, entry.Value); - } - } _characterId = characterId; _raceId = raceId; @@ -165,6 +164,10 @@ public void Init(string characterId, string raceId, string factionId, string gen _calculatorInstance = instance; _calculatorInstance.Setup(this); + if (_brain) + { + brain.Setup(this); + } } public void SetRenderer(Renderer cache) @@ -225,6 +228,10 @@ public Stance ResolveStance(BaseCharacter requester) private void Update() { + if (_brain) + { + _brain.TickBrain(); + } _action?.UpdateCombat(); _action?.UpdateLoop(); } diff --git a/station/Assets/RpgStation/Characters/Builders/DefaultNpcBuilder.cs b/station/Assets/RpgStation/Characters/Builders/DefaultNpcBuilder.cs index c60aa1c7..cbdbd378 100644 --- a/station/Assets/RpgStation/Characters/Builders/DefaultNpcBuilder.cs +++ b/station/Assets/RpgStation/Characters/Builders/DefaultNpcBuilder.cs @@ -31,7 +31,7 @@ public override void Build(BaseCharacter character, BaseCharacterData baseData, } calculatorInstance.PreSetup(model); - character.Init(baseData.CharacterId, model.RaceId, model.FactionId, "Male", calculatorInstance, model.Name); + character.Init(baseData.CharacterId, model.RaceId, model.FactionId, "Male", calculatorInstance,model.Name,null); character.SetupAction(model.Attack); character.AddMeta(StationConst.NPC_KEY, baseData.Identifier); character.AddMeta(StationConst.ICON_ID, model.Icon); diff --git a/station/Assets/RpgStation/Characters/Builders/PlayerCharacterBuilder.cs b/station/Assets/RpgStation/Characters/Builders/PlayerCharacterBuilder.cs index e65e85a1..77ff3c94 100644 --- a/station/Assets/RpgStation/Characters/Builders/PlayerCharacterBuilder.cs +++ b/station/Assets/RpgStation/Characters/Builders/PlayerCharacterBuilder.cs @@ -35,7 +35,7 @@ public override void Build(BaseCharacter character, BaseCharacterData baseData, calculatorInstance.PreSetup(classData); - character.Init(baseData.CharacterId,save.RaceId, save.FactionId, save.GenderId, calculatorInstance, save.Name); + character.Init(baseData.CharacterId,save.RaceId, save.FactionId, save.GenderId, calculatorInstance, save.Name, null); character.SetupAction(model.Attack); character.AddMeta(StationConst.CLASS_ID, save.ClassId); character.AddMeta(StationConst.CHARACTER_ID, data[2]);