コード例 #1
0
        /// <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, AM am, EmotionDispositionDTO disposition, ulong _tick)
        {
            if (emotion == null)
            {
                return(null);
            }
            tick = _tick;
            ActiveEmotion auxEmotion  = null;
            bool          reappraisal = false;

            var decay = disposition.Decay;

            ActiveEmotion previousEmotion;

            if (emotionPool.TryGetValue(calculateHashString(emotion), 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
                emotionPool.Remove(calculateHashString(emotion));
            }

            float potential = DeterminePotential(emotion);

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

                auxEmotion.GetCause(am).LinkEmotion(auxEmotion.EmotionType);
            }

            return(auxEmotion);
        }
コード例 #2
0
        /// <summary>
        /// Creates and adds an emotional disposition to the asset.
        /// </summary>
        /// <param name="emotionDispositionDto">The dto containing the parameters to create a new emotional disposition on the asset</param>
        public void AddEmotionDisposition(EmotionDispositionDTO emotionDispositionDto)
        {
            var disp = new EmotionDisposition(emotionDispositionDto);

            this.m_emotionDispositions.Add(disp.Emotion, disp);
        }
コード例 #3
0
 public EmotionDisposition(EmotionDispositionDTO dispDto)
 {
     Emotion   = dispDto.Emotion;
     Decay     = dispDto.Decay;
     Threshold = dispDto.Threshold;
 }
コード例 #4
0
 public void AddEmotionDisposition(EmotionDispositionDTO emotionDispositionDto)
 {
     m_emotionalState.AddEmotionDisposition(new EmotionDisposition(emotionDispositionDto));
 }