public BodyPartType PartWas(GameObject dismembered) { string name = dismembered.GetPart <Description>().Short; if (!name.Contains("severed ")) { return(null); } name = Regex.Replace(name, "^.*?severed ", "", RegexOptions.Singleline); name = Regex.Replace(name, "\\..*", "", RegexOptions.Singleline); name = Regex.Replace(name, "fore", ""); name = Regex.Replace(name, "hind", ""); name = Regex.Replace(name, "mid", ""); name = Grammar.MakeTitleCase(name); if (Anatomies.GetBodyPartType(name) != null) { return(Anatomies.GetBodyPartType(name)); } foreach (string smallname in name.Split(' ')) { if (Anatomies.GetBodyPartType(smallname) != null) { return(Anatomies.GetBodyPartType(smallname)); } } return(null); }
public void Augment(GameObject who, GameObject what) { BodyPartType type = null; if (what.GetPart <acegiak_DismemberSearcher>().Part != null) { type = Anatomies.GetBodyPartType(what.GetPart <acegiak_DismemberSearcher>().Part.Type); } else { type = PartWas(what); } if (type == null) { Popup.Show("You don't know how to attach that."); return; } List <BodyPart> ObjectChoices = new List <BodyPart>(); List <string> ChoiceList = new List <string>(); List <char> HotkeyList = new List <char>(); char ch = 'a'; foreach (BodyPart item in who.GetPart <Body>().GetParts()) { if (!item.Abstract) { ObjectChoices.Add(item); HotkeyList.Add(ch); ChoiceList.Add("attach to " + item.Name); ch = (char)(ch + 1); ObjectChoices.Add(item); HotkeyList.Add(ch); ChoiceList.Add("attach beside " + item.Name); ch = (char)(ch + 1); } } if (ObjectChoices.Count == 0) { Popup.Show("You have no body."); return; } BodyPart part = null; int choicenum = Popup.ShowOptionList(string.Empty, ChoiceList.ToArray(), HotkeyList.ToArray(), 0, "Where to attach " + what.the + what.DisplayNameOnly + "?", 60, false, true); if (what.GetPart <acegiak_DismemberSearcher>() != null && what.GetPart <acegiak_DismemberSearcher>().Part != null) { if (!recurAdd(ObjectChoices[choicenum], what.GetPart <acegiak_DismemberSearcher>().Part, who, choicenum % 2 == 1)) { Popup.Show("Something went awry."); return; } } else { Popup.Show("it had no dismemberedpart."); } what.Destroy(true); who.GetPart <Body>().UpdateBodyParts(); who.GetPart <Body>().RecalculateArmor(); Popup.Show("You augment yourself with a new " + type.Name + "."); }