Esempio n. 1
0
        public int indexOf(AorB ab, int x)
        {
            switch (ab)
            {
            case AorB.StackA:
                for (int i = ptrA - 1; i >= 0; i--)
                {
                    if (stk[i] == x)
                    {
                        return(i);
                    }
                }
                break;

            case AorB.StackB:
                for (int i = ptrB + 1; i < max; i++)
                {
                    if (stk[i] == x)
                    {
                        return(i);
                    }
                }
                break;
            }
            return(-1);
        }
Esempio n. 2
0
        public void dump(AorB ab)
        {
            switch (ab)
            {
            case AorB.StackA:
                if (ptrA <= 0)
                {
                    Console.WriteLine("스택이 비어있습니다.");
                }
                else
                {
                    for (int i = 0; i < ptrA; i++)
                    {
                        Console.Write(stk[i] + " ");
                    }
                    Console.WriteLine();
                }
                break;

            case AorB.StackB:
                if (ptrB >= max - 1)
                {
                    Console.WriteLine("스택이 비어있습니다.");
                }
                else
                {
                    for (int i = max - 1; i > ptrB; i--)
                    {
                        Console.Write(stk[i] + " ");
                    }
                    Console.WriteLine();
                }
                break;
            }
        }
Esempio n. 3
0
        public bool isEmpty(AorB ab)
        {
            switch (ab)
            {
            case AorB.StackA:
                return(ptrA <= 0);

            case AorB.StackB:
                return(ptrB >= max - 1);
            }
            return(true);
        }
Esempio n. 4
0
        public int size(AorB ab)
        {
            switch (ab)
            {
            case AorB.StackA:
                return(ptrA);

            case AorB.StackB:
                return(max - ptrB - 1);
            }
            return(0);
        }
Esempio n. 5
0
        public void clear(AorB ab)
        {
            switch (ab)
            {
            case AorB.StackA:
                ptrA = 0;
                break;

            case AorB.StackB:
                ptrB = 0;
                break;
            }
        }
Esempio n. 6
0
        private static void SpawnPawn(int skill, AorB ab, HediffDef hediffs, bool AffectsEye, SkillDef skilldef)
        {
            Faction faction = FactionUtility.DefaultFactionFrom(ft: ab.fac);

            var pawngen = new PawnGenerationRequest(
                kind: ab.pkd,
                faction: faction,
                context: PawnGenerationContext.NonPlayer,
                mustBeCapableOfViolence: true,
                forceGenerateNewPawn: true,
                worldPawnFactionDoesntMatter: true
                );

            Pawn newPawn = PawnGenerator.GeneratePawn(request: pawngen);

            newPawn.skills.GetSkill(skillDef: skilldef).Level = skill;

            newPawn.story.traits.allTraits.RemoveAll(match: trt => ab.undesired.Contains(item: trt.def.defName));

            if (hediffs != null)
            {
                if (AffectsEye)
                {
                    foreach (BodyPartRecord bpr in newPawn.RaceProps.body.GetPartsWithTag(tag: Defs_Rimworld.EyeTag))
                    {
                        newPawn.health.AddHediff(def: hediffs, part: bpr, dinfo: null, result: null);
                    }
                }
                else
                {
                    newPawn.health.AddHediff(def: hediffs);
                }
            }

            GenSpawn.Spawn(newThing: newPawn, loc: UI.MouseCell(), map: Find.CurrentMap, wipeMode: WipeMode.Vanish);

            if (faction != null && faction != Faction.OfPlayer)
            {
                Lord lord = null;

                var lordJob = new LordJob_DefendPoint(point: newPawn.Position);
                lord = LordMaker.MakeNewLord(faction: faction, lordJob: lordJob, map: Find.CurrentMap, startingPawns: null);


                lord.AddPawn(p: newPawn);
            }
        }
Esempio n. 7
0
        public int push(AorB ab, int x)
        {
            if (ptrA >= ptrB + 1)
            {
                throw new OverflowIntStackExcption();
            }
            switch (ab)
            {
            case AorB.StackA:
                stk[ptrA++] = x;
                break;

            case AorB.StackB:
                stk[ptrB--] = x;
                break;
            }
            return(x);
        }
Esempio n. 8
0
        private static List <Pawn> NVPawnSetSpawner
        (
            Map map, SkillDef skill, GlowTeam team, int count, IntVec3 spot,
            AorB side
        )
        {
            var     list    = new List <Pawn>();
            Faction faction = FactionUtility.DefaultFactionFrom(ft: side.fac);

            for (var i = 0; i < count; i++)
            {
                var pawngen = new PawnGenerationRequest(
                    kind: side.pkd,
                    faction: faction,
                    context: PawnGenerationContext.NonPlayer,
                    mustBeCapableOfViolence: true,
                    forceGenerateNewPawn: true,
                    worldPawnFactionDoesntMatter: true
                    );

                Pawn newPawn = PawnGenerator.GeneratePawn(request: pawngen);
                newPawn.skills.GetSkill(skillDef: skill).Level = team.Skill;

                newPawn.story.traits.allTraits.RemoveAll(match: trt => side.undesired.Contains(item: trt.def.defName));

                if (team.GlowHediff != null)
                {
                    newPawn.health.AddHediff(
                        def: team.GlowHediff,
                        part: newPawn.RaceProps.body.GetPartsWithTag(tag: BodyPartTagDefOf.ConsciousnessSource).First()
                        );
                }

                IntVec3 loc = CellFinder.RandomClosewalkCellNear(root: spot, map: map, radius: 12, extraValidator: null);
                GenSpawn.Spawn(newThing: newPawn, loc: loc, map: map, rot: Rot4.Random, wipeMode: WipeMode.Vanish, respawningAfterLoad: false);
                list.Add(item: newPawn);
            }

            LordMaker.MakeNewLord(faction: faction, lordJob: new LordJob_DefendPoint(point: map.Center), map: map, startingPawns: list);

            return(list);
        }
Esempio n. 9
0
        public int peep(AorB ab)
        {
            int x = 0;

            switch (ab)
            {
            case AorB.StackA:
                if (ptrA <= 0)
                {
                    throw new EmptyIntStackException();
                }
                x = stk[ptrA - 1];
                break;

            case AorB.StackB:
                if (ptrB >= max - 1)
                {
                    throw new EmptyIntStackException();
                }
                x = stk[ptrB + 1];
                break;
            }
            return(x);
        }