private static MoteBubble ExistingMoteBubbleOn(Pawn pawn)
 {
     if (!pawn.Spawned)
     {
         return(null);
     }
     for (int i = 0; i < 4; i++)
     {
         IntVec3 c = pawn.Position + MoteMaker.UpRightPattern[i];
         if (c.InBounds(pawn.Map))
         {
             List <Thing> thingList = pawn.Position.GetThingList(pawn.Map);
             for (int j = 0; j < thingList.Count; j++)
             {
                 Thing      thing      = thingList[j];
                 MoteBubble moteBubble = thing as MoteBubble;
                 if (moteBubble != null && moteBubble.link1.Linked && moteBubble.link1.Target.HasThing && moteBubble.link1.Target == (TargetInfo)pawn)
                 {
                     return(moteBubble);
                 }
             }
         }
     }
     return(null);
 }
        public static MoteBubble MakeThoughtBubble(Pawn pawn, string iconPath, bool maintain = false)
        {
            ExistingMoteBubbleOn(pawn)?.Destroy();
            MoteBubble obj = (MoteBubble)ThingMaker.MakeThing(maintain ? ThingDefOf.Mote_ForceJobMaintained : ThingDefOf.Mote_ForceJob);

            obj.SetupMoteBubble(ContentFinder <Texture2D> .Get(iconPath), null);
            obj.Attach(pawn);
            GenSpawn.Spawn(obj, pawn.Position, pawn.Map);
            return(obj);
        }
        public static MoteBubble MakeMoodThoughtBubble(Pawn pawn, Thought thought)
        {
            MoteBubble result;

            if (Current.ProgramState != ProgramState.Playing)
            {
                result = null;
            }
            else if (!pawn.Spawned)
            {
                result = null;
            }
            else
            {
                float num = thought.MoodOffset();
                if (num == 0f)
                {
                    result = null;
                }
                else
                {
                    MoteBubble moteBubble = MoteMaker.ExistingMoteBubbleOn(pawn);
                    if (moteBubble != null)
                    {
                        if (moteBubble.def == ThingDefOf.Mote_Speech)
                        {
                            return(null);
                        }
                        if (moteBubble.def == ThingDefOf.Mote_ThoughtBad || moteBubble.def == ThingDefOf.Mote_ThoughtGood)
                        {
                            moteBubble.Destroy(DestroyMode.Vanish);
                        }
                    }
                    ThingDef   def         = (num <= 0f) ? ThingDefOf.Mote_ThoughtBad : ThingDefOf.Mote_ThoughtGood;
                    MoteBubble moteBubble2 = (MoteBubble)ThingMaker.MakeThing(def, null);
                    moteBubble2.SetupMoteBubble(thought.Icon, null);
                    moteBubble2.Attach(pawn);
                    GenSpawn.Spawn(moteBubble2, pawn.Position, pawn.Map, WipeMode.Vanish);
                    result = moteBubble2;
                }
            }
            return(result);
        }
        public static MoteBubble MakeInteractionBubble(Pawn initiator, Pawn recipient, ThingDef interactionMote, Texture2D symbol)
        {
            MoteBubble moteBubble = MoteMaker.ExistingMoteBubbleOn(initiator);

            if (moteBubble != null)
            {
                if (moteBubble.def == ThingDefOf.Mote_Speech)
                {
                    moteBubble.Destroy(DestroyMode.Vanish);
                }
                if (moteBubble.def == ThingDefOf.Mote_ThoughtBad || moteBubble.def == ThingDefOf.Mote_ThoughtGood)
                {
                    moteBubble.Destroy(DestroyMode.Vanish);
                }
            }
            MoteBubble moteBubble2 = (MoteBubble)ThingMaker.MakeThing(interactionMote, null);

            moteBubble2.SetupMoteBubble(symbol, recipient);
            moteBubble2.Attach(initiator);
            GenSpawn.Spawn(moteBubble2, initiator.Position, initiator.Map);
            return(moteBubble2);
        }
        public static MoteBubble MakeSpeechBubble(Pawn initiator, Texture2D symbol)
        {
            MoteBubble moteBubble = ExistingMoteBubbleOn(initiator);

            if (moteBubble != null)
            {
                if (moteBubble.def == ThingDefOf.Mote_Speech)
                {
                    moteBubble.Destroy();
                }
                if (moteBubble.def == ThingDefOf.Mote_ThoughtBad || moteBubble.def == ThingDefOf.Mote_ThoughtGood)
                {
                    moteBubble.Destroy();
                }
            }
            MoteBubble obj = (MoteBubble)ThingMaker.MakeThing(ThingDefOf.Mote_Speech);

            obj.SetupMoteBubble(symbol, null);
            obj.Attach(initiator);
            GenSpawn.Spawn(obj, initiator.Position, initiator.Map);
            return(obj);
        }
Example #6
0
        public static MoteBubble MakeMoodThoughtBubble(Pawn pawn, Thought thought)
        {
            if (Current.ProgramState != ProgramState.Playing)
            {
                return(null);
            }
            if (!pawn.Spawned)
            {
                return(null);
            }
            float num = thought.MoodOffset();

            if (num == 0f)
            {
                return(null);
            }
            MoteBubble moteBubble = ExistingMoteBubbleOn(pawn);

            if (moteBubble != null)
            {
                if (moteBubble.def == ThingDefOf.Mote_Speech)
                {
                    return(null);
                }
                if (moteBubble.def == ThingDefOf.Mote_ThoughtBad || moteBubble.def == ThingDefOf.Mote_ThoughtGood)
                {
                    moteBubble.Destroy();
                }
            }
            ThingDef   def         = (!(num > 0f)) ? ThingDefOf.Mote_ThoughtBad : ThingDefOf.Mote_ThoughtGood;
            MoteBubble moteBubble2 = (MoteBubble)ThingMaker.MakeThing(def);

            moteBubble2.SetupMoteBubble(thought.Icon, null);
            moteBubble2.Attach(pawn);
            GenSpawn.Spawn(moteBubble2, pawn.Position, pawn.Map);
            return(moteBubble2);
        }
 private static MoteBubble ExistingMoteBubbleOn(Pawn pawn)
 {
     if (!pawn.Spawned)
     {
         return(null);
     }
     for (int i = 0; i < 4; i++)
     {
         if (!(pawn.Position + UpRightPattern[i]).InBounds(pawn.Map))
         {
             continue;
         }
         List <Thing> thingList = pawn.Position.GetThingList(pawn.Map);
         for (int j = 0; j < thingList.Count; j++)
         {
             MoteBubble moteBubble = thingList[j] as MoteBubble;
             if (moteBubble != null && moteBubble.link1.Linked && moteBubble.link1.Target.HasThing && moteBubble.link1.Target == pawn)
             {
                 return(moteBubble);
             }
         }
     }
     return(null);
 }