コード例 #1
0
ファイル: Zombie.cs プロジェクト: DoctorVanGogh/zombieland
        public VariableGraphic customBodyGraphic;         // not saved

        public override void ExposeData()
        {
            base.ExposeData();
            Scribe_Values.Look(ref state, "zstate");
            Scribe_Values.Look(ref raging, "raging");
            Scribe_Values.Look(ref wanderDestination, "wanderDestination");
            Scribe_Values.Look(ref rubbleTicks, "rubbleTicks");
            Scribe_Values.Look(ref rubbleCounter, "rubbleCounter");
            Scribe_Collections.Look(ref rubbles, "rubbles", LookMode.Deep);
            Scribe_Values.Look(ref wasColonist, "wasColonist");

            if (Scribe.mode == LoadSaveMode.PostLoadInit)
            {
                // fix for old zombies not having correct leaner
                //
                if ((Drawer.leaner is ZombieLeaner) == false)
                {
                    Drawer.leaner = new ZombieLeaner(this);
                }

                ZombieGenerator.AssignNewCustomGraphics(this);
            }

            if (Scribe.mode == LoadSaveMode.ResolvingCrossRefs)
            {
                var idx = ageTracker.CurLifeStageIndex;                 // trigger calculations
            }
        }
コード例 #2
0
        public void ConvertToZombie()
        {
            var pos = pawn.Position;
            var map = pawn.Map;
            var rot = pawn.Rotation;

            var zombie = ZombieGenerator.GeneratePawn();

            zombie.Name   = pawn.Name;
            zombie.gender = pawn.gender;

            var apparelToTransfer = new List <Apparel>();

            pawn.apparel.WornApparelInDrawOrder.Do(apparel =>
            {
                Apparel newApparel;
                if (pawn.apparel.TryDrop(apparel, out newApparel))
                {
                    apparelToTransfer.Add(newApparel);
                }
            });

            zombie.ageTracker.AgeBiologicalTicks    = pawn.ageTracker.AgeBiologicalTicks;
            zombie.ageTracker.AgeChronologicalTicks = pawn.ageTracker.AgeChronologicalTicks;
            zombie.ageTracker.BirthAbsTicks         = pawn.ageTracker.BirthAbsTicks;

            zombie.story.childhood = pawn.story.childhood;
            zombie.story.adulthood = pawn.story.adulthood;
            zombie.story.melanin   = pawn.story.melanin;
            zombie.story.crownType = pawn.story.crownType;
            zombie.story.hairDef   = pawn.story.hairDef;
            zombie.story.bodyType  = pawn.story.bodyType;

            var zTweener = Traverse.Create(zombie.Drawer.tweener);
            var pTweener = Traverse.Create(pawn.Drawer.tweener);

            zTweener.Field("tweenedPos").SetValue(pTweener.Field("tweenedPos").GetValue());
            zTweener.Field("lastDrawFrame").SetValue(pTweener.Field("lastDrawFrame").GetValue());
            zTweener.Field("lastTickSpringPos").SetValue(pTweener.Field("lastTickSpringPos").GetValue());

            ZombieGenerator.AssignNewCustomGraphics(zombie);
            ZombieGenerator.FinalizeZombieGeneration(zombie);
            GenPlace.TryPlaceThing(zombie, pos, map, ThingPlaceMode.Direct, null);
            map.GetGrid().ChangeZombieCount(pos, 1);

            pawn.Kill(null);
            pawn.Corpse.Destroy();

            apparelToTransfer.ForEach(apparel => zombie.apparel.Wear(apparel));
            zombie.Rotation      = rot;
            zombie.rubbleCounter = Constants.RUBBLE_AMOUNT;
            zombie.state         = ZombieState.Wandering;
            zombie.wasColonist   = true;

            string text = "ColonistBecameAZombieDesc".Translate(new object[] { zombie.NameStringShort });

            Find.LetterStack.ReceiveLetter("ColonistBecameAZombieLabel".Translate(), text, LetterDefOf.BadUrgent, zombie);
        }
コード例 #3
0
ファイル: Zombie.cs プロジェクト: perkinslr/zombieland
        public VariableGraphic customBodyGraphic;         // not saved

        public override void ExposeData()
        {
            base.ExposeData();
            Scribe_Values.Look(ref state, "zstate");
            Scribe_Values.Look(ref wanderDestination, "wanderDestination");
            Scribe_Values.Look(ref rubbleTicks, "rubbleTicks");
            Scribe_Values.Look(ref rubbleCounter, "rubbleCounter");
            Scribe_Collections.Look(ref rubbles, "rubbles", LookMode.Deep);
            Scribe_Values.Look(ref wasColonist, "wasColonist");

            if (Scribe.mode == LoadSaveMode.PostLoadInit)
            {
                // fix for old zombies not having correct leaner
                if ((Drawer.leaner is ZombieLeaner) == false)
                {
                    Drawer.leaner = new ZombieLeaner(this);
                }

                ZombieGenerator.AssignNewCustomGraphics(this);
            }
        }