Иконка ресурса

FREE TalkingNpc : 1.3.1 1.3.1

Нет прав для скачивания
C#:
// Все права принадлежат дискорд сообществу https://discord.gg/VgNHPpNrz6
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Oxide.Core;
using Oxide.Core.Configuration;
using Oxide.Core.Plugins;
using Oxide.Game.Rust.Cui;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using UnityEngine;
using UnityEngine.Networking;
using VLB;

namespace Oxide.Plugins
{
    [Info("TalkingNpc", "Razor/S0N_0F_BISCUIT", "1.3.1")]
    [Description("Adds talking npc to your server")]
    public class TalkingNpc : RustPlugin
    {
        [PluginReference]
        private Plugin CustomVendingSetup, Economics, ServerRewards, SpawnModularCar, Kits, MarkerManager;

        public static TalkingNpc Instance;

        TalkerSpawns TalkerSpawnsData;
        PlayerCooldowns PlayerCooldownsData;
        GlobalCooldowns GlobalCooldownsData;
        DynamicConfigFile TalkerSpawnsFile;
        DynamicConfigFile PlayerCooldownsFile;
        DynamicConfigFile GlobalCooldownsFile;


        Dictionary<ulong, ConversationHandler> PlayerConversations = new Dictionary<ulong, ConversationHandler>();
        Dictionary<InvisibleVendingMachine, string> VendingMachineConfigurations = new Dictionary<InvisibleVendingMachine, string>();
        Dictionary<string, Dictionary<string, object>> VendingMachineDataProviders = new Dictionary<string, Dictionary<string, object>>();

        #region Class Definitions

        static class Commands
        {
            public const string UiAction = "TalkingNpcUIHandler";
            public class UiActions
            {
                public const string OnResponseClicked = "OnResponseClicked";
            }

            public const string ManageNpc = "talking_npc";
            public static class ManageArguments
            {
                public const string Add = "add";
                public const string Monument = "monument";
                public const string Remove = "remove";
            }
            public static class ManageArgumentsHelp
            {
                public const string Add = "<color=#FFFF00>/talking_npc add <Name> <ConversationFile> <true/false></color> - Adds NPC.\n";
                public const string Remove = "<color=#FFFF00>/talking_npc remove <Name> </color> - Removes NPC.\n";
            }

            public const string SpawnVehicle = "talking_npc vehicle spawn";
        }

        static class TalkingNpcHooks
        {
            public const string OnCommand = "OnTalkingNpcCommand";
        }

        static class Permissions
        {
            public const string Admin = "talkingnpc.admin";
        }

        #region User Interface
        public static class Ui
        {
            public static class Anchors
            {
#pragma warning disable IDE0051 // Remove unused private members
                public const string LowerLeft = "0 0";
                public const string UpperLeft = "0 1";
                public const string Center = "0.5 0.5";
                public const string LowerRight = "1 0";
                public const string UpperRight = "1 1";
#pragma warning restore IDE0051 // Remove unused private members
            }

            public static class Colors
            {
                public const string Black = "0 0 0 1";
                public const string Blanc = "0.851 0.820 0.776 1";
                public const string Cloudy = "0.678 0.647 0.620 1";
                public const string DarkGray = "0.12 0.12 0.12 1";
                public const string DarkGreen = "0.145 0.255 0.09 1";
                public const string DarkRed = "0.8 0 0 1";
                public const string DimGray = "0.33 0.33 0.33 1";
                public const string Karaka = "0.16 0.16 0.13 1";
                public const string LightGreen = "0.365 0.447 0.220 1";
                public const string White = "1 1 1 1";

                public static class Transparent
                {
                    public const string Black90 = "0 0 0 0.90";
                    public const string DimGray90 = "0.33 0.33 0.33 0.90";
                    public const string Clear = "0 0 0 0";
                }
            }

            public static class Overlay
            {
                public const string Panel = "Overlay";

                public static class TalkScreen
                {
                    public const string Panel = "TalkingNpc.TalkScreen";
                    public const string TopLetterbox = "TalkingNpc.TalkScreen.TopLetterBox";
                    public const string BottomLetterbox = "TalkingNpc.TalkScreen.BottomLetterBox";

                    public static class Dialog
                    {
                        public const string Panel = "TalkingNpc.TalkScreen.Dialog";
                        public const string CloseButton = "TalkingNpc.TalkScreen.Dialog.CloseButton";

                        public static class Nametag
                        {
                            public const string Panel = "TalkingNpc.TalkScreen.Dialog.Nametag";
                            public const string Text = "TalkingNpc.TalkScreen.Dialog.Nametag.Text";
                        }

                        public static class Message
                        {
                            public const string Panel = "TalkingNpc.TalkScreen.Dialog.Message";
                            public const string Text = "TalkingNpc.TalkScreen.Dialog.Message.Text";
                        }

                        public static class Responses
                        {
                            public const string Panel = "TalkingNpc.TalkScreen.Dialog.Responses";

                            public static class Response
                            {
                                public const string Panel = "TalkingNpc.TalkScreen.Dialog.Response";
                                public const string Text = "TalkingNpc.TalkScreen.Dialog.Response.Text";
                                public const string Button = "TalkingNpc.TalkScreen.Dialog.Response.Button";

                                public static class Number
                                {
                                    public const string Panel = "TalkingNpc.TalkScreen.Dialog.Response.Number";
                                    public const string Text = "TalkingNpc.TalkScreen.Dialog.Response.Number.Text";
                                }
                            }
                        }
                    }
                }
            }

            public class OnResponseClickedCommand
            {
                public string Conversation { get; }
                public uint MessageId { get; }
                public int ResponseIndex { get; }

                public OnResponseClickedCommand(string conversation, uint messageId, int responseIndex)
                {
                    Conversation = conversation;
                    MessageId = messageId;
                    ResponseIndex = responseIndex;
                }

                public override string ToString() => $"{Commands.UiAction} {Commands.UiActions.OnResponseClicked} {Conversation} {MessageId} {ResponseIndex}";
            }
        }

        #endregion

        #region Configuration
        [JsonObject(MemberSerialization.OptIn)]
        class ConfigData
        {
            [JsonProperty(PropertyName = "Settings")]
            public Settings settings { get; set; } = new Settings();

            public class Settings
            {
                [JsonProperty("Admin Permission")]
                public string PermissionUse { get; set; } = Permissions.Admin;

                [JsonProperty("Auto-Close Dialog Distance")]
                public float AutoCloseDialogDistance { get; set; } = 2.6f;
            }

            [JsonProperty(PropertyName = "Version")]
            public VersionNumber Version { get; set; } = Instance.Version;

            public VersionNumber LastBreakingChange { get; private set; } = new VersionNumber(1, 1, 2);
        }
        #endregion

        #region Data

        #region Conversations
        class Currency
        {
            [JsonProperty("Item ID")]
            public int ItemId { get; set; } = -932201673;

            [JsonProperty("Skin ID")]
            public ulong SkinId { get; set; } = 0;
        }

        class Response
        {
            [JsonProperty("Message")]
            public string Message { get; set; }

            [JsonProperty("Needs Permission (null = No)")]
            public string Permission { get; set; }

            [JsonProperty("Player Commands")]
            public List<string> PlayerCommands { get; set; } = new List<string>();

            [JsonProperty("Server Commands")]
            public List<string> ServerCommands { get; set; } = new List<string>();

            [JsonProperty("Next Message (null = Close UI)")]
            public uint? NextMessage { get; set; } = null;

            [JsonProperty("Price")]
            public int Price { get; set; } = 0;

            [JsonProperty("Currency")]
            public Currency Currency { get; set; } = new Currency();

            [JsonProperty("Insufficient Funds Message (null = Close UI)")]
            public uint? InsufficientFundsMessage { get; set; } = null;

            [JsonProperty("Cooldown")]
            public int Cooldown { get; set; } = 0;

            [JsonProperty("Server Wide Cooldown")]
            public bool gCooldown { get; set; } = false;
        }

        class Dialogue
        {
            [JsonProperty("Message")]
            public string Message { get; set; }

            [JsonProperty("Message Display Time (seconds) - Only used if there are no responses")]
            public float MessageDisplayTime { get; set; } = 2f;

            [JsonProperty("Responses")]
            public List<Response> Responses { get; set; } = new List<Response>();
        }

        class ConversationTree : Dictionary<uint, Dialogue> { }

        Dictionary<string, ConversationTree> Conversations = new Dictionary<string, ConversationTree>();

        class ConversationHandler : FacepunchBehaviour
        {
            public NPCTalking NpcTalker { get; private set; } = null;
            public Dictionary<string, InvisibleVendingMachine> VendingMachines { get; private set; } = new Dictionary<string, InvisibleVendingMachine>();

            Dictionary<ulong, BasePlayer> ActiveConversations = new Dictionary<ulong, BasePlayer>();

            private void Awake()
            {
                NpcTalker = GetComponent<NPCTalking>();
            }

            private void OnDestroy()
            {
                foreach (var player in ActiveConversations.Values)
                    EndConversation(player);

                foreach (var vendingMachine in VendingMachines)
                {
                    Instance.VendingMachineConfigurations.Remove(vendingMachine.Value);
                    if (!vendingMachine.Value.IsDestroyed)
                        vendingMachine.Value.Kill();
                }
                VendingMachines.Clear();
            }

            private void CheckPlayersWalkAway()
            {
                foreach (var player in ActiveConversations.Values)
                {
                    if (Vector3.Distance(NpcTalker.transform.position, player.transform.position) > Instance.configData.settings.AutoCloseDialogDistance ||
                        !player.IsConnected || player.IsSleeping())
                        EndConversation(player);
                }

                if (ActiveConversations.Count == 0)
                    CancelInvoke(CheckPlayersWalkAway);
            }

            public void AddVendingMachine(string name, InvisibleVendingMachine vendingMachine) => VendingMachines[name] = vendingMachine;

            public void StartConversation(BasePlayer player, bool walaAway = false)
            {
                if (player == null) return;

                ActiveConversations[player.userID] = player;
                Instance.PlayerConversations[player.userID] = this;

                if (!walaAway && !IsInvoking(CheckPlayersWalkAway))
                    InvokeRepeating(CheckPlayersWalkAway, 0.2f, 0.2f);
            }

            public void EndConversation(BasePlayer player, bool endConversation = true)
            {
                if (player == null) return;

                CuiHelper.DestroyUi(player, Ui.Overlay.TalkScreen.Panel);

                if (endConversation)
                {
                    ActiveConversations.Remove(player.userID);
                    Instance.PlayerConversations.Remove(player.userID);
                }
            }
        }
        #endregion

        #region Cooldowns
        class PlayerCooldowns : Dictionary<ulong, ConversationCooldowns> { }

        class GlobalCooldowns : Dictionary<ulong, ConversationCooldowns> { }

        class ConversationCooldowns : Dictionary<string, MessageCooldowns> { }

        class MessageCooldowns : Dictionary<uint, ResponseCooldowns> { }

        class ResponseCooldowns : Dictionary<int, DateTime> { }
        #endregion

        #region Talker Spawns
        public class TalkerSpawns : Dictionary<string, SavedTalker> { }

        [JsonObject(MemberSerialization.OptIn)]
        public class SavedTalker
        {
            [JsonProperty("Conversation File")]
            public string ConversationFile { get; set; } = "default";

            [JsonProperty("dataFile")]
            private string _ConversationFile { set { ConversationFile = value; } }

            [JsonProperty("Position")]
            public Vector3 Position { get; set; }

            [JsonProperty("position")]
            private Vector3 _Position { set { Position = value; } }

            [JsonProperty("Rotation")]
            public Vector3 Rotation { get; set; }

            [JsonProperty("rotation")]
            private Vector3 _Rotation { set { Rotation = value; } }

            [JsonProperty("Name")]
            public string Name { get; set; }

            [JsonProperty("name")]
            private string _Name { set { Name = value; } }

            [JsonProperty("Kit")]
            public string Kit { get; set; }

            [JsonProperty("NpcUserID")]
            public ulong NpcUserID { get; set; }

            [JsonProperty("CallOnUseNpc")]
            public bool CallOnUseNpc { get; set; }

            [JsonProperty("UseCommand on dialog open closes dialog")]
            public bool useCommandClose { get; set; }

            [JsonProperty("UseCommand on dialog open")]
            public List<string> useCommand { get; set; }

            [JsonProperty("Monument", DefaultValueHandling = DefaultValueHandling.Ignore)]
            public string Monument { get; set; }

            [JsonProperty("monument")]
            private string _Monument { set { Monument = value; } }

            [JsonProperty("Vending Machine Configuration Files")]
            public HashSet<string> VendingMachines { get; set; } = new HashSet<string>();

            [JsonProperty("Umod Marker Manager")]
            public markerInfo UmodMarkersManager { get; set; } = new markerInfo();
           
            public HashSet<ulong> Instances { get; set; } = new HashSet<ulong>();
        }

        public class markerInfo
        {
            public bool enabled = false;
            public string displayName { get; set; } = "newNpc";
            public float radius { get; set; } = 0.4f;
            public string colorMarker { get; set; } = "00FFFF";
            public string colorOutline { get; set; } = "00FFFFFF";
        }
        #endregion

        #endregion

        #endregion

        #region Configuration Handling
        private ConfigData configData;

        protected override void LoadConfig()
        {
            Instance = this;

            base.LoadConfig();
            try
            {
                configData = Config.ReadObject<ConfigData>();
                if (configData == null)
                    LoadDefaultConfig();
                UpdateConfigVersion();
            }
            catch
            {
                PrintError("Your configuration file is invalid");
                UpdateConfig();
                return;
            }
            SaveConfig();
        }

        protected override void LoadDefaultConfig() => configData = new ConfigData();

        protected override void SaveConfig() => Config.WriteObject(configData, true);

        private void UpdateConfig()
        {
            PrintWarning("Invalid config file detected! Backing up current and creating new config...");
            var outdatedConfig = Config.ReadObject<object>();
            Config.WriteObject(outdatedConfig, filename: $"{Name}.Backup");
            LoadDefaultConfig();
            PrintWarning("Config update completed!");
        }

        void UpdateConfigVersion() => configData.Version = Version;
        #endregion

        #region Data Handling
        bool DataFileExists(string path)
        {
            return Interface.Oxide.DataFileSystem.ExistsDatafile($"{Name}/{path}");
        }
        bool ConversationDataFileExists(string path) => DataFileExists($"Conversations/{path}");
        bool VendingMachineDataFileExists(string path) => DataFileExists($"VendingMachines/{path}");

        DynamicConfigFile GetDataFile(string path)
        {
            return Interface.Oxide.DataFileSystem.GetFile($"{Name}/{path}");
        }
        DynamicConfigFile GetConversationDataFile(string path) => GetDataFile($"Conversations/{path}");
        DynamicConfigFile GetVendingMachineDataFile(string path) => GetDataFile($"VendingMachines/{path}");

        bool TryLoadConversation(string filename, out ConversationTree data)
        {
            if (ConversationDataFileExists(filename))
            {
                var file = GetConversationDataFile(filename);
                try
                {
                    data = file.ReadObject<ConversationTree>();
                    return true;
                }
                catch (Exception ex)
                {
                    PrintError($"Error reading data from {file.Filename}: ${ex.Message}");
                }
            }
            data = new ConversationTree();
            return false;
        }

        bool TryLoadVendingMachine(string filename, out JObject data)
        {
            if (VendingMachineDataFileExists(filename))
            {
                var file = GetVendingMachineDataFile(filename);
                try
                {
                    data = file.ReadObject<JObject>();
                    return true;
                }
                catch (Exception ex)
                {
                    PrintError($"Error reading data from {file.Filename}: {ex.Message}");
                }
            }

            data = new JObject();
            return false;
        }

        void SaveConversation(string filename, ConversationTree data)
        {
            GetConversationDataFile(filename).WriteObject(data);
            Conversations[filename] = data;
        }

        void SaveVendingMachine(string filename, JObject vendingMachine)
        {
            GetVendingMachineDataFile(filename).WriteObject(vendingMachine);
        }

        ConversationTree GetConversation(string conversationFile)
        {
            ConversationTree conversation = null;
            if (!Conversations.TryGetValue(conversationFile, out conversation))
                return null;
            return conversation;
        }

        JObject GetVendingMachine(string vendingMachineFile)
        {
            JObject data = new JObject();
            if (!TryLoadVendingMachine(vendingMachineFile, out data))
                return null;
            return data;
        }

        void GenerateDefaultConversation()
        {
            ConversationTree conversation = null;

            if (!TryLoadConversation("default", out conversation))
            {
                if (!ConversationDataFileExists("default"))
                {
                    PrintInfo("Generating default conversation...");

                    conversation.Add(0, new Dialogue()
                    {
                        Message = "Welcome to my shop $displayName.How can I help you?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "I would like to know how you are doing.",
                                NextMessage = 1
                            },
                            new Response()
                            {
                                Message = "I am just saying hi.",
                                NextMessage = 5
                            }
                        }
                    });
                    conversation.Add(1, new Dialogue()
                    {
                        Message = "Im doing good how about you?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "I am ok today.",
                                NextMessage = 2
                            },
                            new Response()
                            {
                                Message = "i dont know.",
                                NextMessage = 3
                            },
                            new Response()
                            {
                                Message = "Life stinks.",
                                NextMessage = 4
                            }
                        }
                    });
                    conversation.Add(2, new Dialogue()
                    {
                        Message = "That is a nice to hear?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "I Will talk to you later",
                                NextMessage = 5
                            }
                        }
                    });
                    conversation.Add(3, new Dialogue()
                    {
                        Message = "Sorry to hear that?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "I guess i will talk to you later.",
                                NextMessage = 5
                            }
                        }
                    });
                    conversation.Add(4, new Dialogue()
                    {
                        Message = "That to bad i hope you day gets better?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "Thank you i will see you later.",
                                NextMessage = 5
                            }
                        }
                    });
                    conversation.Add(5, new Dialogue()
                    {
                        Message = "Let me know if there's anything I can do to help!"
                    });
                    conversation.Add(6, new Dialogue()
                    {
                        Message = "Go get your ride before someone steals it and please stop by again.",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "See you later."
                            }
                        }
                    });
                    conversation.Add(7, new Dialogue()
                    {
                        Message = "I am sorry you do not have enough scrap.",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "I will come back later."
                            }
                        }
                    });

                    SaveConversation("default", conversation);
                }
            }
            else
                SaveConversation("default", conversation);
        }

        public void GenerateModularCarConversation(string convoName = "modularcar")
        {
            ConversationTree conversation = null;

            if (!TryLoadConversation(convoName, out conversation))
            {
                if (!ConversationDataFileExists(convoName))
                {
                    PrintInfo($"Generating {convoName} conversation...");

                    conversation.Add(0, new Dialogue()
                    {
                        Message = "Welcome to my shop $displayName.How can I help you?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "I would like to buy a car.",
                                NextMessage = 1
                            },
                            new Response()
                            {
                                Message = "I am just browsing.",
                                NextMessage = 5
                            }
                        }
                    });
                    conversation.Add(1, new Dialogue()
                    {
                        Message = "A ride you say.Which style ride would you like?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "I would like a small car.",
                                NextMessage = 2
                            },
                            new Response()
                            {
                                Message = "I would like a medium car.",
                                NextMessage = 3
                            },
                            new Response()
                            {
                                Message = "I would like a large car.",
                                NextMessage = 4
                            }
                        }
                    });
                    conversation.Add(2, new Dialogue()
                    {
                        Message = "That is a nice choice.Do you want to buy this ride?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "Here is my 250 scrap.",
                                PlayerCommands = new List<string>()
                                {
                                    $"{Commands.SpawnVehicle} 1 $npcName"
                                },
                                NextMessage = 6,
                                Price = 250,
                                InsufficientFundsMessage = 7
                            },
                            new Response()
                            {
                                Message = "I changed my mind.",
                                NextMessage = 5
                            }
                        }
                    });
                    conversation.Add(3, new Dialogue()
                    {
                        Message = "That is a nice choice.Do you want to buy this ride?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "Here is my 350 scrap.",
                                PlayerCommands = new List<string>()
                                {
                                    $"{Commands.SpawnVehicle} 2 $npcName"
                                },
                                NextMessage = 6,
                                Price = 350,
                                InsufficientFundsMessage = 7
                            },
                            new Response()
                            {
                                Message = "I changed my mind.",
                                NextMessage = 5
                            }
                        }
                    });
                    conversation.Add(4, new Dialogue()
                    {
                        Message = "That is a nice choice.Do you want to buy this ride?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "Here is my 500 scrap.",
                                PlayerCommands = new List<string>()
                                {
                                    $"{Commands.SpawnVehicle} 3 $npcName"
                                },
                                NextMessage = 6,
                                Price = 500,
                                InsufficientFundsMessage = 7
                            },
                            new Response()
                            {
                                Message = "I changed my mind.",
                                NextMessage = 5
                            }
                        }
                    });
                    conversation.Add(5, new Dialogue()
                    {
                        Message = "Let me know if there's anything I can do to help!"
                    });
                    conversation.Add(6, new Dialogue()
                    {
                        Message = "Go get your ride before someone steals it and please stop by again.",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "See you later."
                            }
                        }
                    });
                    conversation.Add(7, new Dialogue()
                    {
                        Message = "I am sorry you do not have enough scrap.",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "I will come back later."
                            }
                        }
                    });

                    SaveConversation(convoName, conversation);
                }
            }
            else
                SaveConversation(convoName, conversation);
        }

        public void GenerateCopterConversation(string convoName = "copter")
        {
            ConversationTree conversation = null;

            if (!TryLoadConversation(convoName, out conversation))
            {
                if (!ConversationDataFileExists(convoName))
                {
                    PrintInfo($"Generating {convoName} conversation...");

                    conversation.Add(0, new Dialogue()
                    {
                        Message = "Welcome to my shop $displayName.How can I help you?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "I would like to buy a copter.",
                                NextMessage = 1
                            },
                            new Response()
                            {
                                Message = "I am just browsing.",
                                NextMessage = 4
                            }
                        }
                    });
                    conversation.Add(1, new Dialogue()
                    {
                        Message = "A copter you say.Which style copter would you like?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "I would like a minicopter.",
                                NextMessage = 2
                            },
                            new Response()
                            {
                                Message = "I would like a scrapcopter.",
                                NextMessage = 3
                            },
                        }
                    });
                    conversation.Add(2, new Dialogue()
                    {
                        Message = "That is a nice choice.Do you want to buy this minicopter?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "Here is my 250 scrap.",
                                PlayerCommands = new List<string>()
                                {
                                    $"{Commands.SpawnVehicle} minicopter $npcName"
                                },
                                NextMessage = 5,
                                Price = 250,
                                InsufficientFundsMessage = 6
                            },
                            new Response()
                            {
                                Message = "I changed my mind.",
                                NextMessage = 5
                            }
                        }
                    });
                    conversation.Add(3, new Dialogue()
                    {
                        Message = "That is a nice choice.Do you want to buy this scrapcopter?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "Here is my 350 scrap.",
                                PlayerCommands = new List<string>()
                                {
                                    $"{Commands.SpawnVehicle} scraptransporthelicopter $npcName"
                                },
                                NextMessage = 5,
                                Price = 350,
                                InsufficientFundsMessage = 6
                            },
                            new Response()
                            {
                                Message = "I changed my mind.",
                                NextMessage = 4
                            }
                        }
                    });

                    conversation.Add(4, new Dialogue()
                    {
                        Message = "Let me know if there's anything I can do to help!"
                    });
                    conversation.Add(5, new Dialogue()
                    {
                        Message = "Go get your ride before someone steals it and please stop by again.",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "See you later."
                            }
                        }
                    });
                    conversation.Add(6, new Dialogue()
                    {
                        Message = "I am sorry you do not have enough scrap.",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "I will come back later."
                            }
                        }
                    });

                    SaveConversation(convoName, conversation);
                }
            }
            else
                SaveConversation(convoName, conversation);
        }

        public void GenerateSnowMobileConversation(string convoName = "defaultsnowmobile")
        {
            ConversationTree conversation = null;

            if (!TryLoadConversation(convoName, out conversation))
            {
                if (!ConversationDataFileExists(convoName))
                {
                    PrintInfo($"Generating {convoName} conversation...");

                    conversation.Add(0, new Dialogue()
                    {
                        Message = "Welcome to my shop $displayName.How can I help you?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "I would like to buy a snowmobile.",
                                NextMessage = 1
                            },
                            new Response()
                            {
                                Message = "I am just browsing.",
                                NextMessage = 4
                            }
                        }
                    });
                    conversation.Add(1, new Dialogue()
                    {
                        Message = "A snowmobile you say.Which style snowmobile would you like?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "I would like a standard.",
                                NextMessage = 2
                            },
                            new Response()
                            {
                                Message = "I would like a Tomaha.",
                                NextMessage = 3
                            },
                        }
                    });
                    conversation.Add(2, new Dialogue()
                    {
                        Message = "That is a nice choice.Do you want to buy this standard snowmobile?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "Here is my 250 scrap.",
                                PlayerCommands = new List<string>()
                                {
                                    $"{Commands.SpawnVehicle} snow $npcName"
                                },
                                NextMessage = 5,
                                Price = 250,
                                InsufficientFundsMessage = 6
                            },
                            new Response()
                            {
                                Message = "I changed my mind.",
                                NextMessage = 5
                            }
                        }
                    });
                    conversation.Add(3, new Dialogue()
                    {
                        Message = "That is a nice choice.Do you want to buy this Tomaha snowmobile?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "Here is my 350 scrap.",
                                PlayerCommands = new List<string>()
                                {
                                    $"{Commands.SpawnVehicle} tomaha $npcName"
                                },
                                NextMessage = 5,
                                Price = 350,
                                InsufficientFundsMessage = 6
                            },
                            new Response()
                            {
                                Message = "I changed my mind.",
                                NextMessage = 4
                            }
                        }
                    });

                    conversation.Add(4, new Dialogue()
                    {
                        Message = "Let me know if there's anything I can do to help!"
                    });
                    conversation.Add(5, new Dialogue()
                    {
                        Message = "Go get your ride before someone steals it and please stop by again.",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "See you later."
                            }
                        }
                    });
                    conversation.Add(6, new Dialogue()
                    {
                        Message = "I am sorry you do not have enough scrap.",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "I will come back later."
                            }
                        }
                    });

                    SaveConversation(convoName, conversation);
                }
            }
            else
                SaveConversation(convoName, conversation);
        }

        public void GenerateBoatConversation(string convoName = "defaultboats")
        {
            ConversationTree conversation = null;

            if (!TryLoadConversation(convoName, out conversation))
            {
                if (!ConversationDataFileExists(convoName))
                {
                    PrintInfo($"Generating {convoName} conversation...");

                    conversation.Add(0, new Dialogue()
                    {
                        Message = "Welcome to my shop $displayName.How can I help you?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "I would like to buy a boat.",
                                NextMessage = 1
                            },
                            new Response()
                            {
                                Message = "I am just browsing.",
                                NextMessage = 4
                            }
                        }
                    });
                    conversation.Add(1, new Dialogue()
                    {
                        Message = "A boat you say.Which style boat would you like?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "I would like a Rowboat.",
                                NextMessage = 2
                            },
                            new Response()
                            {
                                Message = "I would like a RHIB.",
                                NextMessage = 3
                            },
                            new Response()
                            {
                                Message = "I would like a TugBoat.",
                                NextMessage = 7
                            },
                        }
                    });
                    conversation.Add(2, new Dialogue()
                    {
                        Message = "That is a nice choice.Do you want to buy this roawboat?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "Here is my 250 scrap.",
                                PlayerCommands = new List<string>()
                                {
                                    $"{Commands.SpawnVehicle} rowboat $npcName"
                                },
                                NextMessage = 5,
                                Price = 250,
                                InsufficientFundsMessage = 6
                            },
                            new Response()
                            {
                                Message = "I changed my mind.",
                                NextMessage = 5
                            }
                        }
                    });
                    conversation.Add(3, new Dialogue()
                    {
                        Message = "That is a nice choice.Do you want to buy this rhib?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "Here is my 350 scrap.",
                                PlayerCommands = new List<string>()
                                {
                                    $"{Commands.SpawnVehicle} rhib $npcName"
                                },
                                NextMessage = 5,
                                Price = 350,
                                InsufficientFundsMessage = 6
                            },
                            new Response()
                            {
                                Message = "I changed my mind.",
                                NextMessage = 4
                            }
                        }
                    });

                    conversation.Add(4, new Dialogue()
                    {
                        Message = "Let me know if there's anything I can do to help!"
                    });
                    conversation.Add(5, new Dialogue()
                    {
                        Message = "Go get your ride before someone steals it and please stop by again.",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "See you later."
                            }
                        }
                    });
                    
                    conversation.Add(6, new Dialogue()
                    {
                        Message = "I am sorry you do not have enough scrap.",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "I will come back later."
                            }
                        }
                    });

                    conversation.Add(7, new Dialogue()
                    {
                        Message = "That is a nice choice.Do you want to buy this TugBoat?",
                        Responses = new List<Response>()
                        {
                            new Response()
                            {
                                Message = "Here is my 500 scrap.",
                                PlayerCommands = new List<string>()
                                {
                                    $"{Commands.SpawnVehicle} tugboat $npcName"
                                },
                                NextMessage = 5,
                                Price = 500,
                                InsufficientFundsMessage = 6
                
// ... [Code preview truncated due to length. Full source in attached file] ...

Автор
15FPS
Скачиваний
0
Просмотры
1
Первый выпуск
Обновление
Оценка
0.00 звёзд 0 оценок
Сверху