/// <summary> /// Decays the emotion according to the system's time /// </summary> /// <returns>the intensity of the emotion after being decayed</returns> internal void DecayEmotion(EmotionalAppraisalAsset parent) { var delta = parent.Tick - tickATt0; double lambda = Math.Log(parent.HalfLifeDecayConstant) / parent.EmotionalHalfLifeDecayTime; float decay = (float)Math.Exp(lambda * this.Decay * delta); Intensity = intensityATt0 * decay; }
/// <summary> /// Updates the character's mood when a given emotion is "felt" by the character. /// </summary> /// <param name="emotion">the ActiveEmotion that will influence the agent's current mood</param> public void UpdateMood(ActiveEmotion emotion, EmotionalAppraisalAsset parent) { if (!emotion.InfluenceMood) { return; } float scale = (float)emotion.Valence; SetMoodValue(this._intensity + scale * (emotion.Intensity * parent.EmotionInfluenceOnMoodFactor), parent); }
public void SetMoodValue(float value, EmotionalAppraisalAsset parent) { value = value < -10 ? -10 : (value > 10 ? 10 : value); if (Math.Abs(value) < parent.MinimumMoodValueForInfluencingEmotions) { value = 0; } this._intensityATt0 = this._intensity = value; this._tickT0 = parent.Tick; }
/// <summary> /// Decays the mood according to the agent's simulated time /// </summary> /// <returns>the mood's intensity after being decayed</returns> public void DecayMood(EmotionalAppraisalAsset parent) { if (this._intensityATt0 == 0) { this._intensity = 0; return; } var delta = (parent.Tick - this._tickT0); double lambda = Math.Log(parent.HalfLifeDecayConstant) / parent.MoodHalfLifeDecayTime; _intensity = (float)(this._intensityATt0 * Math.Exp(lambda * delta)); if (Math.Abs(this._intensity) < parent.MinimumMoodValueForInfluencingEmotions) { this._intensity = this._intensityATt0 = 0; this._tickT0 = 0; } }
public void SetObjectData(ISerializationData dataHolder) { m_parent = dataHolder.GetValue <EmotionalAppraisalAsset>("Parent"); mood.SetMoodValue(dataHolder.GetValue <float>("Mood"), m_parent); var dispositions = dataHolder.GetValue <EmotionDisposition[]>("EmotionDispositions"); EmotionDisposition defaultDisposition = null; foreach (var disposition in dispositions) { if (string.Equals(disposition.Emotion, "*", StringComparison.InvariantCultureIgnoreCase)) { if (defaultDisposition == null) { defaultDisposition = disposition; } } else { emotionDispositions.Add(disposition.Emotion, disposition); } } if (defaultDisposition == null) { defaultDisposition = new EmotionDisposition("*", 1, 1); } m_defaultEmotionalDisposition = defaultDisposition; var seq = dataHolder.GetValueGraphNode("EmotionalPool") as ISequenceGraphNode; foreach (var n in seq) { var data = (n as IObjectGraphNode).ToSerializationData(); var emotion = new ActiveEmotion(data, m_parent.Tick); var hash = calculateHashString(emotion, m_parent.m_am); emotionPool.Add(hash, emotion); } }
public ConcreteEmotionalState(EmotionalAppraisalAsset parent) : this() { m_parent = parent; }