Ejemplo n.º 1
0
        public GameAttribute(int id, int defaultValue, int u3, int u4, int u5, string scriptA, string scriptB, string name, GameAttributeEncoding encodingType, byte u10, int min, int max, int bitCount)
        {
            Id = id;
            _DefaultValue.Value = defaultValue;
            U3 = u3;
            U4 = u4;
            U5 = u5;
            ScriptA = scriptA;
            ScriptB = scriptB;
            Name = name;
            EncodingType = encodingType;
            U10 = u10;

            Min = new GameAttributeValue(min);
            Max = new GameAttributeValue(max);
            BitCount = bitCount;
        }
Ejemplo n.º 2
0
        public GameAttribute(int id, float defaultValue, int u3, int u4, int u5, string scriptA, string scriptB, string name, GameAttributeEncoding encodingType, byte u10, float min, float max, int bitCount)
        {
            Id = id;
            _DefaultValue.ValueF = defaultValue;
            U3           = u3;
            U4           = u4;
            U5           = u5;
            ScriptA      = scriptA;
            ScriptB      = scriptB;
            Name         = name;
            EncodingType = encodingType;
            U10          = u10;

            Min      = new GameAttributeValue(min);
            Max      = new GameAttributeValue(max);
            BitCount = bitCount;
        }
Ejemplo n.º 3
0
        private void RawSetAttributeValue(GameAttribute attribute, int? key, GameAttributeValue value)
        {
            KeyId keyid;
            keyid.Id = attribute.Id;
            keyid.Key = key;

            _attributeValues[keyid] = value;

            if (!_changedAttributes.Contains(keyid))
                _changedAttributes.Add(keyid);

            // mark dependant attributes as changed
            if (attribute.Dependents != null)
            {
                foreach (var dependent in attribute.Dependents)
                {
                    int? usekey;

                    if (dependent.IsManualDependency)
                        usekey = dependent.Key;
                    else
                        usekey = dependent.UsesExplicitKey ? null : key;

                    if (dependent.IsManualDependency || dependent.UsesExplicitKey == false || dependent.Key == key)
                    {
                        // TODO: always update dependent values for now, but eventually make this lazy
                        RawSetAttributeValue(dependent.Attribute, usekey, dependent.Attribute.ScriptFunc(this, usekey));
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void SetAttributeValue(GameAttribute attribute, int? key, GameAttributeValue value)
        {
            // error if scripted attribute and is not settable
            if (attribute.ScriptFunc != null && !attribute.ScriptedAndSettable)
            {
                var frame = new System.Diagnostics.StackFrame(2, true);
                Logger.Error("illegal value assignment for GameAttribute.{0} attempted at {1}:{2}",
                    attribute.Name, frame.GetFileName(), frame.GetFileLineNumber());
            }

            if (attribute.EncodingType == GameAttributeEncoding.IntMinMax)
            {
                if (value.Value < attribute.Min.Value || value.Value > attribute.Max.Value)
                    throw new ArgumentOutOfRangeException("GameAttribute." + attribute.Name.Replace(' ', '_'), "Min: " + attribute.Min.Value + " Max: " + attribute.Max.Value + " Tried to set: " + value.Value);
            }
            else if (attribute.EncodingType == GameAttributeEncoding.Float16)
            {
                if (value.ValueF < GameAttribute.Float16Min || value.ValueF > GameAttribute.Float16Max)
                    throw new ArgumentOutOfRangeException("GameAttribute." + attribute.Name.Replace(' ', '_'), "Min: " + GameAttribute.Float16Min + " Max " + GameAttribute.Float16Max + " Tried to set: " + value.ValueF);
            }

            RawSetAttributeValue(attribute, key, value);
        }
Ejemplo n.º 5
0
        void SetAttributeValue(GameAttribute attribute, int? key, GameAttributeValue value)
        {
            KeyId keyid;
            keyid.Id = attribute.Id;
            keyid.Key = key;

            if (attribute.EncodingType == GameAttributeEncoding.IntMinMax)
            {
                if (value.Value < attribute.Min.Value || value.Value > attribute.Max.Value)
                    throw new ArgumentOutOfRangeException("GameAttribute." + attribute.Name.Replace(' ', '_'), "Min: " + attribute.Min.Value + " Max: " + attribute.Max.Value + " Tried to set: " + value.Value);
            }
            else if (attribute.EncodingType == GameAttributeEncoding.Float16)
            {
                if (value.ValueF < GameAttribute.Float16Min || value.ValueF > GameAttribute.Float16Max)
                    throw new ArgumentOutOfRangeException("GameAttribute." + attribute.Name.Replace(' ', '_'), "Min: " + GameAttribute.Float16Min  + " Max " + GameAttribute.Float16Max + " Tried to set: " + value.ValueF);
            }
            _attributeValues[keyid] = value;
        }