コード例 #1
0
ファイル: Locator.cs プロジェクト: Predatorie/QuestLike
        public void LocateSingleObjectOfType <T>(PromptObjectResponse <T> response, bool firstcall = true, bool overrideShow = false) where T : class
        {
            var results = Utilities.CastArray <GameObject, T>(LocateObjectsWithType <T>(false, overrideShow));

            if (results.Length == 0)
            {
                response.Invoke(default, false);
コード例 #2
0
        public static void LocateSingleObjectOfType <T>(string id, PromptObjectResponse <T> response, bool firstcall = true) where T : class
        {
            var results = Utilities.CastArray <GameObject, T>(LocateObjectsWithType <T>(id, firstcall));

            if (results.Length == 0)
            {
                response.Invoke(default(T), false);
            }
            else if (results.Length == 1)
            {
                response.Invoke(results[0] as T, false);
            }
            else
            {
                Utilities.PromptSelection <T>("Select one of the following with the matching tag \"" + id + "\"", results, response);
            }
        }
コード例 #3
0
        public static void LocateSingleObjectOfType <T>(PromptObjectResponse <T> response, bool firstcall = true) where T : class
        {
            var results = Utilities.CastArray <GameObject, T>(LocateObjectsWithType <T>(firstcall));

            if (results.Length == 0)
            {
                response.Invoke(null, false);
            }
            else if (results.Length == 1)
            {
                response.Invoke(results[0] as T, false);
            }
            else
            {
                Utilities.PromptSelection <T>("Select one of the following from these options", results, response);
            }
        }
コード例 #4
0
        public static void LocateSingleObject(string id, PromptObjectResponse <GameObject> response, bool firstcall = true)
        {
            GameObject[] results = Locate(id, firstcall);

            if (results.Length == 0)
            {
                response.Invoke(null, false);
            }
            else if (results.Length == 1)
            {
                response.Invoke(results[0], false);
            }
            else
            {
                Utilities.PromptSelection("Select one of the following with the matching tag \"" + id + "\"", results, response);
            }
        }
コード例 #5
0
ファイル: Utilities.cs プロジェクト: Predatorie/QuestLike
        public static void PromptSelection <T>(string showString, object[] list, PromptObjectResponse <T> response) where T : class
        {
            responseType        = typeof(T);
            userResponse        = response;
            selectableObjects   = list;
            awaitedUserResponse = UserResponseType.GameObject;
            var listed = new List <object>();

            listed.AddRange(list);
            var max = listed.Max((a) => { if (a is GameObject)
                                          {
                                              return((a as GameObject).Name.Length);
                                          }
                                          else
                                          {
                                              return(a.ToString().Length);
                                          } });
            var maxContainerName = listed.Max((a) =>
            {
                if (a is GameObject)
                {
                    if ((a as GameObject).container == null || (a as GameObject).container.Owner is Room)
                    {
                        return(0);
                    }
                    return((a as GameObject).container.Owner.Name.Length);
                }
                return(0);
            });

            if (list.Length == 1)
            {
                response.Invoke(list[0] as T, false);
                return;
            }
            else if (list.Length > 1)
            {
                GameScreen.NewLine();
                GameScreen.PrintLine(showString);
                uuid = System.Guid.NewGuid().ToString();
                for (int i = 0; i < list.Length; i++)
                {
                    if (list[i] is GameObject)
                    {
                        awaitedUserResponse = UserResponseType.GameObject;
                        GameObject j = list[i] as GameObject;
                        GameScreen.PrintLine($"[" + (i + 1) + $"] - <{Color.Cyan.ToInteger()},select " + j.ID + " uuid " + uuid + ">" + (j.Name.PadRight(max, ' ')) + "@");
                        if (j.container != null && !(j.container.Owner is Room))
                        {
                            GameScreen.Print(" - Attatched to " + (j.container.Owner.Name.PadRight(maxContainerName, ' ')));
                        }
                        if (j.ShortDescription != "")
                        {
                            GameScreen.Print(" - " + j.ShortDescription);
                        }
                    }
                    else
                    {
                        awaitedUserResponse = UserResponseType.Index;
                        string name = list[i].ToString();
                        GameScreen.PrintLine($"[" + (i + 1) + $"] - <{Color.Cyan.ToInteger()},index select " + i + " uuid " + uuid + ">" + (name.PadRight(max, ' ')) + "@");
                    }
                }
            }
        }
コード例 #6
0
 public void LocateSingleObjectOfType <T>(string id, PromptObjectResponse <T> response, bool firstcall = true, bool overrideShow = false) where T : class
 {
     ((ILocatable)locator).LocateSingleObjectOfType(id, response, firstcall, overrideShow);
 }
コード例 #7
0
 public void LocateSingleObject(string id, PromptObjectResponse <GameObject> response, bool firstcall = true, bool overrideShow = false)
 {
     ((ILocatable)locator).LocateSingleObject(id, response, firstcall, overrideShow);
 }