상속: IActiveEmotion, ICustomSerialization
            public void RemoveEmotion(EmotionDTO emotion)
            {
                var    activeEmotion = new ActiveEmotion(emotion, this.DefaultEmotionDisposition.Decay, this.DefaultEmotionDisposition.Threshold);
                string hash          = calculateHashString(activeEmotion, m_parent.m_am);

                emotionPool.Remove(hash);
            }
예제 #2
0
        /// <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);
        }
예제 #3
0
        /// <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);
        }
예제 #4
0
        /// <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, EmotionalAppraisalConfiguration config, ulong tick)
        {
            if (!emotion.InfluenceMood)
            {
                return;
            }

            this._tickT0 = tick;
            float scale = (float)emotion.Valence;

            SetMoodValue(this._intensity + scale * (emotion.Intensity * config.EmotionInfluenceOnMoodFactor), config);
        }
예제 #5
0
        public EmotionDTO AddActiveEmotion(EmotionDTO emotion, AM am)
        {
            var activeEmotion = new ActiveEmotion(emotion, am, 1, 1);

            if (emotionPool.ContainsKey(calculateHashString(activeEmotion)))
            {
                throw new ArgumentException("This given emotion is already related to given cause", nameof(emotion));
            }

            emotionPool.Add(calculateHashString(activeEmotion), activeEmotion);
            activeEmotion.GetCause(am).LinkEmotion(activeEmotion.EmotionType);
            return(activeEmotion.ToDto(am));
        }
            /// <summary>
            /// Creates and Adds to the emotional state a new ActiveEmotion based on
            /// a received BaseEmotion. However, the ActiveEmotion will be created
            /// and added to the emotional state only if the final intensity for
            /// the emotion surpasses the threshold for the emotion type.
            /// </summary>
            /// <param name="emotion">the BaseEmotion that creates the ActiveEmotion</param>
            /// <returns>the ActiveEmotion created if it was added to the EmotionalState.
            /// Otherwise, if the intensity of the emotion was not enough to be added to the EmotionalState, the method returns null</returns>
            public IActiveEmotion AddEmotion(IEmotion emotion)
            {
                if (emotion == null)
                {
                    return(null);
                }

                int           decay;
                ActiveEmotion auxEmotion  = null;
                bool          reappraisal = false;

                EmotionDisposition disposition = GetEmotionDisposition(emotion.EmotionType);

                decay = disposition.Decay;

                ActiveEmotion previousEmotion;
                string        hash = calculateHashString(emotion, m_parent.m_am);

                if (emotionPool.TryGetValue(hash, out previousEmotion))
                {
                    //if this test is true, it means that this is 100% a reappraisal of the same event
                    //if not true, it is not a reappraisal, but the appraisal of a new event of the same
                    //type
                    if (previousEmotion.CauseId == emotion.CauseId)
                    {
                        reappraisal = true;
                    }

                    //in both cases we need to remove the old emotion. In the case of reappraisal it is obvious.
                    //In the case of the appraisal of a similar event, we want to aggregate all the similar resulting
                    //emotions into only one emotion
                    emotionPool.Remove(hash);
                }

                float potential = DeterminePotential(emotion);

                if (potential > disposition.Threshold)
                {
                    auxEmotion = new ActiveEmotion(emotion, potential, disposition.Threshold, decay, m_parent.Tick);
                    emotionPool.Add(hash, auxEmotion);
                    if (!reappraisal)
                    {
                        this.mood.UpdateMood(auxEmotion, m_parent);
                    }

                    auxEmotion.GetCause(m_parent.m_am).LinkEmotion(auxEmotion.EmotionType);
                }

                return(auxEmotion);
            }
            public EmotionDTO AddActiveEmotion(EmotionDTO emotion)
            {
                EmotionDisposition disposition = GetEmotionDisposition(emotion.Type);
                var    activeEmotion           = new ActiveEmotion(emotion, disposition.Threshold, disposition.Decay);
                string hash = calculateHashString(activeEmotion, m_parent.m_am);

                if (emotionPool.ContainsKey(hash))
                {
                    throw new Exception("Emotion already exists");
                }

                emotionPool.Add(hash, activeEmotion);
                activeEmotion.GetCause(m_parent.m_am).LinkEmotion(activeEmotion.EmotionType);

                return(activeEmotion.ToDto(m_parent.m_am));
            }
            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 EmotionDTO AddActiveEmotion(EmotionDTO emotion)
            {
                EmotionDisposition disposition = GetEmotionDisposition(emotion.Type);
                var activeEmotion = new ActiveEmotion(emotion, disposition.Threshold, disposition.Decay);
                string hash = calculateHashString(activeEmotion, m_parent.m_am);

                if (emotionPool.ContainsKey(hash))
                {
                    throw new ArgumentException("This given emotion is already related to given cause",nameof(emotion));
                }

                emotionPool.Add(hash, activeEmotion);
                activeEmotion.GetCause(m_parent.m_am).LinkEmotion(activeEmotion.EmotionType);

                return activeEmotion.ToDto(m_parent.m_am);
            }
 public void RemoveEmotion(EmotionDTO emotion)
 {
     var activeEmotion = new ActiveEmotion(emotion, this.DefaultEmotionDisposition.Decay,this.DefaultEmotionDisposition.Threshold);
     string hash = calculateHashString(activeEmotion, m_parent.m_am);
     emotionPool.Remove(hash);
 }
            /// <summary>
            /// Creates and Adds to the emotional state a new ActiveEmotion based on 
            /// a received BaseEmotion. However, the ActiveEmotion will be created 
            /// and added to the emotional state only if the final intensity for 
            /// the emotion surpasses the threshold for the emotion type. 
            /// </summary>
            /// <param name="emotion">the BaseEmotion that creates the ActiveEmotion</param>
            /// <returns>the ActiveEmotion created if it was added to the EmotionalState.
            /// Otherwise, if the intensity of the emotion was not enough to be added to the EmotionalState, the method returns null</returns>
            public IActiveEmotion AddEmotion(IEmotion emotion)
            {
                if (emotion == null)
                    return null;

                int decay;
                ActiveEmotion auxEmotion = null;
                bool reappraisal = false;

                EmotionDisposition disposition = GetEmotionDisposition(emotion.EmotionType);
                decay = disposition.Decay;

                ActiveEmotion previousEmotion;
                string hash = calculateHashString(emotion, m_parent.m_am);
                if (emotionPool.TryGetValue(hash,out previousEmotion))
                {
                    //if this test is true, it means that this is 100% a reappraisal of the same event
                    //if not true, it is not a reappraisal, but the appraisal of a new event of the same
                    //type
                    if (previousEmotion.CauseId == emotion.CauseId)
                        reappraisal = true;

                    //in both cases we need to remove the old emotion. In the case of reappraisal it is obvious.
                    //In the case of the appraisal of a similar event, we want to aggregate all the similar resulting
                    //emotions into only one emotion
                    emotionPool.Remove(hash);
                }

                float potential = DeterminePotential(emotion);
                if (potential > disposition.Threshold)
                {
                    auxEmotion = new ActiveEmotion(emotion, potential, disposition.Threshold, decay, m_parent.Tick);
                    emotionPool.Add(hash, auxEmotion);
                    if (!reappraisal)
                        this.mood.UpdateMood(auxEmotion,m_parent);

                    auxEmotion.GetCause(m_parent.m_am).LinkEmotion(auxEmotion.EmotionType);
                }

                return auxEmotion;
            }
예제 #12
0
        public void RemoveEmotion(EmotionDTO emotion, AM am)
        {
            var activeEmotion = new ActiveEmotion(emotion, am, 1, 1);

            emotionPool.Remove(calculateHashString(activeEmotion));
        }