示例#1
0
        private void StartCharacterInteraction(Brain brain)
        {
            GenericInteractionAIBehaviour behaviour = (GenericInteractionAIBehaviour)brain.ActiveBlockingBehaviour;

            behaviour.StartBehaviour(this);

            for (int i = 0; i < CharacterInfluences.Length; i++)
            {
                StatInfluencerSO influencer = ScriptableObject.CreateInstance <StatInfluencerSO>();
                influencer.InteractionName  = CharacterInfluences[i].statTemplate.name + " influencer from " + InteractionName + " (" + GetInstanceID() + ")";
                influencer.Trigger          = this;
                influencer.stat             = CharacterInfluences[i].statTemplate;
                influencer.maxChange        = CharacterInfluences[i].maxChange;
                influencer.duration         = m_Duration;
                influencer.CooldownDuration = m_Cooldown;

                if (brain.TryAddInfluencer(influencer))
                {
                    m_Reservations.Remove(brain);
                    m_ActiveInteractors.Add(brain);
                    m_TimeOfLastInfluence.Remove(brain);
                    m_TimeOfLastInfluence.Add(brain, Time.timeSinceLevelLoad);
                }
            }
        }
示例#2
0
        /// <summary>
        /// Create a memory about an influencer object. See `AddMemory(MemorySO memory)`.
        /// </summary>
        /// <param name="influencer">The influencer that this memory should record.</param>
        /// <param name="isGood">Is this a good memory that represents an experience to be repeated?</param>
        internal void AddMemory(StatInfluencerSO influencer, bool isGood)
        {
            MemorySO memory = ScriptableObject.CreateInstance <MemorySO>();

            memory.about     = influencer.generator;
            memory.stat      = influencer.stat;
            memory.influence = influencer.maxChange;
            memory.cooldown  = influencer.cooldown;
            memory.isGood    = isGood;
            AddMemory(memory);
        }
示例#3
0
        private void AddObjectInfluence()
        {
            for (int i = 0; i < ObjectInfluences.Length; i++)
            {
                StatInfluencerSO influencer = ScriptableObject.CreateInstance <StatInfluencerSO>();
                influencer.InteractionName  = ObjectInfluences[i].statTemplate.name + " influencer from " + InteractionName + " (" + GetInstanceID() + ")";
                influencer.Trigger          = this;
                influencer.stat             = ObjectInfluences[i].statTemplate;
                influencer.maxChange        = ObjectInfluences[i].maxChange;
                influencer.duration         = m_Duration;
                influencer.CooldownDuration = m_Cooldown;

                m_StatsTracker.TryAddInfluencer(influencer);
            }
        }
示例#4
0
        /// <summary>
        /// Create a memory about an influencer object. See `AddMemory(MemorySO memory)`.
        /// </summary>
        /// <param name="influencer">The influencer that this memory should record.</param>
        /// <param name="isGood">Is this a good memory that represents an experience to be repeated?</param>
        internal void AddMemory(StatInfluencerSO influencer, bool isGood)
        {
            if (influencer.Generator == null)
            {
                return;                               // don't hold memories about behaviours only influencers
            }
            MemorySO memory = ScriptableObject.CreateInstance <MemorySO>();

            memory.about           = influencer.Generator;
            memory.interactionName = influencer.InteractionName;
            memory.stat            = influencer.stat;
            memory.influence       = influencer.maxChange;
            memory.cooldown        = influencer.CooldownDuration;
            memory.isGood          = isGood;
            AddMemory(memory);
        }
示例#5
0
        /// <summary>
        /// Add all the character influencers that operate over time from this behaviour to the stats tracker.
        /// </summary>
        /// <param name="duration">The time over which the influencers should be applied</param>
        internal void AddCharacterInfluencers(float duration)
        {
            for (int i = 0; i < m_CharacterInfluences.Length; i++)
            {
                if (!m_CharacterInfluences[i].applyOnCompletion)
                {
                    StatInfluencerSO influencer = ScriptableObject.CreateInstance <StatInfluencerSO>();
                    influencer.InteractionName  = m_CharacterInfluences[i].statTemplate.name;
                    influencer.Trigger          = null;
                    influencer.stat             = m_CharacterInfluences[i].statTemplate;
                    influencer.maxChange        = m_CharacterInfluences[i].maxChange;
                    influencer.duration         = duration;
                    influencer.CooldownDuration = 0;

                    Brain.TryAddInfluencer(influencer);
                }
            }
        }