Esempio n. 1
0
        public void ObserveVerb(ushort entityID, ushort targetID, ushort verbID, float verbIntensity, SortedList <ushort, Reaction> reactions)
        {
            verbIntensity *= ED.Number * 2;
            if (entityID != EntityID)
            {
                Perception perception = null;

                Reaction reaction = null;
                if (Perceptions.TryGetValue(entityID, out perception))
                {
                    VerbTargetInfo targetInfo = new VerbTargetInfo(targetID);

                    var globalPerceptions = Perceptions[0].TotalPerceptions / (Perceptions.Count - 1);
                    var entityPerceptions = Perceptions[EntityID].TotalPerceptions;
                    targetInfo.KnowThemWell = new BoundedNumber(entityPerceptions - globalPerceptions);
                    if (entityPerceptions <= globalPerceptions)
                    {
                        targetInfo.UsingGlobalPerceptions = true;
                    }

                    float verbIntensityTemp = verbIntensity;
                    if (targetID != EntityID) // you are not the target
                    {
                        //verbIntensityTemp *= verbIntensity;
                        targetInfo.GetTraits = () => new Perception[] { Perceptions[EntityID], Perceptions[targetID], Perceptions[entityID], Perceptions[0] };
                    }
                    else
                    {
                        targetInfo.IsYou     = true;
                        targetInfo.GetTraits = () => new Perception[] { Perceptions[EntityID], Perceptions[targetID], Perceptions[0] };
                    }
                    reaction = perception.ObserveVerb(verbID, targetInfo, this, verbIntensity);
                }
                else
                {
                    //if (notTarget && !Perceptions.ContainsKey(targetID))
                    // first impressions are made automatically upon being made observable
                    (perception, reaction) = Perception.FromFirstImpression(Constants.CHARACTERS[targetID], Perceptions[0], verbID, targetID, targetID != EntityID, verbIntensity, this);
                    Perceptions.Add(entityID, perception);
                }

                if (reaction == null)
                {
                    Emotions.Apathy_Passion -= 0.5f * ED.Number;
                }
                else
                {
                    reactions.Add(EntityID, reaction);
                }
            }

            // TODO: Affects self-perceptions
        }
Esempio n. 2
0
        internal Reaction ObserveVerb(ushort verbID, VerbTargetInfo target, TraitsVector reactorTraits, float verbIntensity)
        {
            IVerb verbTraits = null;

            if (ObservedActions.TryGetValue(verbID, out ObservedVerb verb))
            {
                verbTraits = verb.GetTraits();
                ObservedActions[verbID] = verb;
            }
            else
            {
                verb       = new ObservedVerb(verbID);
                verbTraits = verb.GetTraits();
                ObservedActions.Add(verbID, verb);
            }

            if (!verb.HitLimit)
            {
                ++TotalPerceptions;
                // could also be used to represent desensitization to violence
                float magnitude = (1.0f / verb.NumberOfTimes) * (1 - verbIntensity);
                //TraitsVector thisTraits = this;
                AddVector(verbTraits.ApplyMagnitude(magnitude));


                if (verbTraits.VerbType == VerbType.None)
                {
                    AddVector(verbTraits.ApplyMagnitude(magnitude));
                }
                else if (verb)
                {
                }

                return(new Reaction(
                           (reactorTraits - verbTraits).SumToBounded().Suppress(1 - magnitude),
                           ((TraitsVector)this - verbTraits).SumToBounded().Suppress(1 - magnitude),
                           verbTraits,
                           magnitude,
                           verbIntensity
                           ));
            }
            else
            {
                return(null);
            }
        }