Пример #1
0
        public static PersonalityNode MakeNode(PersonalityNodeDef def, Pawn pawn)
        {
            PersonalityNode node = new PersonalityNode(pawn);

            node.def = def;
            node.Initialize();
            return(node);
        }
Пример #2
0
        private static void DrawPersonalityNodes(Rect rect, PsychologyPawn pawn)
        {
            float width = rect.width - 26f - 3f;
            List <PersonalityNode> allNodes = pawn.psyche.PersonalityNodes;

            allNodes.SortBy(p => - p.AdjustedRating, p => p.def.defName);
            PsycheCardUtility.nodeStrings.Clear();
            float num = 0f;

            for (int i = 0; i < allNodes.Count; i++)
            {
                int category = Mathf.RoundToInt(6f * Mathf.InverseLerp(0.16f, 0.83f, allNodes[i].AdjustedRating));
                if (/*!allNodes[i].Core && */ category != 3)
                {
                    string text = (NodeDescriptions[category] == "" ? "" : ("Psyche" + NodeDescriptions[category]).Translate());
                    PsycheCardUtility.nodeStrings.Add(new Pair <string, int>(text, i));
                    num += Mathf.Max(26f, Text.CalcHeight(text, width));
                }
            }
            Rect viewRect = new Rect(0f, 0f, rect.width, num);

            viewRect.xMax *= 0.9f;
            Widgets.BeginScrollView(rect, ref PsycheCardUtility.nodeScrollPosition, viewRect);
            float num3 = 0f;

            for (int j = 0; j < PsycheCardUtility.nodeStrings.Count; j++)
            {
                string          first    = PsycheCardUtility.nodeStrings[j].First;
                PersonalityNode node     = allNodes[PsycheCardUtility.nodeStrings[j].Second];
                float           num4     = Mathf.Max(26f, Text.CalcHeight(first, width));
                Rect            rect2    = new Rect(10f, num3, width / 3, num4);
                Rect            rect3    = new Rect(10f + width / 3, num3, (2 * width) / 3, num4);
                int             category = Mathf.RoundToInt(6f * Mathf.InverseLerp(0.16f, 0.83f, allNodes[PsycheCardUtility.nodeStrings[j].Second].AdjustedRating));
                GUI.color = NodeColors[category];
                Widgets.Label(rect2, first.ToString());
                GUI.color = Color.white;
                Widgets.DrawHighlightIfMouseover(rect3);
                Widgets.Label(rect3, node.def.label.CapitalizeFirst());
                TooltipHandler.TipRegion(rect3, () => node.def.description, 613261 + j * 612);
                num3 += num4;
            }
            GUI.EndScrollView();
        }
        public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks)
        {
            PsychologyPawn  realInitiator = initiator as PsychologyPawn;
            PsychologyPawn  realRecipient = recipient as PsychologyPawn;
            PersonalityNode topic         = (from node in realInitiator.psyche.PersonalityNodes
                                             where !node.Core
                                             select node).RandomElementByWeight(node => realInitiator.psyche.GetConversationTopicWeight(node.def, realRecipient));
            Hediff_Conversation initiatorHediff = (Hediff_Conversation)HediffMaker.MakeHediff(HediffDefOfPsychology.HoldingConversation, realInitiator);

            initiatorHediff.otherPawn   = realRecipient;
            initiatorHediff.topic       = topic.def;
            initiatorHediff.waveGoodbye = true;
            realInitiator.health.AddHediff(initiatorHediff);
            Hediff_Conversation recipientHediff = (Hediff_Conversation)HediffMaker.MakeHediff(HediffDefOfPsychology.HoldingConversation, realRecipient);

            recipientHediff.otherPawn   = realInitiator;
            recipientHediff.topic       = topic.def;
            recipientHediff.waveGoodbye = false;
            realRecipient.health.AddHediff(recipientHediff);
        }
        public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks, out string letterText, out string letterLabel, out LetterDef letterDef)
        {
            letterText  = null;
            letterLabel = null;
            letterDef   = null;
            PersonalityNode topic = (from node in PsycheHelper.Comp(initiator).Psyche.PersonalityNodes
                                     where !node.Core
                                     select node).RandomElementByWeight(node => PsycheHelper.Comp(initiator).Psyche.GetConversationTopicWeight(node.def, recipient));
            string convoTopic = topic.def.conversationTopics.RandomElement();
            Hediff_Conversation initiatorHediff = (Hediff_Conversation)HediffMaker.MakeHediff(HediffDefOfPsychology.HoldingConversation, initiator);

            initiatorHediff.otherPawn   = recipient;
            initiatorHediff.topic       = topic.def;
            initiatorHediff.waveGoodbye = true;
            initiatorHediff.convoTopic  = convoTopic;
            initiator.health.AddHediff(initiatorHediff);
            Hediff_Conversation recipientHediff = (Hediff_Conversation)HediffMaker.MakeHediff(HediffDefOfPsychology.HoldingConversation, recipient);

            recipientHediff.otherPawn   = initiator;
            recipientHediff.topic       = topic.def;
            recipientHediff.waveGoodbye = false;
            recipientHediff.convoTopic  = convoTopic;
            recipient.health.AddHediff(recipientHediff);
        }
Пример #5
0
        private static void DrawPersonalityNodes(Rect rect, Pawn pawn)
        {
            float width = rect.width - 26f - 3f;
            List <PersonalityNode> allNodes = (from n in PsycheHelper.Comp(pawn).Psyche.PersonalityNodes
                                               orderby n.AdjustedRating descending, n.def.defName
                                               select n).ToList();

            PsycheCardUtility.nodeStrings.Clear();
            float num = 0f;

            for (int i = 0; i < allNodes.Count(); i++)
            {
                float rating   = allNodes[i].AdjustedRating;
                float yAxis    = 0.5f - rating;
                float weight   = Mathf.Sqrt(Mathf.Abs(rating - 0.5f)) * (1 / Mathf.Sqrt(0.5f));
                int   category = Mathf.RoundToInt((Categories / 2) - (Categories * yAxis * weight));
                if (/*!allNodes[i].Core && */ category != 3)
                {
                    string text = (NodeDescriptions[category] == "" ? "" : ("Psyche" + NodeDescriptions[category]).Translate());
                    PsycheCardUtility.nodeStrings.Add(new Pair <string, int>(text, i));
                    num += Mathf.Max(26f, Text.CalcHeight(text, width));
                }
            }
            Rect viewRect = new Rect(0f, 0f, rect.width, num);

            viewRect.xMax *= 0.9f;
            Widgets.BeginScrollView(rect, ref PsycheCardUtility.nodeScrollPosition, viewRect);
            float num3 = 0f;

            for (int j = 0; j < PsycheCardUtility.nodeStrings.Count; j++)
            {
                string          first    = PsycheCardUtility.nodeStrings[j].First;
                PersonalityNode node     = allNodes[PsycheCardUtility.nodeStrings[j].Second];
                float           num4     = Mathf.Max(26f, Text.CalcHeight(first, width));
                Rect            rect2    = new Rect(10f, num3, width / 3, num4);
                Rect            rect3    = new Rect(10f + width / 3, num3, (2 * width) / 3, num4);
                float           rating   = node.AdjustedRating;
                float           yAxis    = 0.5f - rating;
                float           weight   = Mathf.Sqrt(Mathf.Abs(rating - 0.5f)) * (1 / Mathf.Sqrt(0.5f));
                int             category = Mathf.RoundToInt((Categories / 2) - (Categories * yAxis * weight));
                GUI.color = NodeColors[category];
                Widgets.Label(rect2, first.ToString());
                if (Prefs.DevMode && Prefs.LogVerbose)
                {
                    TooltipHandler.TipRegion(rect2, delegate { return((100f * node.AdjustedRating) + "%"); }, 693261 + j * 310);
                }
                GUI.color = Color.white;
                Widgets.DrawHighlightIfMouseover(rect3);
                Widgets.Label(rect3, node.def.label.CapitalizeFirst());
                Func <String> descriptionString = delegate
                {
                    if (node.def.conversationTopics != null)
                    {
                        return(node.def.description + "\n\n" + "ConversationTooltip".Translate(string.Join(", ", node.def.conversationTopics.Take(node.def.conversationTopics.Count - 1).ToArray()) + "ConversationAnd".Translate() + node.def.conversationTopics.Last()));
                    }
                    return(node.def.description);
                };
                TooltipHandler.TipRegion(rect3, descriptionString, 613261 + j * 612);
                num3 += num4;
            }
            Widgets.EndScrollView();
        }