public static void removeLeadership(Pawn current)
        {
            HediffLeader h1 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader1"));
            HediffLeader h2 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader2"));
            HediffLeader h3 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader3"));
            HediffLeader h4 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader4"));

            if (h2 != null)
            {
                h1 = h2;
            }
            if (h3 != null)
            {
                h1 = h3;
            }
            if (h4 != null)
            {
                h1 = h4;
            }


            Hediff hediff = HediffMaker.MakeHediff(HediffDef.Named("leaderExpired"), current, null);

            hediff.Severity = 1f;
            HediffLeader hl = (HediffLeader)hediff;

            hl.ticksLeader = h1.ticksLeader;
            current.health.AddHediff(hl, null, null);
            current.health.RemoveHediff(h1);
            current.needs.AddOrRemoveNeedsAsAppropriate();
        }
Exemplo n.º 2
0
        public static void purgeLeadership(Pawn current)
        {
            HediffLeader h1 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader1"));
            HediffLeader h2 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader2"));
            HediffLeader h3 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader3"));
            HediffLeader h4 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader4"));
            HediffLeader h5 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leaderExpired"));

            //HediffLeader h6 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("1"));

            if (h1 != null)
            {
                current.health.RemoveHediff(h1);
            }
            if (h2 != null)
            {
                current.health.RemoveHediff(h2);
            }
            if (h3 != null)
            {
                current.health.RemoveHediff(h3);
            }
            if (h4 != null)
            {
                current.health.RemoveHediff(h4);
            }
            if (h5 != null)
            {
                current.health.RemoveHediff(h5);
            }
            //if (h6 != null) current.health.RemoveHediff(h6);
            current.needs.AddOrRemoveNeedsAsAppropriate();
        }
        public static String getLeaderType(Pawn current)
        {
            HediffLeader h1 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader1"));
            HediffLeader h2 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader2"));
            HediffLeader h3 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader3"));
            HediffLeader h4 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader4"));
            String       s  = "leader1";

            if (h2 != null)
            {
                s = "leader2";
            }
            if (h3 != null)
            {
                s = "leader3";
            }
            if (h4 != null)
            {
                s = "leader4";
            }
            return(s);
        }
Exemplo n.º 4
0
        public static List <Texture2D> iconList(Pawn current)
        {
            HediffLeader h1 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader1"));
            HediffLeader h2 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader2"));
            HediffLeader h3 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader3"));
            HediffLeader h4 = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader4"));


            if (h2 != null)
            {
                return(ModTextures.icons_leader2);
            }
            if (h3 != null)
            {
                return(ModTextures.icons_leader3);
            }
            if (h4 != null)
            {
                return(ModTextures.icons_leader4);
            }
            return(ModTextures.icons_leader1);
        }
Exemplo n.º 5
0
        public float getSkillFactor(Pawn current)
        {
            HediffLeader h1    = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader1"));
            HediffLeader h2    = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader2"));
            HediffLeader h3    = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader3"));
            HediffLeader h4    = (HediffLeader)current.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("leader4"));
            float        score = IncidentWorker_SetLeadership.getBotanistScore(current);

            if (h2 != null)
            {
                h1 = h2; score = IncidentWorker_SetLeadership.getWarriorScore(current);
            }
            if (h3 != null)
            {
                h1 = h3; score = IncidentWorker_SetLeadership.getCarpenterScore(current);
            }
            if (h4 != null)
            {
                h1 = h4; score = IncidentWorker_SetLeadership.getScientistScore(current);
            }

            return(((score / 20f) * 0.3f) + 1f);
        }
Exemplo n.º 6
0
        public override void Tick()
        {
            base.Tick();

            Pawn actor = this.pawn;

            this.counter += 1;
            bool flag = this.counter >= 100;

            if (flag)
            {
                if (leader.Map == null)
                {
                    this.pawn.health.RemoveHediff(this);
                }

                bool leaderNearby = false;
                if (leader != null && leader.Map == this.pawn.Map && this.pawn.IsColonistPlayerControlled)
                {
                    string label;
                    if (this.def.defName == "leaderAura1")
                    {
                        label = "leader1";
                    }
                    else if (this.def.defName == "leaderAura2")
                    {
                        label = "leader2";
                    }
                    else if (this.def.defName == "leaderAura3")
                    {
                        label = "leader3";
                    }
                    else
                    {
                        label = "leader4";
                    }

                    /*
                     * List<Thing> list = GenRadial.RadialDistinctThingsAround(actor.Position, actor.Map, 15f, true).ToList<Thing>();
                     * foreach (Thing current in list)
                     * {}*/
                    float distance = (this.pawn.Position - leader.Position).LengthHorizontal;

                    if (distance <= 15f)
                    {
                        if (leader.GetRoom() == this.pawn.GetRoom())
                        {
                            Pawn pawn = leader;

                            HediffLeader hediff = (HediffLeader)pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named(label));
                            if (hediff != null)
                            {
                                leaderNearby  = true;
                                this.Severity = Mathf.Clamp(hediff.Need.CurLevel, 0.01f, 1f);
                                if (pawn.CurJob != null && pawn.jobs.curDriver.asleep)
                                {
                                    leaderNearby = false;
                                }
                                if (pawn.InAggroMentalState)
                                {
                                    leaderNearby = false;
                                }
                            }
                        }
                    }
                }

                if (!leaderNearby)
                {
                    this.pawn.health.RemoveHediff(this);
                }
            }
        }