Beispiel #1
0
    public override void PreAttributeChange(AttributeSystemComponent attributeSystem, List <AttributeValue> prevAttributeValues, ref List <AttributeValue> currentAttributeValues)
    {
        var attributeCacheDict = attributeSystem.mAttributeIndexCache;

        if (attributeCacheDict.TryGetValue(PrimaryAttribute, out var primaryAttributeIndex))
        {
            var prevValue    = prevAttributeValues[primaryAttributeIndex].CurrentValue;
            var currentValue = currentAttributeValues[primaryAttributeIndex].CurrentValue;

            if (prevValue != currentValue)
            {
                // If value has changed, log a message to console
                Debug.Log($"{attributeSystem.gameObject.name}: {currentAttributeValues[primaryAttributeIndex].Attribute.Name} modified.  Old Value: {prevValue}.  New Value: {currentValue}.");
            }
        }
    }
Beispiel #2
0
    public override void PreAttributeChange(AttributeSystemComponent attributeSystem, List <AttributeValue> prevAttributeValues, ref List <AttributeValue> currentAttributeValues)
    {
        var attributeCacheDict = attributeSystem.mAttributeIndexCache;

        if (attributeCacheDict.TryGetValue(PrimaryAttribute, out var primaryAttributeIndex))
        {
            var prevValue    = prevAttributeValues[primaryAttributeIndex].CurrentValue;
            var currentValue = currentAttributeValues[primaryAttributeIndex].CurrentValue;

            if (prevValue != currentValue)
            {
                // Instantiate a prefab for displaying the number
                var damageNumber = Instantiate(damageNumberComponent, attributeSystem.gameObject.transform.position, attributeSystem.gameObject.transform.rotation);

                // The prefab has an Initialise method, which allows us to pass in the change magnitude, so we can show the appropriate number
                damageNumber.Initialise(currentValue - prevValue);
            }
        }
    }
Beispiel #3
0
    public override void PreAttributeChange(AttributeSystemComponent attributeSystem, List <AttributeValue> prevAttributeValues, ref List <AttributeValue> currentAttributeValues)
    {
        var attributeCacheDict = attributeSystem.mAttributeIndexCache;

        ClampAttributeToMax(PrimaryAttribute, MaxAttribute, currentAttributeValues, attributeCacheDict);
    }