Beispiel #1
0
        public static ICollection <IField> GetFieldInfo(Type type)
        {
            ICollection <IField> fields = new List <IField>();

            if (type == typeof(InheritanceTestSuperEntityExt))
            {
                var idCol = new DefaultColumn("IdCol", true, false, ColumnType.Integer);
                idCol.SubClassCommonColumn = true;
                fields.Add(idCol);
                fields.Add(new DefaultColumn("Name", ColumnType.Varchar));
            }
            else if (type == typeof(InheritanceTestSubEntityAExt))
            {
                var idCol = new DefaultColumn("IdCol", true, false, ColumnType.Integer);
                idCol.SubClassCommonColumn = true;
                fields.Add(idCol);
                fields.Add(new DefaultColumn("NameA", ColumnType.Varchar));
            }
            else if (type == typeof(InheritanceTestSubEntityBExt))
            {
                var idCol = new DefaultColumn("IdCol", true, false, ColumnType.Integer);
                idCol.SubClassCommonColumn = true;
                fields.Add(idCol);
                fields.Add(new DefaultColumn("NameB", ColumnType.Varchar));
            }
            return(fields);
        }
Beispiel #2
0
        private static IColumn CreateColumnMapping(PropertyInfo propertyInfo, ColumnInfo columnInfo)
        {
            IColumn column = new DefaultColumn(propertyInfo.Name, columnInfo.ColumnType, columnInfo.Nullable);

            if (columnInfo.ColumnName != null &&
                columnInfo.ColumnName.Trim().Length > 0)
            {
                column.ColumnName = columnInfo.ColumnName;
            }
            column.Key  = columnInfo.Key;
            column.Size = columnInfo.Size;
            column.SubClassCommonColumn = columnInfo.SubClassCommonColumn;
            column.ReadFromSequence     = columnInfo.ReadFromSequence;
            if (column.ReadFromSequence)
            {
                try
                {
                    column.SequenceGenerator =
                        (ISequenceGenerator)Activator.CreateInstance(columnInfo.SequenceGeneratorType);
                }
                catch (Exception e)
                {
                    throw new SequenceGeneratorInitializationException(e.Message, e);
                }
            }
            return(column);
        }
    public void Initialize()
    {
        this.Clear();
        MapGenerator.Random = new System.Random();
        this.Map            = new Dictionary <Vector3i, Slot>();
        this.failureQueue   = new Queue <Slot>();
        this.buildQueue     = new Queue <Slot>();

        this.createModules();
        this.defaultColumn = new DefaultColumn(this);
    }
Beispiel #4
0
    public void SimplifyNeighborData()
    {
        this.Initialize();
        int count  = 0;
        var center = new Vector3i(0, this.Height / 2, 0);

        this.defaultColumn = null;
        int p = 0;

        foreach (var module in this.Modules)
        {
            this.InitialModuleHealth = this.createInitialModuleHealth(this.Modules);
            foreach (var s in this.Map.Values)
            {
                s.Module = null;
                for (int d = 0; d < 6; d++)
                {
                    for (int i = 0; i < this.Modules.Length; i++)
                    {
                        s.ModuleHealth[d][i] = this.InitialModuleHealth[d][i];
                    }
                }

                if (s.Modules.Count() != this.Modules.Count())
                {
                    foreach (var m in this.Modules)
                    {
                        s.Modules.Add(m);
                    }
                }
            }
            this.buildQueue.Clear();
            var slot = this.GetSlot(center);
            try {
            }
            catch (CollapseFailedException exception) {
                this.BuildAllSlots();
                throw new InvalidOperationException("Module " + module.Name + " creates a failure at relative position " + exception.Slot.Position + ".");
            }
            slot.Collapse(module);
            for (int direction = 0; direction < 6; direction++)
            {
                var neighbor = slot.GetNeighbor(direction);
                int unoptimizedNeighborCount = module.PossibleNeighbors[direction].Length;
                module.PossibleNeighbors[direction] = module.PossibleNeighbors[direction].Where(m => neighbor.Modules.Contains(m)).ToArray();
                count += unoptimizedNeighborCount - module.PossibleNeighbors[direction].Length;
            }
            p++;
            EditorUtility.DisplayProgressBar("Simplifying... " + count, module.Name, (float)p / this.Modules.Length);
        }
        Debug.Log("Removed " + count + " impossible neighbors.");
        EditorUtility.ClearProgressBar();
    }
Beispiel #5
0
    public void Initialize()
    {
        this.Clear();
        MapGenerator.Random   = new System.Random();
        this.Map              = new Dictionary <Vector3i, Slot>();
        this.buildQueue       = new Queue <Slot>();
        this.History          = new RingBuffer <HistoryItem>(3000);
        this.backtrackBarrier = 0;

        if (this.Modules == null || this.Modules.Length == 0)
        {
            Debug.LogWarning("Module data was not available, creating new data.");
            this.CreateModules();
        }
        this.InitialModuleHealth = this.createInitialModuleHealth(this.Modules);
        this.defaultColumn       = new DefaultColumn(this);
    }