Beispiel #1
0
        public void AddResponse(NPCConversations npcc, NPCConversationStep npccs, SMCharacter invokingCharacter, List <ShortcutToken> stl, string responseOptions)
        {
            // Set up a list to hold them in the character (if there isn't one already)
            if (this.AwaitingCharacterResponses == null)
            {
                this.AwaitingCharacterResponses = new List <SMNPCAwaitingCharacterResponse>();
            }

            // Create the awaiting response token.
            SMNPCAwaitingCharacterResponse acr = new SMNPCAwaitingCharacterResponse();

            acr.ConversationID      = npcc.ConversationID;
            acr.ConversationStep    = npccs.StepID;
            acr.WaitingForCharacter = invokingCharacter;
            acr.RoomID = this.RoomID;

            // Work out the timeout conversation if there is one.
            string nextStepAfterTimeout = null;
            int    timeout = 10000;

            if (npccs.NextStep != null)
            {
                string[] getNextStep = npccs.NextStep.Split('.');
                nextStepAfterTimeout = getNextStep[0];
                timeout = int.Parse(getNextStep[1]);
            }

            // Set the conversation timeout
            acr.ConversationStepAfterTimeout = nextStepAfterTimeout;
            acr.UnixTimeStampTimeout         = Utility.Utils.GetUnixTimeOffset(timeout);

            // Add the item to the character, and send a message to the player regarding the available responses.
            this.AwaitingCharacterResponses.Add(acr);
            invokingCharacter.SetAwaitingResponse(this.UserID, stl, timeout, this.RoomID);

            if ((responseOptions != null) && (!responseOptions.Contains("{variable}")))
            {
                invokingCharacter.sendMessageToPlayer(responseOptions);
            }
        }