diff --git a/Assets/Content/Data/DefaultPrefabObjects.asset b/Assets/Content/Data/DefaultPrefabObjects.asset index 7db81e8920..07b1b2e9cb 100644 --- a/Assets/Content/Data/DefaultPrefabObjects.asset +++ b/Assets/Content/Data/DefaultPrefabObjects.asset @@ -13,10 +13,14 @@ MonoBehaviour: m_Name: DefaultPrefabObjects m_EditorClassIdentifier: _prefabs: + - {fileID: 6020083413388562179, guid: dfcd83503e242c843a6bc43cc5040fc9, type: 3} - {fileID: 5177941338532333075, guid: 6deac385bf663034fa7d8dece88c07bb, type: 3} + - {fileID: 7875182825432581152, guid: ad573dedc3cb2d74fa42bedc463ffd75, type: 3} + - {fileID: 1962741444460096580, guid: 14b8b7b37cbe54a44a994f9d927bf213, type: 3} - {fileID: 562230263738288595, guid: 06a27ffa07c1c754c9590607a5a80030, type: 3} - {fileID: 562230263738288595, guid: 59f05e8a3a1d4b94eb5222aed605e260, type: 3} - {fileID: 8203177977882359099, guid: 6ab4ce7059d374a4498481e1385c222e, type: 3} + - {fileID: 6636680625000353110, guid: cc5383d385556f443b2a7d3202f2b2c1, type: 3} - {fileID: 3227132888119106738, guid: 7bbb74a7ffc8cae44baa886de43c586b, type: 3} - {fileID: 1871071288925904272, guid: add4d1bc2d874d94782d6b8c912af5e2, type: 3} - {fileID: 6115335805774105745, guid: bf177f8bab26bc84b87fd9a971004418, type: 3} @@ -62,6 +66,7 @@ MonoBehaviour: - {fileID: -7727686409064562107, guid: 05582ec649a27b64c85729877d9e344d, type: 3} - {fileID: -7727686409064562107, guid: d211f90919bc28a4e8def76cb07197ba, type: 3} - {fileID: 3206407796921847736, guid: 3335d001fdfff824aa859b98f2fe564e, type: 3} + - {fileID: 4302234173120300195, guid: 313c7a6f7eaaf4f4cb80cbe0fe77005d, type: 3} - {fileID: 9154675693299657064, guid: af039f84b4a245049b5b62799af01384, type: 3} - {fileID: 2930813178971533500, guid: 1c3eed1ea37ecc1448e41270cdc63486, type: 3} - {fileID: 1019513474262773944, guid: 06c946c7c639138488b814e4448b82e4, type: 3} @@ -75,6 +80,11 @@ MonoBehaviour: - {fileID: 3258417366846669140, guid: 330d85a67a5891145bd8037dde90f37b, type: 3} - {fileID: 3258417366846669140, guid: dd3ce5340ed4aba4babae7020f737084, type: 3} - {fileID: 4819234911439508660, guid: 11f824c472e04854e95065dda095e8f4, type: 3} + - {fileID: 6348062478285535548, guid: 1d2cf546d53e3fe4c9103007427aaec7, type: 3} + - {fileID: 8767567404870203102, guid: 404443f7c306fc8469698745624fa3bf, type: 3} + - {fileID: 1491149956516498634, guid: b044d7bdb55405046a9055726a779eb1, type: 3} + - {fileID: 4037338737721612837, guid: f88a398ad3d01454f955de9c337d9b99, type: 3} + - {fileID: 1773710978803455870, guid: 4cb99cf2fee96f944abbacc51b0b701c, type: 3} - {fileID: -1308347259443233487, guid: 821d0946be816bb42a0eed24631d57ee, type: 3} - {fileID: 3815592008771065855, guid: 8686fbdb413e33b4395a775c4f2ba990, type: 3} - {fileID: -7727686409064562107, guid: de6f06ad18d50134295959f438ba9c5d, type: 3} @@ -111,6 +121,7 @@ MonoBehaviour: - {fileID: 8635336608555116780, guid: 6caa99f8281726e40a793826d5c047db, type: 3} - {fileID: 9015187684533357890, guid: 5e8a02c5ce0073644ac01bdb55d72a70, type: 3} - {fileID: -2900402353996906960, guid: b5be0a52925e2674193d081d2deb68cb, type: 3} + - {fileID: 885347571389710399, guid: 162e188d33a82b440a239f20901c716a, type: 3} - {fileID: 881130758709618923, guid: 2332a158259900e4f8a237fa8daff266, type: 3} - {fileID: 7958861831329766982, guid: d8b0c8d1ddcdeb24d9763054c103c9fe, type: 3} - {fileID: 7958861831329766982, guid: 79260483ae5d3e04fa272e092b49abac, type: 3} @@ -119,6 +130,11 @@ MonoBehaviour: - {fileID: 2090837846029440516, guid: 3520c433beff78a478401074d2ca95a3, type: 3} - {fileID: 7958861831329766982, guid: d9aabfd5d726a7f499b8e360d919eba4, type: 3} - {fileID: 4819234911439508660, guid: 1ae18785d74e9fa4699b6f6de889c243, type: 3} + - {fileID: 6294647206769462932, guid: 7becfab153276864f9fc7636a839d837, type: 3} + - {fileID: 1602098408367427586, guid: 9c8363ee7f934bd4b8ee5a2e30da1269, type: 3} + - {fileID: 4052990814619214022, guid: 772da386eb7b01745913050fee544c32, type: 3} + - {fileID: 7970185317444620997, guid: 781dd9024aaa53444bc3deeaa9708fbb, type: 3} + - {fileID: 261983550380735922, guid: 411b513efc8f06a40aecfc47d0c5fc5a, type: 3} - {fileID: 6999522401175031449, guid: 9b8a1328991fc2846bc55a3d9a82e5c0, type: 3} - {fileID: 1330758276423851772, guid: 0ef9cea3bb74e6c4788f77e711f92d4d, type: 3} - {fileID: -7180308641962958576, guid: 501391c27a7f94c4d8c937f00a9ceb9f, type: 3} diff --git a/Assets/Content/Systems/UI/InGameConsole/Console.prefab b/Assets/Content/Systems/UI/InGameConsole/Console.prefab index f6f2c12f59..dc3b295459 100644 --- a/Assets/Content/Systems/UI/InGameConsole/Console.prefab +++ b/Assets/Content/Systems/UI/InGameConsole/Console.prefab @@ -90,6 +90,8 @@ GameObject: - component: {fileID: 4468402020721993883} - component: {fileID: 4468402020721993882} - component: {fileID: 4468402020721993861} + - component: {fileID: 2462624425783740797} + - component: {fileID: 6636680625000353110} m_Layer: 5 m_Name: Console m_TagString: Untagged @@ -203,12 +205,60 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 42e2610303da350419124ae8ed8ce88e, type: 3} m_Name: m_EditorClassIdentifier: + _componentIndexCache: 0 + _addedNetworkObject: {fileID: 6636680625000353110} + _networkObjectCache: {fileID: 6636680625000353110} _consolePanel: {fileID: 4468402021449001342} _contentContainer: {fileID: 4468402021075484997} _movingSpeed: 2500 _inputField: {fileID: 4468402021573311568} + _commandsController: {fileID: 2462624425783740797} _allPrevCommands: - +--- !u!114 &2462624425783740797 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4468402020721993860} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9076991674ff4984a7bd0fed6bf0b169, type: 3} + m_Name: + m_EditorClassIdentifier: + _componentIndexCache: 1 + _addedNetworkObject: {fileID: 6636680625000353110} + _networkObjectCache: {fileID: 6636680625000353110} + console: {fileID: 4468402020721993861} +--- !u!114 &6636680625000353110 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 4468402020721993860} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 26b716c41e9b56b4baafaf13a523ba2e, type: 3} + m_Name: + m_EditorClassIdentifier: + k__BackingField: 0 + k__BackingField: 0 + _networkBehaviours: + - {fileID: 4468402020721993861} + - {fileID: 2462624425783740797} + k__BackingField: {fileID: 0} + k__BackingField: [] + _isNetworked: 1 + _isGlobal: 0 + _defaultDespawnType: 0 + NetworkObserver: {fileID: 0} + k__BackingField: -1 + _scenePathHash: 0 + k__BackingField: 0 + k__BackingField: 17889965511288280426 + _sceneNetworkObjects: [] --- !u!1 &4468402021075484997 GameObject: m_ObjectHideFlags: 0 @@ -245,7 +295,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 2, y: -230} + m_AnchoredPosition: {x: 2, y: -68.55036} m_SizeDelta: {x: -2, y: 0} m_Pivot: {x: 0, y: 0} --- !u!222 &4468402021075485017 @@ -1328,7 +1378,7 @@ MonoBehaviour: m_HandleRect: {fileID: 4468402020486027511} m_Direction: 2 m_Value: 0 - m_Size: 1 + m_Size: 0 m_NumberOfSteps: 0 m_OnValueChanged: m_PersistentCalls: diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ChangePermsCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ChangePermsCommand.cs index 01a8a5c1fa..5743ae32bc 100644 --- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ChangePermsCommand.cs +++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ChangePermsCommand.cs @@ -10,7 +10,9 @@ public class ChangePermsCommand : Command public override string LongDescription => "changeperms (user ckey) (required role)"; public override string ShortDescription => "Change user permission"; public override ServerRoleTypes AccessLevel => ServerRoleTypes.User; - public override string Perform(string[] args) + public override bool ServerCommand => true; + + public override string Perform(string[] args) { CheckArgsResponse checkArgsResponse = CheckArgs(args); if (checkArgsResponse.IsValid == false) diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/Command.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/Command.cs index 3f886931fc..b3cceff060 100644 --- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/Command.cs +++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/Command.cs @@ -10,6 +10,8 @@ protected struct CheckArgsResponse public bool IsValid; public string InvalidArgs; } + + public abstract bool ServerCommand { get; } public abstract string ShortDescription { get; } public abstract string LongDescription { get; } public abstract ServerRoleTypes AccessLevel { get; } diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/EchoCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/EchoCommand.cs index e8dc31f55c..6ef1b60467 100644 --- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/EchoCommand.cs +++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/EchoCommand.cs @@ -9,7 +9,8 @@ public class EchoCommand : Command public override string LongDescription => "echo (number) (your string)"; public override string ShortDescription => "Repeat your string"; public override ServerRoleTypes AccessLevel => ServerRoleTypes.User; - public override string Perform(string[] args) + public override bool ServerCommand => true; + public override string Perform(string[] args) { CheckArgsResponse checkArgsResponse = CheckArgs(args); if (checkArgsResponse.IsValid == false) diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/AddTraitCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/AddTraitCommand.cs index 5d052083a1..1fb78405d9 100644 --- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/AddTraitCommand.cs +++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/AddTraitCommand.cs @@ -12,8 +12,9 @@ public class AddTraitCommand : Command public override string LongDescription => "Adds a trait to the item in hand"; public override string ShortDescription => "item.addtrait"; public override ServerRoleTypes AccessLevel => ServerRoleTypes.User; + public override bool ServerCommand => true; - public override string Perform(string[] args) + public override string Perform(string[] args) { CheckArgsResponse checkArgsResponse = CheckArgs(args); if (checkArgsResponse.IsValid == false) diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/DescribeItemCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/DescribeItemCommand.cs index a68e2ab539..6b6b599858 100644 --- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/DescribeItemCommand.cs +++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/DescribeItemCommand.cs @@ -1,4 +1,4 @@ -using SS3D.Systems.Inventory.Items; +using SS3D.Systems.Inventory.Items; using SS3D.Systems.Permissions; namespace SS3D.Systems.IngameConsoleSystem.Commands @@ -11,8 +11,9 @@ public class DescribeItemCommand : Command public override string LongDescription => "Describes the item in hand"; public override string ShortDescription => "item.describe"; public override ServerRoleTypes AccessLevel => ServerRoleTypes.User; + public override bool ServerCommand => false; - public override string Perform(string[] args) + public override string Perform(string[] args) { CheckArgsResponse checkArgsResponse = CheckArgs(args); if (checkArgsResponse.IsValid == false) diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/GetTraitsCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/GetTraitsCommand.cs index 5ef367e74c..cb0f695476 100644 --- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/GetTraitsCommand.cs +++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ItemCommands/GetTraitsCommand.cs @@ -1,4 +1,4 @@ -using SS3D.Systems.Inventory.Items; +using SS3D.Systems.Inventory.Items; using SS3D.Systems.Permissions; namespace SS3D.Systems.IngameConsoleSystem.Commands @@ -11,8 +11,9 @@ public class GetTraitCommand : Command public override string LongDescription => "Get all traits from item in hand"; public override string ShortDescription => "item.traits"; public override ServerRoleTypes AccessLevel => ServerRoleTypes.User; + public override bool ServerCommand => false; - public override string Perform(string[] args) + public override string Perform(string[] args) { CheckArgsResponse checkArgsResponse = CheckArgs(args); if (checkArgsResponse.IsValid == false) diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/KillCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/KillCommand.cs index e875a34a87..18d7da22f8 100644 --- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/KillCommand.cs +++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/KillCommand.cs @@ -10,7 +10,9 @@ public class KillCommand : Command public override string LongDescription => "kill (user ckey)"; public override string ShortDescription => "Kill player"; public override ServerRoleTypes AccessLevel => ServerRoleTypes.User; - public override string Perform(string[] args) + public override bool ServerCommand => true; + + public override string Perform(string[] args) { CheckArgsResponse checkArgsResponse = CheckArgs(args); if (checkArgsResponse.IsValid == false) diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/PlayerListCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/PlayerListCommand.cs index 21abf56d43..3c7edbbdbb 100644 --- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/PlayerListCommand.cs +++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/PlayerListCommand.cs @@ -13,7 +13,9 @@ public class PlayerListCommand : Command public override string ShortDescription => "Show all players online"; public override ServerRoleTypes AccessLevel => ServerRoleTypes.User; - public override string Perform(string[] args) + public override bool ServerCommand => false; + + public override string Perform(string[] args) { CheckArgsResponse checkArgsResponse = CheckArgs(args); if (checkArgsResponse.IsValid == false) diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/QuitCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/QuitCommand.cs index 16a2534bd2..d720dd5399 100644 --- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/QuitCommand.cs +++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/QuitCommand.cs @@ -8,7 +8,9 @@ public class QuitCommand : Command public override string LongDescription => "Close app"; public override string ShortDescription => "Close app"; public override ServerRoleTypes AccessLevel => ServerRoleTypes.User; - public override string Perform(string[] args) + + public override bool ServerCommand => true; + public override string Perform(string[] args) { CheckArgsResponse checkArgsResponse = CheckArgs(args); if (checkArgsResponse.IsValid == false) diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ReconnectCommand.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ReconnectCommand.cs index c919f7aecd..751a066b7f 100644 --- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ReconnectCommand.cs +++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/Commands/ReconnectCommand.cs @@ -9,7 +9,10 @@ public class ReconnectCommand: Command public override string LongDescription => "Restart app"; public override string ShortDescription => "Restart app"; public override ServerRoleTypes AccessLevel => ServerRoleTypes.User; - public override string Perform(string[] args) + + public override bool ServerCommand => true; + + public override string Perform(string[] args) { CheckArgsResponse checkArgsResponse = CheckArgs(args); if (checkArgsResponse.IsValid == false) diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/CommandsController.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/CommandsController.cs index 9b5d57a2dc..62bfd86ef4 100644 --- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/CommandsController.cs +++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/CommandsController.cs @@ -2,11 +2,20 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; +using Codice.Client.Common; +using FishNet.Connection; +using FishNet.Object; +using SS3D.Core; +using SS3D.Core.Behaviours; using SS3D.Systems.IngameConsoleSystem.Commands; +using SS3D.Systems.Permissions; +using SS3D.Systems.PlayerControl; +using UnityEngine; +using UnityEngine.InputSystem; namespace SS3D.Systems.IngameConsoleSystem { - public class CommandsController + public class CommandsController : NetworkActor { /// /// Contains all command infos and their names in lowercase @@ -16,7 +25,10 @@ public class CommandsController /// Length of space between columns in help command /// private const int TabLength = 20; - public CommandsController() + + [SerializeField] private ConsolePanelView console; + + protected override void OnStart() { IEnumerable commands = Assembly.GetAssembly(typeof(Command)).GetTypes().Where(iType => iType.IsClass && iType.IsSubclassOf(typeof(Command)) && !iType.IsAbstract); @@ -29,35 +41,82 @@ public CommandsController() _allCommands.Add(name, instance); } } - /// - /// Find and call command - /// - /// Command and it's args separated by spaces - /// Command response - public string ProcessCommand(string command) + + [Client] + public void ClientProcessCommand(string command) + { + ProcessCommand(command); + } + + /// + /// Find and call command + /// + /// Command and it's args separated by spaces + /// Command response + [ServerRpc(RequireOwnership = false)] + public void ProcessCommand(string command, NetworkConnection conn = null) { - string[] splitCommand = command.Split(' '); + string ckey = Subsystems.Get().GetCkey(conn); + if (!Subsystems.Get().TryGetUserRole(ckey, out ServerRoleTypes userPermission)) + { + CommandAnswer(conn, string.Format("No role found for user {0}, can't process command", ckey)); + } + + string[] splitCommand = command.Split(' '); string commandName = splitCommand[0]; if (commandName == "help") { - return HelpCommand(); + CommandAnswer(conn, HelpCommand()); } if (splitCommand.Length > 1) { if (splitCommand[1] == "help") { - return LongHelpCommand(command); + CommandAnswer(conn, LongHelpCommand(command)); } } - // Find proper command body and prepare correct args - if (_allCommands.ContainsKey(commandName)) + + if (!_allCommands.ContainsKey(commandName)) { - return _allCommands[commandName].Perform(command.Split().Skip(1).ToArray()); - } - return "No such command exists"; - } - /// All available commands with short descriptions - private string HelpCommand() + CommandAnswer(conn, "No such command exists"); + } + + if (_allCommands[commandName].AccessLevel > userPermission) + { + CommandAnswer(conn, "Access level too low, can't perform command"); + } + + if (_allCommands[commandName].ServerCommand) + { + CommandAnswer(conn, _allCommands[commandName].Perform(command.Split().Skip(1).ToArray())); + } + else + { + PerformOnClient(conn, command); + } + + // Find proper command body and prepare correct args + CommandAnswer(conn, _allCommands[commandName].Perform(command.Split().Skip(1).ToArray())); + + } + + [TargetRpc] + public void PerformOnClient(NetworkConnection conn, string command) + { + string[] splitCommand = command.Split(' '); + string commandName = splitCommand[0]; + string answer = _allCommands[commandName].Perform(command.Split().Skip(1).ToArray()); + console.AddText(answer); + } + + [TargetRpc] + public void CommandAnswer(NetworkConnection conn, string answer) + { + console.AddText(answer); + } + + /// All available commands with short descriptions + private string HelpCommand() { string ret = ""; foreach (KeyValuePair i in _allCommands) diff --git a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/ConsolePanelView.cs b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/ConsolePanelView.cs index e17b67a9e2..1fefc8cd3c 100644 --- a/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/ConsolePanelView.cs +++ b/Assets/Scripts/SS3D/Systems/IngameConsoleSystem/ConsolePanelView.cs @@ -1,10 +1,12 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using Coimbra; using Coimbra.Services.Events; using Coimbra.Services.PlayerLoopEvents; +using FishNet.Object; using SS3D.Core; +using SS3D.Core.Behaviours; using SS3D.Systems.Inputs; using TMPro; using UnityEngine; @@ -36,7 +38,9 @@ public class ConsolePanelView : Actor /// Text field with command responses in _contentContainer /// private TextMeshProUGUI _textField; - private CommandsController _commandsController; + + [SerializeField] private CommandsController _commandsController; + // Used for choosing command via arrows [SerializeField] private List _allPrevCommands = new() {""}; private int _chosenPrevCommand; @@ -44,11 +48,10 @@ public class ConsolePanelView : Actor private Controls.ConsoleActions _consoleControls; private InputSystem _inputSystem; - protected override void OnStart() + protected override void OnStart() { base.OnStart(); _textField = _contentContainer.GetComponent(); - _commandsController = new CommandsController(); _inputSystem = Subsystems.Get(); _controls = _inputSystem.Inputs; _consoleControls = _controls.Console; @@ -134,9 +137,10 @@ private void Slide() _isShowed = !_isShowed; } } - /// - /// Handle command taking from input field and showing a response - /// + /// + /// Handle command taking from input field and showing a response + /// + [Client] public void ProcessCommand(string command) { AddText("> " + command + ""); @@ -144,10 +148,11 @@ public void ProcessCommand(string command) _allPrevCommands.Add(command); _allPrevCommands.Add(""); _chosenPrevCommand = _allPrevCommands.Count; - string answer = _commandsController.ProcessCommand(command); - AddText(answer); - } - private void AddText(string text) + _commandsController.ClientProcessCommand(command); + } + + [Client] + public void AddText(string text) { _textField.text += "\n" + text; }