public override void RandomizeSettings(float points, Map map, List <Rule> outExtraDescriptionRules, Dictionary <string, string> outExtraDescriptionConstants)
 {
     if (def.defaultDroneLevel == PsychicDroneLevel.GoodMedium)
     {
         level = PsychicDroneLevel.GoodMedium;
     }
     else if (points < 800f)
     {
         level = PsychicDroneLevel.BadLow;
     }
     else if (points < 2000f)
     {
         level = PsychicDroneLevel.BadMedium;
     }
     else
     {
         level = PsychicDroneLevel.BadHigh;
     }
     if (map.mapPawns.FreeColonistsCount > 0)
     {
         gender = map.mapPawns.FreeColonists.RandomElement().gender;
     }
     else
     {
         gender = Rand.Element(Gender.Male, Gender.Female);
     }
     outExtraDescriptionRules.Add(new Rule_String("psychicDroneLevel", level.GetLabel()));
     outExtraDescriptionRules.Add(new Rule_String("psychicDroneGender", gender.GetLabel()));
 }
        public static string GetLabel(this PsychicDroneLevel level)
        {
            switch (level)
            {
            case PsychicDroneLevel.None:
                return("PsychicDroneLevel_None".Translate());

            case PsychicDroneLevel.GoodMedium:
                return("PsychicDroneLevel_GoodMedium".Translate());

            case PsychicDroneLevel.BadLow:
                return("PsychicDroneLevel_BadLow".Translate());

            case PsychicDroneLevel.BadMedium:
                return("PsychicDroneLevel_BadMedium".Translate());

            case PsychicDroneLevel.BadHigh:
                return("PsychicDroneLevel_BadHigh".Translate());

            case PsychicDroneLevel.BadExtreme:
                return("PsychicDroneLevel_BadExtreme".Translate());

            default:
                return("error");
            }
        }
Beispiel #3
0
 private void IncreaseDroneLevel()
 {
     if (this.droneLevel != PsychicDroneLevel.BadExtreme)
     {
         this.droneLevel += 1;
         string text = "LetterPsychicDroneLevelIncreased".Translate();
         Find.LetterStack.ReceiveLetter("LetterLabelPsychicDroneLevelIncreased".Translate(), text, LetterDefOf.NegativeEvent, null);
         SoundDefOf.PsychicPulseGlobal.PlayOneShotOnCamera(this.parent.Map);
     }
 }
Beispiel #4
0
 public static string GetLabel(this PsychicDroneLevel level)
 {
     return(level switch
     {
         PsychicDroneLevel.None => "PsychicDroneLevel_None".Translate(),
         PsychicDroneLevel.GoodMedium => "PsychicDroneLevel_GoodMedium".Translate(),
         PsychicDroneLevel.BadLow => "PsychicDroneLevel_BadLow".Translate(),
         PsychicDroneLevel.BadMedium => "PsychicDroneLevel_BadMedium".Translate(),
         PsychicDroneLevel.BadHigh => "PsychicDroneLevel_BadHigh".Translate(),
         PsychicDroneLevel.BadExtreme => "PsychicDroneLevel_BadExtreme".Translate(),
         _ => "error",
     });
Beispiel #5
0
        private void IncreaseDroneLevel()
        {
            if (this.droneLevel == PsychicDroneLevel.BadExtreme)
            {
                return;
            }
            this.droneLevel += 1;
            string text = "LetterPsychicDroneLevelIncreased".Translate();

            Find.LetterStack.ReceiveLetter("LetterLabelPsychicDroneLevelIncreased".Translate(), text, LetterDefOf.BadNonUrgent, null);
            SoundDefOf.PsychicPulseGlobal.PlayOneShotOnCamera(base.Map);
        }
Beispiel #6
0
        protected override ThoughtState CurrentStateInternal(Pawn p)
        {
            PsychicDroneLevel psychicDroneLevel = PsychicDroneLevel.None;

            if (p.Map != null)
            {
                PsychicDroneLevel highestPsychicDroneLevelFor = p.Map.gameConditionManager.GetHighestPsychicDroneLevelFor(p.gender);
                if ((int)highestPsychicDroneLevelFor > (int)psychicDroneLevel)
                {
                    psychicDroneLevel = highestPsychicDroneLevelFor;
                }
            }
            else if (p.IsCaravanMember())
            {
                foreach (Site site in Find.World.worldObjects.Sites)
                {
                    foreach (SitePart part in site.parts)
                    {
                        if (!part.conditionCauser.DestroyedOrNull() && part.def.Worker is SitePartWorker_ConditionCauser_PsychicDroner)
                        {
                            CompCauseGameCondition_PsychicEmanation compCauseGameCondition_PsychicEmanation = part.conditionCauser.TryGetComp <CompCauseGameCondition_PsychicEmanation>();
                            if (compCauseGameCondition_PsychicEmanation.ConditionDef.conditionClass == typeof(GameCondition_PsychicEmanation) && compCauseGameCondition_PsychicEmanation.InAoE(p.GetCaravan().Tile) && compCauseGameCondition_PsychicEmanation.gender == p.gender && (int)compCauseGameCondition_PsychicEmanation.Level > (int)psychicDroneLevel)
                            {
                                psychicDroneLevel = compCauseGameCondition_PsychicEmanation.Level;
                            }
                        }
                    }
                }
                foreach (Map map in Find.Maps)
                {
                    foreach (GameCondition activeCondition in map.gameConditionManager.ActiveConditions)
                    {
                        CompCauseGameCondition_PsychicEmanation compCauseGameCondition_PsychicEmanation2 = activeCondition.conditionCauser.TryGetComp <CompCauseGameCondition_PsychicEmanation>();
                        if (compCauseGameCondition_PsychicEmanation2 != null && compCauseGameCondition_PsychicEmanation2.InAoE(p.GetCaravan().Tile) && compCauseGameCondition_PsychicEmanation2.gender == p.gender && (int)compCauseGameCondition_PsychicEmanation2.Level > (int)psychicDroneLevel)
                        {
                            psychicDroneLevel = compCauseGameCondition_PsychicEmanation2.Level;
                        }
                    }
                }
            }
            return(psychicDroneLevel switch
            {
                PsychicDroneLevel.None => false,
                PsychicDroneLevel.GoodMedium => ThoughtState.ActiveAtStage(0),
                PsychicDroneLevel.BadLow => ThoughtState.ActiveAtStage(1),
                PsychicDroneLevel.BadMedium => ThoughtState.ActiveAtStage(2),
                PsychicDroneLevel.BadHigh => ThoughtState.ActiveAtStage(3),
                PsychicDroneLevel.BadExtreme => ThoughtState.ActiveAtStage(4),
                _ => throw new NotImplementedException(),
            });
        public PsychicDroneLevel GetHighestPsychicDroneLevelFor(Gender gender)
        {
            PsychicDroneLevel psychicDroneLevel = PsychicDroneLevel.None;

            for (int i = 0; i < ActiveConditions.Count; i++)
            {
                GameCondition_PsychicEmanation gameCondition_PsychicEmanation = activeConditions[i] as GameCondition_PsychicEmanation;
                if (gameCondition_PsychicEmanation != null && gameCondition_PsychicEmanation.gender == gender && (int)gameCondition_PsychicEmanation.level > (int)psychicDroneLevel)
                {
                    psychicDroneLevel = gameCondition_PsychicEmanation.level;
                }
            }
            return(psychicDroneLevel);
        }
        protected override void DoConditionAndLetter(IncidentParms parms, Map map, int duration, Gender gender, float points)
        {
            if (points < 0f)
            {
                points = StorytellerUtility.DefaultThreatPointsNow(map);
            }
            PsychicDroneLevel level = (points < 800f) ? PsychicDroneLevel.BadLow : ((!(points < 2000f)) ? PsychicDroneLevel.BadHigh : PsychicDroneLevel.BadMedium);
            GameCondition_PsychicEmanation gameCondition_PsychicEmanation = (GameCondition_PsychicEmanation)GameConditionMaker.MakeCondition(GameConditionDefOf.PsychicDrone, duration);

            gameCondition_PsychicEmanation.gender = gender;
            gameCondition_PsychicEmanation.level  = level;
            map.gameConditionManager.RegisterCondition(gameCondition_PsychicEmanation);
            SendStandardLetter(gameCondition_PsychicEmanation.LabelCap, gameCondition_PsychicEmanation.LetterText, gameCondition_PsychicEmanation.def.letterDef, parms, LookTargets.Invalid);
        }
        protected override ThoughtState CurrentStateInternal(Pawn p)
        {
            PsychicDroneLevel psychicDroneLevel = PsychicDroneLevel.None;
            CompPsychicDrone  compPsychicDrone  = ThoughtWorker_PsychicDrone.PsychicDroneEmanator(p.Map);

            if (compPsychicDrone != null)
            {
                psychicDroneLevel = compPsychicDrone.DroneLevel;
            }
            GameCondition_PsychicEmanation activeCondition = p.Map.gameConditionManager.GetActiveCondition <GameCondition_PsychicEmanation>();

            if (activeCondition != null && activeCondition.gender == p.gender && activeCondition.def.droneLevel > psychicDroneLevel)
            {
                psychicDroneLevel = activeCondition.def.droneLevel;
            }
            ThoughtState result;

            switch (psychicDroneLevel)
            {
            case PsychicDroneLevel.None:
                result = false;
                break;

            case PsychicDroneLevel.GoodMedium:
                result = ThoughtState.ActiveAtStage(0);
                break;

            case PsychicDroneLevel.BadLow:
                result = ThoughtState.ActiveAtStage(1);
                break;

            case PsychicDroneLevel.BadMedium:
                result = ThoughtState.ActiveAtStage(2);
                break;

            case PsychicDroneLevel.BadHigh:
                result = ThoughtState.ActiveAtStage(3);
                break;

            case PsychicDroneLevel.BadExtreme:
                result = ThoughtState.ActiveAtStage(4);
                break;

            default:
                throw new NotImplementedException();
            }
            return(result);
        }
 public override void RandomizeSettings_NewTemp_NewTemp(Site site)
 {
     gender = (Rand.Bool ? Gender.Male : Gender.Female);
     if (site.ActualThreatPoints < 800f)
     {
         droneLevel = PsychicDroneLevel.BadLow;
     }
     else if (site.ActualThreatPoints < 2000f)
     {
         droneLevel = PsychicDroneLevel.BadMedium;
     }
     else
     {
         droneLevel = PsychicDroneLevel.BadHigh;
     }
 }
Beispiel #11
0
        protected override void DoConditionAndLetter(Map map, int duration, Gender gender, float points)
        {
            if (points < 0f)
            {
                points = StorytellerUtility.DefaultThreatPointsNow(map);
            }
            PsychicDroneLevel level = (points < 800f) ? PsychicDroneLevel.BadLow : ((!(points < 2000f)) ? PsychicDroneLevel.BadHigh : PsychicDroneLevel.BadMedium);
            GameCondition_PsychicEmanation gameCondition_PsychicEmanation = (GameCondition_PsychicEmanation)GameConditionMaker.MakeCondition(GameConditionDefOf.PsychicDrone, duration);

            gameCondition_PsychicEmanation.gender = gender;
            gameCondition_PsychicEmanation.level  = level;
            map.gameConditionManager.RegisterCondition(gameCondition_PsychicEmanation);
            string label = "LetterLabelPsychicDrone".Translate() + " (" + level.GetLabel() + ", " + gender.GetLabel() + ")";
            string text  = "LetterIncidentPsychicDrone".Translate(gender.ToString().Translate().ToLower(), level.GetLabel());

            Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.NegativeEvent);
        }
Beispiel #12
0
        protected override ThoughtState CurrentStateInternal(Pawn p)
        {
            PsychicDroneLevel psychicDroneLevel = PsychicDroneLevel.None;
            CompPsychicDrone  compPsychicDrone  = PsychicDroneEmanator(p.Map);

            if (compPsychicDrone != null)
            {
                psychicDroneLevel = compPsychicDrone.DroneLevel;
            }
            GameCondition_PsychicEmanation activeCondition = p.Map.gameConditionManager.GetActiveCondition <GameCondition_PsychicEmanation>();

            if (activeCondition != null && activeCondition.gender == p.gender && (int)activeCondition.level > (int)psychicDroneLevel)
            {
                psychicDroneLevel = activeCondition.level;
            }
            switch (psychicDroneLevel)
            {
            case PsychicDroneLevel.None:
                return(false);

            case PsychicDroneLevel.GoodMedium:
                return(ThoughtState.ActiveAtStage(0));

            case PsychicDroneLevel.BadLow:
                return(ThoughtState.ActiveAtStage(1));

            case PsychicDroneLevel.BadMedium:
                return(ThoughtState.ActiveAtStage(2));

            case PsychicDroneLevel.BadHigh:
                return(ThoughtState.ActiveAtStage(3));

            case PsychicDroneLevel.BadExtreme:
                return(ThoughtState.ActiveAtStage(4));

            default:
                throw new NotImplementedException();
            }
        }
Beispiel #13
0
 public override void Initialize(CompProperties props)
 {
     base.Initialize(props);
     gender     = Gender.Male;
     droneLevel = Props.droneLevel;
 }
 public override void PostMake()
 {
     base.PostMake();
     level = def.defaultDroneLevel;
 }
 public static string GetLabelCap(this PsychicDroneLevel level)
 {
     return(level.GetLabel().CapitalizeFirst());
 }
Beispiel #16
0
        protected override ThoughtState CurrentStateInternal(Pawn p)
        {
            Need_Soul soul = p.needs.TryGetNeed <Need_Soul>();

            if (soul == null)
            {
                soul = new Need_Soul(p);
            }

            float factor = 1f;

            soul.GainNeed(factor * 0.00001f);

            PsychicDroneLevel             psychicDroneLevel = PsychicDroneLevel.None;
            MapCondition_PsychicEmanation activeCondition   = p.Map.mapConditionManager.GetActiveCondition <MapCondition_PsychicEmanation>();

            if (activeCondition != null && activeCondition.def.droneLevel > psychicDroneLevel)
            {
                psychicDroneLevel = activeCondition.def.droneLevel;
            }
            else
            {
                return(ThoughtState.Inactive);
            }
            switch (psychicDroneLevel)
            {
            case PsychicDroneLevel.None:
                factor = 0f;
                return(false);

            case PsychicDroneLevel.BadLow:
                factor = 1f;
                break;

            case PsychicDroneLevel.BadMedium:
                factor = 1.3f;
                break;

            case PsychicDroneLevel.BadHigh:
                factor = 1.5f;
                break;

            case PsychicDroneLevel.BadExtreme:
                factor = 2f;
                break;

            default:
                return(ThoughtState.Inactive);
            }


            if (soul.NoPatron)
            {
                return(ThoughtState.ActiveAtStage(0));
            }
            else if (soul.PsykerPowerLevel == PsykerPowerLevel.Omega)
            {
                return(ThoughtState.Inactive);
            }
            return(ThoughtState.ActiveAtStage(1));
        }