public float MoodOffsetOfGroup(Thought group)
        {
            this.GetMoodThoughts(group, ThoughtHandler.tmpThoughts);
            float result;

            if (!ThoughtHandler.tmpThoughts.Any <Thought>())
            {
                result = 0f;
            }
            else
            {
                float num  = 0f;
                float num2 = 1f;
                float num3 = 0f;
                for (int i = 0; i < ThoughtHandler.tmpThoughts.Count; i++)
                {
                    Thought thought = ThoughtHandler.tmpThoughts[i];
                    num  += thought.MoodOffset();
                    num3 += num2;
                    num2 *= thought.def.stackedEffectMultiplier;
                }
                float num4 = num / (float)ThoughtHandler.tmpThoughts.Count;
                ThoughtHandler.tmpThoughts.Clear();
                result = num4 * num3;
            }
            return(result);
        }
        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 float MoodOffsetOfGroup(Thought group)
        {
            GetMoodThoughts(group, tmpThoughts);
            if (!tmpThoughts.Any())
            {
                return(0f);
            }
            float num  = 0f;
            float num2 = 1f;
            float num3 = 0f;

            for (int i = 0; i < tmpThoughts.Count; i++)
            {
                Thought thought = tmpThoughts[i];
                num  += thought.MoodOffset();
                num3 += num2;
                num2 *= thought.def.stackedEffectMultiplier;
            }
            float num4 = num / (float)tmpThoughts.Count;

            tmpThoughts.Clear();
            return(num4 * num3);
        }
Beispiel #4
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);
        }