Exemplo 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);
        }
Exemplo n.º 2
0
        public static NodeAttribute GetNodeAttribute(IntAttribute attr)
        {
            switch (attr)
            {
            case IntAttribute.Id:
                return(NodeAttribute.Id);

            case IntAttribute.IsDeleted:
                return(NodeAttribute.IsDeleted);

            case IntAttribute.IsInherited:
                return(NodeAttribute.IsInherited);

            case IntAttribute.Index:
                return(NodeAttribute.Index);

            case IntAttribute.Locked:
                return(NodeAttribute.Locked);

            case IntAttribute.LockType:
                return(NodeAttribute.LockType);

            case IntAttribute.LockTimeout:
                return(NodeAttribute.LockTimeout);

            case IntAttribute.MajorVersion:
                return(NodeAttribute.MajorVersion);

            case IntAttribute.MinorVersion:
                return(NodeAttribute.MinorVersion);

            case IntAttribute.FullTextRank:
                return(NodeAttribute.FullTextRank);

            case IntAttribute.ParentId:
                return(NodeAttribute.ParentId);

            case IntAttribute.LockedById:
                return(NodeAttribute.LockedById);

            case IntAttribute.CreatedById:
                return(NodeAttribute.CreatedById);

            case IntAttribute.ModifiedById:
                return(NodeAttribute.ModifiedById);

            case IntAttribute.IsSystem:
                return(NodeAttribute.IsSystem);

            case IntAttribute.ClosestSecurityNodeId:
                return(NodeAttribute.ClosestSecurityNodeId);

            case IntAttribute.SavingState:
                return(NodeAttribute.SavingState);

            default:
                throw new NotImplementedException("Unknown IntAttribute");
            }
        }
Exemplo n.º 3
0
		public IntExpression(IntAttribute property, ValueOperator op, PropertyType value)
		{
			if (value == null)
				throw new ArgumentNullException("value");
			if (value.DataType != DataType.Int)
				throw GetWrongPropertyDataTypeException("value", DataType.Int);
			_binExp = new BinaryExpression((NodeAttribute)property, BinaryExpression.GetOperator(op), value);
		}
 protected void PlayersOnIslandChangeHandler(IntAttribute sender, int oldVlaue, int newValue)
 {
     Debug.WriteLine("Number of players on island " + island.Name + " changed from " + oldVlaue + " to " + newValue);
     if (newValue == 0)
     {
         lastPlayerLeftAt = Game.Instance.Simulation.Time.At;
     }
 }
Exemplo n.º 5
0
 private void GamePadIndexChanged(
     IntAttribute sender,
     int oldValue,
     int newValue
     )
 {
     ChangeInt("GamePadIndex", newValue);
 }
Exemplo n.º 6
0
 private void MaxFuelChanged(
     IntAttribute sender,
     int oldValue,
     int newValue
     )
 {
     ChangeInt("MaxFuel", newValue);
 }
Exemplo n.º 7
0
 private void FrozenChanged(
     IntAttribute sender,
     int oldValue,
     int newValue
     )
 {
     ChangeInt("Frozen", newValue);
 }
Exemplo n.º 8
0
 private void LivesChanged(
     IntAttribute sender,
     int oldValue,
     int newValue
     )
 {
     ChangeInt("Lives", newValue);
 }
Exemplo n.º 9
0
		public IntExpression(PropertyType property, ValueOperator op, IntAttribute value)
		{
			if (property == null)
				throw new ArgumentNullException("property");
			if (property.DataType != DataType.Int)
				throw GetWrongPropertyDataTypeException("property", DataType.Int);
			_binExp = new BinaryExpression(property, BinaryExpression.GetOperator(op), BinaryExpression.GetNodeAttribute(value));
		}
Exemplo n.º 10
0
 public IntExpression(IntAttribute property, ValueOperator op, PropertyType value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     if (value.DataType != DataType.Int)
     {
         throw GetWrongPropertyDataTypeException("value", DataType.Int);
     }
     _binExp = new BinaryExpression((NodeAttribute)property, BinaryExpression.GetOperator(op), value);
 }
Exemplo n.º 11
0
 public IntExpression(PropertyType property, ValueOperator op, IntAttribute value)
 {
     if (property == null)
     {
         throw new ArgumentNullException("property");
     }
     if (property.DataType != DataType.Int)
     {
         throw GetWrongPropertyDataTypeException("property", DataType.Int);
     }
     _binExp = new BinaryExpression(property, BinaryExpression.GetOperator(op), BinaryExpression.GetNodeAttribute(value));
 }
Exemplo n.º 12
0
 private void FrozenChanged(
     IntAttribute sender,
     int oldValue,
     int newValue
     )
 {
     if (newValue > 0)
     {
         ChangeBool("Frozen", true);
     }
     else
     {
         ChangeBool("Frozen", false);
     }
 }
Exemplo n.º 13
0
 public SearchOrder(IntAttribute propertyToOrder, OrderDirection direction) : this((NodeAttribute)propertyToOrder, direction)
 {
 }
Exemplo n.º 14
0
        private static Expression ParseIntExpression(XmlNode node, XmlNamespaceManager nsmgr, SchemaRoot schema)
        {
            ValueOperator op         = ParseValueOperator(node);
            object        leftValue  = ParseLeftValue(node, nsmgr, schema);
            object        rightValue = ParseRightValue(node, nsmgr, schema);

            PropertyType leftProp = leftValue as PropertyType;

            if (leftProp != null)
            {
                if (rightValue == null)
                {
                    return(new IntExpression(leftProp, op, (int?)null));
                }

                PropertyType rightProp = rightValue as PropertyType;
                if (rightProp != null)
                {
                    return(new IntExpression(leftProp, op, rightProp));
                }

                string rightString = rightValue as String;
                if (rightString != null)
                {
                    return(new IntExpression(leftProp, op, XmlConvert.ToInt32(rightString)));
                }

                try
                {
                    IntAttribute rightAttr = (IntAttribute)rightValue;
                    return(new IntExpression(leftProp, op, rightAttr));
                }
                catch (Exception e) //rethrow
                {
                    throw new ApplicationException(String.Concat("Unrecognized IntAttribute: '", rightValue, "'. Source: ", node.OuterXml), e);
                }
            }
            else
            {
                IntAttribute leftAttr = (IntAttribute)leftValue;
                if (rightValue == null)
                {
                    return(new IntExpression(leftAttr, op, (int?)null));
                }

                PropertyType rightProp = rightValue as PropertyType;
                if (rightProp != null)
                {
                    return(new IntExpression(leftAttr, op, rightProp));
                }

                string rightString = rightValue as String;
                if (rightString != null)
                {
                    return(new IntExpression(leftAttr, op, XmlConvert.ToInt32(rightString)));
                }

                try
                {
                    IntAttribute rightAttr = (IntAttribute)rightValue;
                    return(new IntExpression(leftAttr, op, rightAttr));
                }
                catch (Exception e) //rethrow
                {
                    throw new ApplicationException(String.Concat("Unrecognized IntAttribute: '", rightValue, "'. Source: ", node.OuterXml), e);
                }
            }
        }
Exemplo n.º 15
0
		public IntExpression(IntAttribute property, ValueOperator op, IntAttribute value)
		{
			_binExp = new BinaryExpression((NodeAttribute)property, BinaryExpression.GetOperator(op), BinaryExpression.GetNodeAttribute(value));
		}
Exemplo n.º 16
0
		public SearchOrder(IntAttribute propertyToOrder) : this(propertyToOrder, OrderDirection.Asc) { }
Exemplo n.º 17
0
		public SearchOrder(IntAttribute propertyToOrder, OrderDirection direction) : this((NodeAttribute)propertyToOrder, direction) { }
Exemplo n.º 18
0
        private Element ConvertXElementToElement(XElement element)
        {
            var elementValues = new List <string>();

            if (!element.Elements().Any())
            {
                var tElem = _oldRoot.Descendants(element.Name).Where(x => GetParentsAsString(x, -1) == GetParentsAsString(element, -1) && !x.Elements().Any()).Select(e => e.Value);
                elementValues.AddRange(tElem);
            }

            var xElementList = _oldRoot.Descendants(element.Name).GroupBy(el => el.Parent).Select(g => new { g.Key, Count = g.Count() }).Where(x => x.Count > 1);

            Element returnElement;
            var     elementName = element.Name.LocalName;
            var     elementType = DataType.GetDataTypeFromList(elementValues, _dateFormat, _dateTimeFormat);

            switch (elementType.type)
            {
            case DataType.Type.Date:
                returnElement = new DateTimeElement(elementName, _dateFormat);
                break;

            case DataType.Type.DateTime:
                returnElement = new DateTimeElement(elementName, _dateTimeFormat);
                break;

            case DataType.Type.Bool:
                returnElement = new BoolElement(elementName, "True", "False");
                break;

            case DataType.Type.@bool:
                returnElement = new BoolElement(elementName, "true", "false");
                break;

            case DataType.Type.@int:
                returnElement = new IntElement(elementName);
                break;

            case DataType.Type.@decimal:
                returnElement = new DecimalElement(elementName);
                break;

            case DataType.Type.@string:
                returnElement = new StringElement(elementName);
                break;

            default:
                returnElement = new Element(elementName);
                break;
            }
            returnElement.Enumerable      = xElementList.Any();
            returnElement.Type            = elementType;
            returnElement.OriginalElement = element;

            foreach (var xElement in element.Elements())
            {
                returnElement.Elements.Add(ConvertXElementToElement(xElement));
            }

            foreach (var xAttribute in element.Attributes())
            {
                var tElements = _oldRoot.DescendantsAndSelf(element.Name).Where(x => GetParentsAsString(x, -1) == GetParentsAsString(element, -1)).ToList();

                var xAttr           = xAttribute;
                var attributeValues = tElements.Select(tElement => tElement.Attribute(xAttr.Name)).Select(attribute => attribute != null ? attribute.Value : "").ToList();

                Attribute thisAttribute;
                var       attributeName = xAttribute.Name.LocalName;

                if (xAttribute.IsNamespaceDeclaration)
                {
                    returnElement.NamespaceAttributes.Add(xAttribute);
                    continue;
                }

                if (attributeName == "schemaLocation")
                {
                    thisAttribute = new SchemaLocationAttribute(attributeName, xAttribute.Value);
                    returnElement.Attributes.Add(thisAttribute);
                    continue;
                }

                var attributeType = DataType.GetDataTypeFromList(attributeValues, _dateFormat, _dateTimeFormat);
                switch (attributeType.type)
                {
                case DataType.Type.Date:
                    thisAttribute = new DateTimeAttribute(attributeName, _dateFormat);
                    break;

                case DataType.Type.DateTime:
                    thisAttribute = new DateTimeAttribute(attributeName, _dateTimeFormat);
                    break;

                case DataType.Type.Bool:
                    thisAttribute = new BoolAttribute(attributeName, "True", "False");
                    break;

                case DataType.Type.@bool:
                    thisAttribute = new BoolAttribute(attributeName, "true", "false");
                    break;

                case DataType.Type.@int:
                    thisAttribute = new IntAttribute(attributeName);
                    break;

                case DataType.Type.@decimal:
                    thisAttribute = new DecimalAttribute(attributeName);
                    break;

                case DataType.Type.@string:
                    thisAttribute = new StringAttribute(attributeName);
                    break;

                default:
                    thisAttribute = new Attribute(attributeName);
                    break;
                }
                thisAttribute.Type = attributeType;

                returnElement.Attributes.Add(thisAttribute);
            }

            return(returnElement);
        }
Exemplo n.º 19
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);
        }
Exemplo n.º 20
0
		public static NodeAttribute GetNodeAttribute(IntAttribute attr)
		{
			switch (attr)
			{
				case IntAttribute.Id:
					return NodeAttribute.Id;
                case IntAttribute.IsDeleted:
                    return NodeAttribute.IsDeleted;
                case IntAttribute.IsInherited:
                    return NodeAttribute.IsInherited;
                case IntAttribute.Index:
					return NodeAttribute.Index;
				case IntAttribute.Locked:
					return NodeAttribute.Locked;
				case IntAttribute.LockType:
					return NodeAttribute.LockType;
				case IntAttribute.LockTimeout:
					return NodeAttribute.LockTimeout;
				case IntAttribute.MajorVersion:
					return NodeAttribute.MajorVersion;
				case IntAttribute.MinorVersion:
					return NodeAttribute.MinorVersion;
				case IntAttribute.FullTextRank:
					return NodeAttribute.FullTextRank;
				case IntAttribute.ParentId:
					return NodeAttribute.ParentId;
				case IntAttribute.LockedById:
					return NodeAttribute.LockedById;
				case IntAttribute.CreatedById:
					return NodeAttribute.CreatedById;
				case IntAttribute.ModifiedById:
					return NodeAttribute.ModifiedById;
				default:
					throw new NotImplementedException("Unknown IntAttribute");
			}
		}
Exemplo n.º 21
0
 public SearchOrder(IntAttribute propertyToOrder) : this(propertyToOrder, OrderDirection.Asc)
 {
 }
Exemplo n.º 22
0
 public IntExpression(IntAttribute property, ValueOperator op, IntAttribute value)
 {
     _binExp = new BinaryExpression((NodeAttribute)property, BinaryExpression.GetOperator(op), BinaryExpression.GetNodeAttribute(value));
 }
Exemplo n.º 23
0
 public static void labelAttribute(this IntAttribute _p0)
 {
 }