Ejemplo n.º 1
0
        public EntityProperty(Entity parent, ServerClassProperty serverClassProperty)
        {
            this.Name = serverClassProperty.Name;
            this.Parent = parent;
            this.ServerClassProperty = serverClassProperty;

            m_UpdateObservers = new List<OnEntityPropertyUpdated>();
        }
Ejemplo n.º 2
0
        private object ReadServerClassProperty(BitStream bitStream, ServerClassProperty serverClassProperty)
        {
            DataTableProperty dataTableProperty = serverClassProperty.DataTableProperty;

            object result = null;

            switch (dataTableProperty.Type)
            {
                case DataTablePropertyType.Int:
                    {
                        result = ReadInt32(bitStream, dataTableProperty);

                        break;
                    }
                case DataTablePropertyType.Float:
                    {
                        result = ReadFloat(bitStream, dataTableProperty);

                        break;
                    }
                case DataTablePropertyType.Vector:
                    {
                        result = ReadVector(bitStream, dataTableProperty);

                        break;
                    }
                case DataTablePropertyType.Array:
                    {
                        result = ReadArray(bitStream, serverClassProperty);

                        break;
                    }
                case DataTablePropertyType.String:
                    {
                        result = ReadString(bitStream, dataTableProperty);

                        break;
                    }
                case DataTablePropertyType.VectorXY:
                    {
                        result = ReadVectorXY(bitStream, dataTableProperty);

                        break;
                    }

                default:
                    {
                        Console.WriteLine("Unable to Decode Property");

                        break;
                    }
            }

            return result;
        }
Ejemplo n.º 3
0
        private object[] ReadArray(BitStream bitStream, ServerClassProperty serverClassProperty)
        {
            int numberOfElements = serverClassProperty.DataTableProperty.NumberOfElements;
            int maxElements = numberOfElements;

            int numberOfBits = 1;

            while ((maxElements >>= 1) != 0)
            {
                numberOfBits++;
            }

            int count = (int)bitStream.ReadBits(numberOfBits);

            object[] result = new object[count];

            ServerClassProperty intermediaryServerClassProperty = new ServerClassProperty("", serverClassProperty.ArrayElementProperty, null);

            for (int i = 0; i < count; i++)
            {
                result[i] = ReadServerClassProperty(bitStream, intermediaryServerClassProperty);
            }

            return result;
        }
Ejemplo n.º 4
0
        private void SetServerClassProperties(ServerClass serverClass, DataTable dataTable, List<ServerClassProperty> serverClassProperties, string propertyNamePrefix, List<ExcludedDataTableProperty> currentExcludes)
        {
            for (int i = 0; i < dataTable.Properties.Count; i++)
            {
                DataTableProperty dataTableProperty = dataTable.Properties[i];

                if (dataTableProperty.Flags.HasFlag(DataTablePropertyFlags.InsideArray) || dataTableProperty.Flags.HasFlag(DataTablePropertyFlags.Exclude) || IsPropertyExcluded(dataTable, dataTableProperty, currentExcludes))
                {
                    continue;
                }

                if (dataTableProperty.Type == DataTablePropertyType.DataTable)
                {
                    DataTable linkedDataTable = m_Demo.DataTables.GetDataTable(dataTableProperty.DataTableName);

                    if (dataTableProperty.Flags.HasFlag(DataTablePropertyFlags.Collapsible))
                    {
                        SetServerClassProperties(serverClass, linkedDataTable, serverClassProperties, propertyNamePrefix, currentExcludes);
                    }
                    else
                    {
                        string prefix = String.Format("{0}{1}", propertyNamePrefix, (dataTableProperty.Name.Length > 0) ? dataTableProperty.Name + "." : "");

                        SetServerClassProperties(serverClass, linkedDataTable, prefix, currentExcludes);
                    }
                }
                else
                {
                    ServerClassProperty serverClassProperty;

                    if (dataTableProperty.Type == DataTablePropertyType.Array)
                    {
                        serverClassProperty = new ServerClassProperty(propertyNamePrefix + dataTableProperty.Name, dataTableProperty, dataTable.Properties[i - 1]);
                    }
                    else
                    {
                        serverClassProperty = new ServerClassProperty(propertyNamePrefix + dataTableProperty.Name, dataTableProperty, null);
                    }

                    serverClassProperties.Add(serverClassProperty);
                }
            }
        }