Ejemplo n.º 1
0
        public void AddAttribute(string name, AttributeTypes type, string value)
        {
            Attribute attribute = null;

            switch (type)
            {
            case AttributeTypes.String: attribute = new StringAttribute(name); break;

            case AttributeTypes.Int: attribute = new IntAttribute(name); break;

            case AttributeTypes.Float: attribute = new FloatAttribute(name); break;

            case AttributeTypes.Vector2: attribute = new Vector2Attribute(name); break;

            case AttributeTypes.Vector3: attribute = new Vector3Attribute(name); break;

            case AttributeTypes.Quaternion: attribute = new QuaternionAttribute(name); break;

            case AttributeTypes.Matrix: attribute = new MatrixAttribute(name); break;

            case AttributeTypes.Bool: attribute = new BoolAttribute(name); break;

            default: throw new System.Exception("AttributeType '" + type + "' does not exist!");
            }
            attribute.Initialize(value);
            AddAttribute(attribute);
        }
Ejemplo n.º 2
0
 private void MaxEnergyChanged(
     FloatAttribute sender,
     float oldValue,
     float newValue
     )
 {
     ChangeFloat("MaxEnergy", newValue);
 }
Ejemplo n.º 3
0
 private void MaxHealthChanged(
     FloatAttribute sender,
     float oldValue,
     float newValue
     )
 {
     ChangeFloat("MaxHealth", newValue);
 }
Ejemplo n.º 4
0
 private void HealthChanged(
     FloatAttribute sender,
     float oldValue,
     float newValue
     )
 {
     if (oldValue > newValue && newValue < 100) // hack, this should be maxhealth but where do i get it?
     {
         ChangeBool("Blink", true);
     }
 }
Ejemplo n.º 5
0
        public override Panel CreateControl(BaseConfigurationAttribute attr, PropertyInfo prop, object configuration_instance)
        {
            var panel = base.CreateControl(attr, prop, configuration_instance);

            FloatAttribute iattr = attr as FloatAttribute;

            var slider   = panel.Children[1] as Slider;
            var num_view = panel.Children[2] as TextBox;

            slider.Maximum       = iattr.MaxValue;
            slider.Minimum       = iattr.MinValue;
            slider.TickFrequency = iattr.Step;
            num_view.SetBinding(TextBox.TextProperty, new Binding("Value")
            {
                Source = slider,
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged,
                StringFormat        = "F2"
            });

            return(panel);
        }
Ejemplo n.º 6
0
        private CarPartAttribute GetPreparedAttribute(CarPartAttributeData attributeData)
        {
            var attributeName = HashMapper.ResolveHash(attributeData.NameHash);
            CarPartAttribute attribute;

            switch (attributeName)
            {
            case "PARTID_UPGRADE_GROUP":
                attribute = new PartIdAttribute();
                break;

            case "LANGUAGEHASH":
                attribute = new LanguageHashAttribute();
                break;

            case "KITNUMBER":
                attribute = new KitNumberAttribute();
                break;

            case "LOD_NAME_PREFIX_SELECTOR":
                attribute = new LodNamePrefixAttribute();
                break;

            case "LOD_BASE_NAME":
                attribute = new LodBaseNameAttribute();
                break;

            case "NAME_OFFSET":
                attribute = new NameOffsetAttribute();
                break;

            case "LOD_CHARACTERS_OFFSET":
                attribute = new LodCharactersOffsetAttribute();
                break;

            case "LOD_NAME_PREFIX_NAMEHASH":
                attribute = new LodNamePrefixNameHashAttribute();
                break;

            case "ONLINE":
            case "STOCK":
            case "CARBONFIBRE":
            case "CENTER":
            case "0x87557E1E":
            case "0xF9661A07":
            case "STOCK_MATERIAL":
            case "USEMARKER1":
            case "FULLBODY":
            case "MIRROR":
            case "ISDECAL":
                attribute = new BoolAttribute(attributeName);
                break;

            case "TEXTURE":
                attribute = new TextureAttribute();
                break;

            case "0x10C98090":
            case "MAX_LOD":
            case "COLOR0ID":
            case "COLOR1ID":
            case "COLOR2ID":
            case "COLOR3ID":
            case "VINYLLANGUAGEHASH":
            case "TEXTUREHASH":
            case "CV":
            case "SPECIFICCARNAME":
            case "0x6BA02C05":
            case "MAT0":
            case "MAT1":
            case "MAT2":
            case "MAT3":
            case "MAT4":
            case "MAT5":
            case "MAT6":
            case "MAT7":
            case "0xC9818DFC":
            case "0xEBB03E66":
            case "MATNAMEA":
            case "MATNAMEB":
            case "0xD68A7BAB":
            case "RED":
            case "GREEN":
            case "BLUE":
            case "SWATCH":
            case "GROUPLANGUAGEHASH":
            case "0x04B39858":
            case "0x5412A1D9":
            case "MODEL_TABLE_OFFSET":
            case "MORPHTARGET_NUM":
            case "0xCE7D8DB5":
            case "0x7D29CF3E":
            case "0x65F58556":
            case "GLOSS":
            case "0xB5548ED7":
            case "0x1B0EA1A9":
            case "0xEB0101E2":
            case "0xE80A3B62":
            case "PAINTGROUP":
            case "DAMAGELEVEL":
                attribute = new IntAttribute(attributeName);
                break;

            case "BLEND":
            case "0x9A9B6DDC":
                attribute = new FloatAttribute(attributeName);
                break;

            default:
                attribute = new IntAttribute(attributeName);
                Debug.WriteLine("WARNING: Unimplemented attribute {0}; value={1} (0x{1:X8})", attributeName, attributeData.UnsignedParam);
                break;
            }

            attribute.LoadValue(attributeData);

            if (attribute is StringBasedAttribute sba)
            {
                sba.ReadStrings(_stringsDictionary);
            }

            return(attribute);
        }