public MethodGetterSetterTrait(ABCFile abc, string objName, TraitType traitType)
        {
            _abc = abc;

            ObjName = objName;
            TraitType = traitType;
        }
Example #2
0
        public SlotConstantTrait(ABCFile abc, string objName, TraitType traitType)
        {
            _abc = abc;

            ObjName = objName;
            TraitType = traitType;
        }
Example #3
0
        public SlotConstantTrait(ABCFile abc, FlashReader reader, string objName, TraitType traitType)
            : this(abc, objName, traitType)
        {
            SlotId = reader.Read7BitEncodedInt();
            TypeIndex = reader.Read7BitEncodedInt();
            ValueIndex = reader.Read7BitEncodedInt();

            if (ValueIndex != 0)
                ValueType = (ConstantType)reader.ReadByte();
        }
Example #4
0
 public Trait(String name, TraitType effectType)
     : this(name)
 {
     Effect = effectType;
 }
 public MethodGetterSetterTrait(ABCFile abc, FlashReader reader, string objName, TraitType traitType) :
     this(abc, objName, traitType)
 {
     DispId = reader.Read7BitEncodedInt();
     MethodIndex = reader.Read7BitEncodedInt();
 }
Example #6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="source"></param>
        public void Parse(Stream source)
        {
            // UNTESTED
            Name = VariableLengthInteger.ReadU30(source);

            byte kind = VariableLengthInteger.ReadU8(source);
            byte kindType = (byte)(kind & 0x0F);
            byte kindAttr = (byte)((kind & 0xF0) >> 4);

            if (!Enum.IsDefined(typeof(TraitType), kindType))
            {
                AbcFormatException fe = new AbcFormatException("Invalid Traits_info kind " + kindType.ToString("d"));
                Log.Error(this, fe);
                throw fe;
            }
            Type = (TraitType)kindType;

            //
            // "Any other combination of attribute with kind is ignored."
            // - so we test for it.
            //
            AttribFinal = (kindAttr & 0x01) != 0 ? true : false;
            AttribOverride = (kindAttr & 0x02) != 0 ? true : false;
            AttribMetadata = (kindAttr & 0x04) != 0 ? true : false;

            if (AttribFinal && (!((Type == TraitType.Trait_Getter) || (Type == TraitType.Trait_Setter) || (Type == TraitType.Trait_Method))))
            {
                AbcFormatException fe = new AbcFormatException("ATTR_Final with trait type " + Enum.GetName(typeof(TraitType), Type));
                Log.Error(this, fe);
                throw fe;
            }
            if (AttribOverride && (!((Type == TraitType.Trait_Getter) || (Type == TraitType.Trait_Setter) || (Type == TraitType.Trait_Method))))
            {
                AbcFormatException fe = new AbcFormatException("ATTR_Override with trait type " + Enum.GetName(typeof(TraitType), Type));
                Log.Error(this, fe);
                throw fe;
            }

            //
            // Just to point out how this works: only one of them
            // is going to be valid
            //
            switch (Type)
            {
                case TraitType.Trait_Const:
                case TraitType.Trait_Slot:
                    _Data_Slot = ParseSlot(source);
                    break;

                case TraitType.Trait_Class:
                    _Data_Class = ParseClass(source);
                    break;

                case TraitType.Trait_Function:
                    _Data_Function = ParseFunction(source);
                    break;

                case TraitType.Trait_Method:
                case TraitType.Trait_Getter:
                case TraitType.Trait_Setter:
                    _Data_Method = ParseMethod(source);
                    break;

                default:
                    Exception e = new Exception("Internal error: invalid _Type 0x" + Type.ToString("X02") + " reached end of switch");
                    Log.Error(this, e);
                    throw e;
            }

            if (AttribMetadata)
            {
                UInt32 metadataCount = VariableLengthInteger.ReadU30(source);
                _Metadata = new List<UInt32>((int)metadataCount);
                for (uint i = 0; i < metadataCount; i++)
                {
                    UInt32 metav = VariableLengthInteger.ReadU30(source);
                    _Metadata.Add(metav);
                }
            }
        }
        /// <summary>
        /// Updates the current trait type to a specified trait
        /// </summary>
        /// <param name="type"> the trait type to update to</param>
        public void UpdateType(TraitType type)
        {
            traitType = type;
            setDefaultValues();

            switch (traitType) {
                case TraitType.Default:
                    //Do Nothing
                    break;
                case TraitType.Slow:
                    MoveSpeed = 3f;
                    break;
                case TraitType.Incontenent:
                    MoveSpeed = 11f;
                    ToiletNeedRate = 1.5f;
                    break;
                case TraitType.Alcoholic:
                    MoveSpeed = 8f;
                    DrinkNeedRate = 6;
                    break;
                case TraitType.Dancer:
                    MoveSpeed = 14f;
                    DanceNeedRate = 7;
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
        }
 /// <summary>
 /// Constructs a TraitProperties object with the specified trait type
 /// </summary>
 /// <param name="type"> the trait type to get properties for</param>
 public TraitProperties(TraitType type)
 {
     UpdateType(type);
 }
 public MethodGetterSetterTrait(ABCFile abc, TraitType traitType)
 {
     ABC = abc;
     TraitType = traitType;
 }
Example #10
0
 public SlotConstantTrait(ABCFile abc, TraitType traitType)
 {
     ABC = abc;
     TraitType = traitType;
 }