/// <summary>
 /// Displays the active mote when applicable.
 /// </summary>
 public void DisplayActiveMote()
 {
     foreach (Pawn colonist in Find.MapPawns.FreeColonists)
     {
         MoteAttached bonusMalusMote = null;
         if (CheckIfColonistHasASmallAdrenalineBoostBonus(colonist))
         {
             bonusMalusMote = ThingMaker.MakeThing(Util_AlertSpeaker.SmallAdrenalineBoostMoteDef) as MoteAttached;
             bonusMalusMote.AttachTo(colonist);
             GenSpawn.Spawn(bonusMalusMote, colonist.Position);
         }
         else if (CheckIfColonistHasAMediumAdrenalineBoostBonus(colonist))
         {
             bonusMalusMote = ThingMaker.MakeThing(Util_AlertSpeaker.MediumAdrenalineBoostMoteDef) as MoteAttached;
             bonusMalusMote.AttachTo(colonist);
             GenSpawn.Spawn(bonusMalusMote, colonist.Position);
         }
         else if (CheckIfColonistHasASmallStressMalus(colonist))
         {
             bonusMalusMote = ThingMaker.MakeThing(Util_AlertSpeaker.SmallStressMoteDef) as MoteAttached;
             bonusMalusMote.AttachTo(colonist);
             GenSpawn.Spawn(bonusMalusMote, colonist.Position);
         }
     }
 }
        protected Toil GetToilPlayTheGuitar()
        {
            int tickCounter = 0;

            Toil toil = new Toil()
            {
                initAction = () =>
                {
                    tickCounter = Rand.Range(35, 50);
                    MoteAttached moteAttached = (MoteAttached)ThingMaker.MakeThing(Util_CampfireParty.Mote_Guitar);
                    moteAttached.AttachTo(this.pawn);
                    GenSpawn.Spawn(moteAttached, this.pawn.Position);
                    this.pawn.Drawer.rotator.FaceCell(this.pawn.Position + new IntVec3(0, 0, -1));
                },
                tickAction = () =>
                {
                    tickCounter--;
                    if (tickCounter <= 0)
                    {
                        tickCounter = Rand.Range(35, 50);
                        MoteThrower.ThrowDrift(this.pawn.Position, Util_CampfireParty.Mote_MusicNote);
                    }
                    // Gain some joy.
                    this.pawn.needs.joy.GainJoy(this.CurJob.def.joyGainRate * 0.000144f, Util_CampfireParty.JoyKindDefOf_Social);
                    this.pawn.Drawer.rotator.FaceCell(this.pawn.Position + new IntVec3(0, 0, -1));
                },
                defaultDuration     = 240,
                defaultCompleteMode = ToilCompleteMode.Delay
            };

            return(toil);
        }
示例#3
0
        public static void MakeSpeechOverlay(Thing talker)
        {
            MoteAttached moteAttached =
                (MoteAttached)ThingMaker.MakeThing(DefDatabase <ThingDef> .GetNamed("Mote_Speech"));

            moteAttached.ScaleUniform = 1.25f;
            moteAttached.AttachTo(talker);
            GenSpawn.Spawn(moteAttached, talker.Position);
        }
示例#4
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            List <Toil>   toilsList       = new List <Toil>();
            Building_Pyre pyre            = this.TargetThingA as Building_Pyre;
            bool          beerIsAvailable = false;

            if (this.pawn.Position.InHorDistOf(pyre.Position, Building_Pyre.partyAreaRadius) == false)
            {
                // Go around pyre.
                toilsList.Add(base.ToilGetWanderCell(pyre.Position));
                Find.PawnDestinationManager.ReserveDestinationFor(this.pawn, this.CurJob.targetB.Cell);
                toilsList.Add(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.OnCell));
                // Release cell (the pawn will either go grab a beer or move on the next job).
                toilsList.Add(base.ToilReleaseCell());
            }
            // Look for an available beer.
            List <Thing> list = Find.ListerThings.ThingsOfDef(ThingDefOf.Beer);

            if (list.Count > 0)
            {
                Predicate <Thing> validator = (Thing t) => pawn.CanReserve(t, 1) && !t.IsForbidden(pawn);
                Thing             beer      = GenClosest.ClosestThing_Global_Reachable(pyre.Position, list, PathEndMode.OnCell, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), Building_Pyre.beerSearchAreaRadius, validator, null);
                if (beer != null)
                {
                    beerIsAvailable = true;
                    this.CurJob.SetTarget(TargetIndex.A, beer);
                    //this.CurJob.targetA = beer;
                    this.CurJob.maxNumToCarry = 1;
                    toilsList.Add(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(TargetIndex.A));
                    toilsList.Add(Toils_Ingest.PickupIngestible(TargetIndex.A, this.pawn)); // TargetIndex.A becomes the carried beer.
                    toilsList.Add(Toils_Ingest.CarryIngestibleToChewSpot(this.pawn));
                    toilsList.Add(Toils_Ingest.FindAdjacentEatSurface(TargetIndex.B, TargetIndex.A));
                    // float durationMultiplier = 1f / this.pawn.GetStatValue(StatDefOf.EatingSpeed, true); // Don't use it so the job duration is nearly the same for all pawns.
                    float durationMultiplier = 1f;
                    toilsList.Add(Toils_Ingest.ChewIngestible(this.pawn, durationMultiplier, TargetIndex.A, TargetIndex.B).FailOn((Toil x) => !this.Food.Spawned && (this.pawn.carrier == null || this.pawn.carrier.CarriedThing != this.Food)));
                    toilsList.Add(Toils_Ingest.FinalizeIngest(this.pawn, TargetIndex.A));
                }
            }
            // Draw a mote.
            ThingDef moteDef = null;

            if (beerIsAvailable)
            {
                moteDef = Util_CampfireParty.Mote_BeerAvailable;
            }
            else
            {
                moteDef = Util_CampfireParty.Mote_BeerUnavailable;
            }
            MoteAttached moteAttached = (MoteAttached)ThingMaker.MakeThing(moteDef);

            moteAttached.AttachTo(this.pawn);
            GenSpawn.Spawn(moteAttached, this.pawn.Position);

            return(toilsList);
        }