コード例 #1
0
 private void SapienceLevelChanged(Need_Control sender, Pawn pawn, SapienceLevel sapiencelevel)
 {
     if (sapiencelevel == SapienceLevel.Sapient)
     {
         _waiting = true;
     }
 }
コード例 #2
0
        private void SapienceLevelChanges(Need_Control sender, Pawn pawn, SapienceLevel sapiencelevel)
        {
            if (pawn.Faction != Faction.OfPlayer)
            {
                return;
            }


            Find.ColonistBar.MarkColonistsDirty();
        }
コード例 #3
0
ファイル: Need_Control.cs プロジェクト: User00015/Pawnmorpher
        /// <summary>
        ///     Determines whether the control need is enabled for the pawn.
        /// </summary>
        /// <param name="pawn">The pawn.</param>
        /// <returns>
        ///     <c>true</c> if control need is enabled for the given humanoid race; otherwise, <c>false</c>.
        /// </returns>
        public static bool IsEnabledFor([NotNull] Pawn pawn)
        {
            if (pawn == null)
            {
                throw new ArgumentNullException(nameof(pawn));
            }
            SapienceLevel fhLevel = pawn.GetQuantizedSapienceLevel() ?? SapienceLevel.PermanentlyFeral;

            return(fhLevel != SapienceLevel.PermanentlyFeral || EnabledRaces.Contains(pawn.def));
        }
コード例 #4
0
        /// <summary>
        ///     Makes the parent thing permanently feral.
        /// </summary>
        public void MakePermanentlyFeral()
        {
            if (!_isFormerHuman)
            {
                Log.Error($"trying to make a non former human \"{PMThingUtilities.GetDebugLabel(parent)}\" permanently feral");
            }

            SapienceLevel = SapienceLevel.PermanentlyFeral;
            //TODO move most of FormerHumanUtilities.MakePermanentlyFeral here
        }
コード例 #5
0
        /// <summary>
        ///     Makes the parent a former human.
        /// </summary>
        /// <returns></returns>
        public void MakeFormerHuman(float initialLevel) //TODO move most of FormerHumanUtilities.MakeAnimalSapient here
        {
            if (_isFormerHuman)
            {
                Log.Warning($"{nameof(MakeFormerHuman)} is being called on {parent.def}'s {nameof(FormerHumanTracker)} more then once!");
                return;
            }

            _isFormerHuman = true;
            SapienceLevel  = FormerHumanUtilities.GetQuantizedSapienceLevel(initialLevel);
        }
コード例 #6
0
        private void SapienceLevelChanged(Need_Control sender, Pawn pawn1, SapienceLevel sapiencelevel)
        {
            var idx = (int)sapiencelevel;

            if (idx < def.stages.Count)
            {
                SetStage(idx);
            }

            SetLabel(sapiencelevel);
        }
コード例 #7
0
        private void OnSapienceLevelChanged(Need_Control sender, Pawn pawn, SapienceLevel sapienceLevel)
        {
            if (sapienceLevel == SapienceLevel.Feral)
            {
                _countdownStarted = true;
            }

            if (PawnUtility.ShouldSendNotificationAbout(pawn))
            {
                SendFHLetter(pawn, sapienceLevel);
            }
        }
コード例 #8
0
        /// <summary>
        ///     Sets the sapience.
        /// </summary>
        /// <param name="sapience">The sapience.</param>
        public void SetSapience(float sapience)
        {
            _seekerLevel = Mathf.Clamp(sapience, 0, Mathf.Min(MaxLevel, Limit));
            CurLevel     = _seekerLevel;

            SapienceLevel cLevel = FormerHumanUtilities.GetQuantizedSapienceLevel(CurLevel);

            if (_currentLevel != cLevel)
            {
                _currentLevel = cLevel;
                OnSapienceLevelChanges();
            }
        }
コード例 #9
0
 /// <summary>
 ///     Exposes the data.
 /// </summary>
 public override void ExposeData()
 {
     base.ExposeData();
     Scribe_Values.Look(ref _seekerLevel, nameof(_seekerLevel), -1);
     if (Scribe.mode == LoadSaveMode.PostLoadInit)
     {
         if (_seekerLevel < 0)
         {
             _seekerLevel = CurLevel;
         }
         _currentLevel = FormerHumanUtilities.GetQuantizedSapienceLevel(_seekerLevel);
         CurLevel      = Mathf.Clamp(CurLevel, 0, MaxLevel);
     }
 }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TransformationRequest"/> struct.
 /// </summary>
 /// <param name="outputDef">The output definition.</param>
 /// <param name="original">The original.</param>
 /// <param name="maxSeverity">the maximum severity of the former human hediff</param>
 public TransformationRequest(PawnKindDef outputDef, Pawn original, SapienceLevel maxSeverity)
 {
     originals          = new[] { original };
     this.outputDef     = outputDef;
     forcedGender       = TFGender.Original;
     forcedGenderChance = 50;
     cause                 = null;
     tale                  = null;
     this.maxSeverity      = maxSeverity.GetMidLevel();
     addMutationToOriginal = true;
     noLetter              = false;
     minSeverity           = 0;
     forcedFaction         = default;
     factionResponsible    = null;
 }
コード例 #11
0
        private static void SendFHLetter(Pawn pawn, SapienceLevel sapienceLevel)
        {
            // the translation keys should be $SapienceLevel_TransitionLabel and $SapienceLevel_TransitionContent
            string       translationLabel = "FormerHuman" + sapienceLevel + "_Transition";
            string       letterLabelKey = translationLabel + "Label";
            string       letterContentKey = translationLabel + "Content";
            TaggedString letterContent, letterLabel;


            if (letterLabelKey.TryTranslate(out letterLabel) && letterContentKey.TryTranslate(out letterContent))
            {
                letterLabel   = letterLabel.AdjustedFor(pawn);
                letterContent = letterContent.AdjustedFor(pawn);

                Find.LetterStack.ReceiveLetter(letterLabel, letterContent, LetterDefOf.NeutralEvent, new LookTargets(pawn));
            }
        }
コード例 #12
0
        private void OnSapienceLevelChanges(SapienceLevel lastSapienceLevel)
        {
            if (lastSapienceLevel.IsColonistAnimal() && !_sapienceLevel.IsColonistAnimal())
            {
                OnNoLongerColonist();
            }
            else if (lastSapienceLevel <= SapienceLevel.MostlyFeral && _sapienceLevel > SapienceLevel.MostlyFeral)
            {
                OnNoLongerSapient();
            }



            //try to send a message
            if (Pawn.Faction?.IsPlayer == true)
            {
                SendTransitionLetter();
            }
        }
コード例 #13
0
 /// <summary>
 ///     called every so often by the need manager.
 /// </summary>
 /// <exception cref="System.NotImplementedException"></exception>
 public override void NeedInterval()
 {
     base.NeedInterval();
     if (pawn.IsHashIntervalTick(TimeMetrics.TICKS_PER_REAL_SECOND)) //just every second or so
     {
         TrySubscribe();
         CalculateCachesIfNeeded();
         _seekerLevel = Mathf.Min(_seekerLevel, Limit);
         float instinctChange = GetInstinctChangePerTick(pawn) * TimeMetrics.TICKS_PER_REAL_SECOND;
         if (Mathf.Abs(instinctChange) > EPSILON)
         {
             AddInstinctChange(instinctChange);
         }
         //_maxLevelCached = null;
         SapienceLevel sLevel = FormerHumanUtilities.GetQuantizedSapienceLevel(CurLevel);
         if (sLevel != _currentLevel)
         {
             _currentLevel = sLevel;
             OnSapienceLevelChanges();
         }
     }
 }
コード例 #14
0
        /// <summary>
        ///     called every so often by the need manager.
        /// </summary>
        /// <exception cref="System.NotImplementedException"></exception>
        public override void NeedInterval()
        {
            base.NeedInterval();
            if (pawn.IsHashIntervalTick(TimeMetrics.TICKS_PER_REAL_SECOND)) //just every second or so
            {
                float instinctChange = GetInstinctChangePerTick(pawn) * TimeMetrics.TICKS_PER_REAL_SECOND;
                if (Mathf.Abs(instinctChange) > EPSILON)
                {
                    AddInstinctChange(Mathf.CeilToInt(instinctChange));
                }
                _maxLevelCached = null;
                SapienceLevel sLevel = FormerHumanUtilities.GetQuantizedSapienceLevel(CurLevel);
                if (sLevel != _currentLevel)
                {
                    _currentLevel = sLevel;
                    OnSapienceLevelChanges();
                }

                if (_currentLevel == SapienceLevel.Feral && Rand.MTBEventOccurs(4, 60000f, 30f))
                {
                    TriggerPermanentlyFeralChange();
                }
            }
        }
コード例 #15
0
 /// <summary>
 /// Gets the index of the stage for the given sapience level
 /// </summary>
 /// <param name="sapienceLevel">The sapience level.</param>
 /// <returns></returns>
 protected int GetStageIndex(SapienceLevel sapienceLevel)
 {
     return(Mathf.Min(def.stages.Count - 1, (int)sapienceLevel));
 }
コード例 #16
0
 /// <summary>
 /// Gets the label.
 /// </summary>
 /// <param name="level">The level.</param>
 /// <returns></returns>
 public static string GetLabel(this SapienceLevel level)
 {
     return(_labelDict[level]);
 }
コード例 #17
0
 private void SetLabel(SapienceLevel level)
 {
     _labelCached = level.GetLabel();
 }
コード例 #18
0
 public RulePackDef this[SapienceLevel key] => variants?[key];
コード例 #19
0
 public RulePackDef GetRulePackVariant(SapienceLevel level)
 {
     return(variants?[level]);
 }
コード例 #20
0
        public T this[SapienceLevel key]
        {
            get
            {
                switch (key)
                {
                case SapienceLevel.Sapient:
                    return(sapient);

                case SapienceLevel.MostlySapient:
                    return(mostlySapient);

                case SapienceLevel.Conflicted:
                    return(conflicted);

                case SapienceLevel.MostlyFeral:
                    return(mostlyFeral);

                case SapienceLevel.Feral:
                    return(feral);

                case SapienceLevel.PermanentlyFeral:
                    return(permanentlyFeral);

                default:
                    throw new ArgumentOutOfRangeException(nameof(key), key, null);
                }
            }
            set
            {
                switch (key)
                {
                case SapienceLevel.Sapient:
                    sapient = value;
                    break;

                case SapienceLevel.MostlySapient:
                    mostlySapient = value;
                    break;

                case SapienceLevel.Conflicted:
                    conflicted = value;
                    break;

                case SapienceLevel.MostlyFeral:
                    mostlyFeral = value;
                    break;

                case SapienceLevel.Feral:
                    feral = value;
                    break;

                case SapienceLevel.PermanentlyFeral:
                    permanentlyFeral = value;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(key), key, null);
                }
            }
        }