예제 #1
0
 /// <summary>
 /// Constructs a <see cref="TagStructureInfo"/> object which contains info about a tag structure type.
 /// </summary>
 /// <param name="structureType">The tag structure type to analyze.</param>
 /// <param name="version">The engine version to compare attributes against.</param>
 public TagStructureInfo(Type structureType, DefinitionSet version)
 {
     Version = version;
     GroupTag = new Tag(-1);
     ParentGroupTag = new Tag(-1);
     GrandparentGroupTag = new Tag(-1);
     Analyze(structureType, version);
 }
 /// <summary>
 /// Creates a stringID resolver for a given engine version.
 /// </summary>
 /// <param name="version">The version.</param>
 /// <returns>The resolver.</returns>
 public static StringIDResolverBase Create(DefinitionSet version)
 {
     if (Definition.Compare(version, DefinitionSet.HaloOnline700123) >= 0)
         return new Definitions.HaloOnline700123.StringIDResolver();
     if (Definition.Compare(version, DefinitionSet.HaloOnline498295) >= 0)
         return new Definitions.HaloOnline498295.StringIDResolver();
     return new Definitions.HaloOnline106708.StringIDResolver();
 }
예제 #3
0
        private bool GetCurrentPropertyInfo()
        {
            // If the field has a TagFieldAttribute, use it, otherwise use the default
            Attribute = Field.GetCustomAttributes(typeof(TagFieldAttribute), false).FirstOrDefault() as TagFieldAttribute ?? DefaultFieldAttribute;
            if (Attribute.Offset >= Info.TotalSize)
            {
                throw new InvalidOperationException("Offset for property \"" + Field.Name + "\" is outside of its structure");
            }

            // Read version restrictions, if any
            var minVersionAttrib = Field.GetCustomAttributes(typeof(MinVersionAttribute), false).FirstOrDefault() as MinVersionAttribute;
            var maxVersionAttrib = Field.GetCustomAttributes(typeof(MaxVersionAttribute), false).FirstOrDefault() as MaxVersionAttribute;

            MinVersion = (minVersionAttrib != null) ? minVersionAttrib.Version : DefinitionSet.Unknown;
            MaxVersion = (maxVersionAttrib != null) ? maxVersionAttrib.Version : DefinitionSet.Unknown;
            return(Definition.IsBetween(Info.Version, MinVersion, MaxVersion));
        }
예제 #4
0
        }     //class DefinitionSet

        public static string[] Format(double[,] data)
        {
            StringList before, after;

            CreateTemplate(out before, out after);
            var list           = new StringList(before);
            int longIndexBound = data.GetUpperBound(1);

            for (var index = 0; index < longIndexBound; ++index)
            {
                list.Add(DefinitionSet.formatLine(index, data[0, index], data[1, index], index < longIndexBound - 1));
            }
            foreach (var line in after)
            {
                list.Add(line);
            }
            return(list.ToArray());
        } //Format
        } //LoadWav

        void CreateFft()
        {
            if (wavFileName != null)
            {
                saveDialog.FileName = Path.ChangeExtension(wavFileName, DefinitionSet.outputFileType);
            }
            if (saveDialog.ShowDialog() != true)
            {
                return;
            }
            this.result = Main.Processor.Perform(wave.LeftChannel, 2 << (int)this.sliderSize.Value, (int)this.sliderShift.Value);
            this.canvasFrequency.SetData(Main.Processor.GetAmplitude(result), System.Windows.Media.Brushes.Navy, true);
            this.canvasPhase.SetData(Main.Processor.GetPhase(result), System.Windows.Media.Brushes.DarkCyan, true);
            var fileContent = Main.Formatter.Format(result);

            System.IO.File.WriteAllLines(saveDialog.FileName, fileContent);
            this.footer.Text = DefinitionSet.formatFileNames(wavFileName, saveDialog.FileName);
        } //CreateFft
예제 #6
0
        private void Analyze(Type mainType, DefinitionSet version)
        {
            // Get the attribute for the main structure type
            Structure = GetStructureAttribute(mainType, version);
            if (Structure == null)
            {
                throw new InvalidOperationException("No TagStructure attribute which matches the target version was found on " + mainType.Name);
            }

            // Scan through the type's inheritance hierarchy and analyze each TagStructure attribute
            var currentType = mainType;

            Types = new List <Type>();
            while (currentType != null)
            {
                var attrib = (currentType != mainType) ? GetStructureAttribute(currentType, version) : Structure;
                if (attrib != null)
                {
                    Types.Add(currentType);
                    TotalSize += attrib.Size;
                    if (attrib.Class != null)
                    {
                        if (GroupTag.Value == -1)
                        {
                            GroupTag = new Tag(attrib.Class);
                        }
                        else if (ParentGroupTag.Value == -1)
                        {
                            ParentGroupTag = new Tag(attrib.Class);
                        }
                        else if (GrandparentGroupTag.Value == -1)
                        {
                            GrandparentGroupTag = new Tag(attrib.Class);
                        }
                    }
                }
                currentType = currentType.BaseType;
            }
        }
예제 #7
0
        /// <summary>
        /// Translates a tag index between two versions.
        /// </summary>
        /// <param name="version1">The version of the index to translate.</param>
        /// <param name="index1">The tag index.</param>
        /// <param name="version2">The version to get the equivalent tag index in.</param>
        /// <returns>The equivalent tag index if found, or -1 otherwise.</returns>
        public int Translate(DefinitionSet version1, int index1, DefinitionSet version2)
        {
            // Get both version maps and fail if one doesn't exist
            VersionMap map1, map2;

            if (!_versionMaps.TryGetValue(version1, out map1))
            {
                return(-1);
            }
            if (!_versionMaps.TryGetValue(version2, out map2))
            {
                return(-1);
            }

            // Get the global index from the first map, then look up that index in the second one
            var globalIndex = map1.GetGlobalTagIndex(index1);

            if (globalIndex < 0)
            {
                return(-1);
            }
            return(map2.GetVersionedTagIndex(globalIndex));
        }
예제 #8
0
        public static void Create(DefinitionSet set)
        {
            set.Beams.Add(new Block
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_LargeMissileTurret), "MA_Gimbal_Laser_Armored"),
                Components = new List <Component>
                {
                    new Emitter()
                    {
                        ColorMin       = new Vector4(.1f, 0, .1f, .1f),
                        ColorMax       = new Vector4(.3f, 0, .8f, 1f),
                        MaxPowerOutput = .5e3f,
                        CoolingPower   = .1f,
                        Efficiency     = 1f,
                        ThermalFuseMin = 1000,
                        ThermalFuseMax = 1500,
                        Dummy          = "MissileTurretBase1/laser_a1"
                    },
                    new Optics()
                    {
                        IncomingBeams = new[] { "MissileTurretBase1/laser_a1", "MissileTurretBase1/laser_a1.2" },
                        OutgoingBeams = new[]
                        {
                            new Optics.OutgoingBeam()
                            {
                                Color         = Vector4.One,
                                Dummy         = "MissileTurretBase1/MissileTurretBarrels/laser_b2",
                                MaxThroughput = float.PositiveInfinity
                            }
                        },
                        IntersectionPoint = "MissileTurretBase1/laser_b1",
                    },
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "MissileTurretBase1/MissileTurretBarrels/laser_b2",
                            "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001"
                        }
                    },
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "beam_acceptor_01",
                            "MissileTurretBase1/laser_a1.2"
                        }
                    },
                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });

            set.Beams.Add(new Block
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_LargeMissileTurret), "MA_Gimbal_Laser_Armored_Slope"),
                Components = new List <Component>
                {
                    new Emitter()
                    {
                        ColorMin       = new Vector4(.1f, 0, .1f, .1f),
                        ColorMax       = new Vector4(.3f, 0, .8f, 1f),
                        MaxPowerOutput = .5e3f,
                        CoolingPower   = .1f,
                        Efficiency     = 1f,
                        ThermalFuseMin = 1000,
                        ThermalFuseMax = 1500,
                        Dummy          = "MissileTurretBase1/laser_a1",
                    },
                    new Optics()
                    {
                        IncomingBeams = new[] { "MissileTurretBase1/laser_a1", "MissileTurretBase1/laser_a1.2" },
                        OutgoingBeams = new[]
                        {
                            new Optics.OutgoingBeam()
                            {
                                Color         = Vector4.One,
                                Dummy         = "MissileTurretBase1/MissileTurretBarrels/laser_b2",
                                MaxThroughput = float.PositiveInfinity
                            }
                        },
                        IntersectionPoint = "MissileTurretBase1/laser_b1",
                    },
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "MissileTurretBase1/MissileTurretBarrels/laser_b2",
                            "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001"
                        }
                    },
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "beam_acceptor_01",
                            "MissileTurretBase1/laser_a1.2"
                        }
                    },
                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });

            set.Beams.Add(new Block
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_LargeMissileTurret), "MA_Gimbal_Laser_Armored_Slope2"),
                Components = new List <Component>
                {
                    new Emitter()
                    {
                        ColorMin       = new Vector4(.1f, 0, .1f, .1f),
                        ColorMax       = new Vector4(.3f, 0, .8f, 1f),
                        MaxPowerOutput = .5e3f,
                        CoolingPower   = .1f,
                        Efficiency     = 1f,
                        ThermalFuseMin = 1000,
                        ThermalFuseMax = 1500,
                        Dummy          = "MissileTurretBase1/laser_a1",
                    },
                    new Optics()
                    {
                        IncomingBeams = new[] { "MissileTurretBase1/laser_a1", "MissileTurretBase1/laser_a1.2" },
                        OutgoingBeams = new[]
                        {
                            new Optics.OutgoingBeam()
                            {
                                Color         = Vector4.One,
                                Dummy         = "MissileTurretBase1/MissileTurretBarrels/laser_b2",
                                MaxThroughput = float.PositiveInfinity
                            }
                        },
                        IntersectionPoint = "MissileTurretBase1/laser_b1",
                    },
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "MissileTurretBase1/MissileTurretBarrels/laser_b2",
                            "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001"
                        }
                    },
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "beam_acceptor_01",
                            "MissileTurretBase1/laser_a1.2"
                        }
                    },
                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });

            set.Beams.Add(new Block
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_LargeMissileTurret), "MA_Gimbal_Laser_Armored_Slope45"),
                Components = new List <Component>
                {
                    new Emitter()
                    {
                        ColorMin       = new Vector4(.1f, 0, .1f, .1f),
                        ColorMax       = new Vector4(.3f, 0, .8f, 1f),
                        MaxPowerOutput = .5e3f,
                        CoolingPower   = .1f,
                        Efficiency     = 1f,
                        ThermalFuseMin = 1000,
                        ThermalFuseMax = 1500,
                        Dummy          = "MissileTurretBase1/laser_a1",
                    },
                    new Optics()
                    {
                        IncomingBeams = new[] { "MissileTurretBase1/laser_a1", "MissileTurretBase1/laser_a1.2" },
                        OutgoingBeams = new[]
                        {
                            new Optics.OutgoingBeam()
                            {
                                Color         = Vector4.One,
                                Dummy         = "MissileTurretBase1/MissileTurretBarrels/laser_b2",
                                MaxThroughput = float.PositiveInfinity
                            }
                        },
                        IntersectionPoint = "MissileTurretBase1/laser_b1",
                    },
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "MissileTurretBase1/MissileTurretBarrels/laser_b2",
                            "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001"
                        }
                    },
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "beam_acceptor_01",
                            "MissileTurretBase1/laser_a1.2"
                        }
                    },
                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });

            set.Beams.Add(new Block
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_LargeMissileTurret), "MA_Gimbal_Laser"),
                Components = new List <Component>
                {
                    new Emitter()
                    {
                        ColorMin       = new Vector4(.1f, 0, .1f, .1f),
                        ColorMax       = new Vector4(.3f, 0, .8f, 1f),
                        MaxPowerOutput = .5e3f,
                        CoolingPower   = .1f,
                        Efficiency     = 1f,
                        ThermalFuseMin = 1000,
                        ThermalFuseMax = 1500,
                        Dummy          = "MissileTurretBase1/laser_a1",
                    },
                    new Optics()
                    {
                        IncomingBeams = new[] { "MissileTurretBase1/laser_a1", "MissileTurretBase1/laser_a1.2" },
                        OutgoingBeams = new[]
                        {
                            new Optics.OutgoingBeam()
                            {
                                Color         = Vector4.One,
                                Dummy         = "MissileTurretBase1/MissileTurretBarrels/laser_b2",
                                MaxThroughput = float.PositiveInfinity
                            }
                        },
                        IntersectionPoint = "MissileTurretBase1/laser_b1",
                    },
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "MissileTurretBase1/MissileTurretBarrels/laser_b2",
                            "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001"
                        }
                    },
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "beam_acceptor_01",
                            "MissileTurretBase1/laser_a1.2"
                        }
                    },
                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });

            set.Beams.Add(new Block
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_LargeMissileTurret), "MA_Gimbal_Laser_Armored_sb"),
                Components = new List <Component>
                {
                    new Emitter()
                    {
                        ColorMin       = new Vector4(.1f, 0, .1f, .1f),
                        ColorMax       = new Vector4(.3f, 0, .8f, 1f),
                        MaxPowerOutput = .1e3f,
                        CoolingPower   = .1f,
                        Efficiency     = 1f,
                        ThermalFuseMin = 1000,
                        ThermalFuseMax = 1500,
                        Dummy          = "MissileTurretBase1/laser_a1",
                    },
                    new Optics()
                    {
                        IncomingBeams = new[] { "MissileTurretBase1/laser_a1", "beam_acceptor_01" },
                        OutgoingBeams = new[]
                        {
                            new Optics.OutgoingBeam()
                            {
                                Color         = Vector4.One,
                                Dummy         = "MissileTurretBase1/MissileTurretBarrels/laser_b2",
                                MaxThroughput = float.PositiveInfinity
                            }
                        },
                        IntersectionPoint = "MissileTurretBase1/laser_b1",
                    },
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "MissileTurretBase1/MissileTurretBarrels/laser_b2",
                            "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001"
                        }
                    },
                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });

            set.Beams.Add(new Block
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_LargeMissileTurret), "MA_Gimbal_Laser_Armored_Slope_sb"),
                Components = new List <Component>
                {
                    new Emitter()
                    {
                        ColorMin       = new Vector4(.1f, 0, .1f, .1f),
                        ColorMax       = new Vector4(.3f, 0, .8f, 1f),
                        MaxPowerOutput = .1e3f,
                        CoolingPower   = .1f,
                        Efficiency     = 1f,
                        ThermalFuseMin = 1000,
                        ThermalFuseMax = 1500,
                        Dummy          = "MissileTurretBase1/laser_a1",
                    },
                    new Optics()
                    {
                        IncomingBeams = new[] { "MissileTurretBase1/laser_a1", "beam_acceptor_01" },
                        OutgoingBeams = new[]
                        {
                            new Optics.OutgoingBeam()
                            {
                                Color         = Vector4.One,
                                Dummy         = "MissileTurretBase1/MissileTurretBarrels/laser_b2",
                                MaxThroughput = float.PositiveInfinity
                            }
                        },
                        IntersectionPoint = "MissileTurretBase1/laser_b1",
                    },
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "MissileTurretBase1/MissileTurretBarrels/laser_b2",
                            "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001"
                        }
                    },
                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });

            set.Beams.Add(new Block
            {
                Id = new MyDefinitionId(typeof(MyObjectBuilder_LargeMissileTurret),
                                        "MA_Gimbal_Laser_Armored_Slope2_sb"),
                Components = new List <Component>
                {
                    new Emitter()
                    {
                        ColorMin       = new Vector4(.1f, 0, .1f, .1f),
                        ColorMax       = new Vector4(.3f, 0, .8f, 1f),
                        MaxPowerOutput = .1e3f,
                        CoolingPower   = .1f,
                        Efficiency     = 1f,
                        ThermalFuseMin = 1000,
                        ThermalFuseMax = 1500,
                        Dummy          = "MissileTurretBase1/laser_a1",
                    },
                    new Optics()
                    {
                        IncomingBeams = new[] { "MissileTurretBase1/laser_a1", "beam_acceptor_01" },
                        OutgoingBeams = new[]
                        {
                            new Optics.OutgoingBeam()
                            {
                                Color         = Vector4.One,
                                Dummy         = "MissileTurretBase1/MissileTurretBarrels/laser_b2",
                                MaxThroughput = float.PositiveInfinity
                            }
                        },
                        IntersectionPoint = "MissileTurretBase1/laser_b1",
                    },
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "MissileTurretBase1/MissileTurretBarrels/laser_b2",
                            "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001"
                        }
                    },
                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });

            set.Beams.Add(new Block
            {
                Id = new MyDefinitionId(typeof(MyObjectBuilder_LargeMissileTurret),
                                        "MA_Gimbal_Laser_Armored_Slope45_sb"),
                Components = new List <Component>
                {
                    new Emitter()
                    {
                        ColorMin       = new Vector4(.1f, 0, .1f, .1f),
                        ColorMax       = new Vector4(.3f, 0, .8f, 1f),
                        MaxPowerOutput = .1e3f,
                        CoolingPower   = .1f,
                        Efficiency     = 1f,
                        ThermalFuseMin = 1000,
                        ThermalFuseMax = 1500,
                        Dummy          = "MissileTurretBase1/laser_a1",
                    },
                    new Optics()
                    {
                        IncomingBeams = new[] { "MissileTurretBase1/laser_a1", "beam_acceptor_01" },
                        OutgoingBeams = new[]
                        {
                            new Optics.OutgoingBeam()
                            {
                                Color         = Vector4.One,
                                Dummy         = "MissileTurretBase1/MissileTurretBarrels/laser_b2",
                                MaxThroughput = float.PositiveInfinity
                            }
                        },
                        IntersectionPoint = "MissileTurretBase1/laser_b1",
                    },
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "MissileTurretBase1/MissileTurretBarrels/laser_b2",
                            "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001"
                        }
                    },
                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });

            set.Beams.Add(new Block
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_LargeMissileTurret), "MA_Gimbal_Laser_sb"),
                Components = new List <Component>
                {
                    new Emitter()
                    {
                        ColorMin       = new Vector4(.1f, 0, .1f, .1f),
                        ColorMax       = new Vector4(.3f, 0, .8f, 1f),
                        MaxPowerOutput = .1e3f,
                        CoolingPower   = .1f,
                        Efficiency     = 1f,
                        ThermalFuseMin = 1000,
                        ThermalFuseMax = 1500,
                        Dummy          = "MissileTurretBase1/laser_a1",
                    },
                    new Optics()
                    {
                        IncomingBeams = new[] { "MissileTurretBase1/laser_a1", "beam_acceptor_01" },
                        OutgoingBeams = new[]
                        {
                            new Optics.OutgoingBeam()
                            {
                                Color         = Vector4.One,
                                Dummy         = "MissileTurretBase1/MissileTurretBarrels/laser_b2",
                                MaxThroughput = float.PositiveInfinity
                            }
                        },
                        IntersectionPoint = "MissileTurretBase1/laser_b1",
                    },
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "MissileTurretBase1/MissileTurretBarrels/laser_b2",
                            "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001"
                        }
                    },
                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });


            set.Beams.Add(new Block()
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_Passage), "MA_BN_Tube90_Large"),
                Components = new List <Component>()
                {
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "beam_acceptor_08", "beam_dumdum_90", "beam_acceptor_09"
                        }
                    }
                }
            });

            set.Beams.Add(new Block()
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_Passage), "MA_BN_Combiner_Large"),
                Components = new List <Component>()
                {
                    new Optics()
                    {
                        IncomingBeams     = new[] { "laser_h3", "laser_i3", "beam_acceptor_06" },
                        IntersectionPoint = "beam_emitter_02",
                        OutgoingBeams     = new[]
                        {
                            new Optics.OutgoingBeam()
                            {
                                Dummy = "beam_emitter_02",
                                Color = new Vector4(1, 1, 1, 1)
                            }
                        }
                    },
                    new Path()
                    {
                        Dummies = new[] { "beam_acceptor_05", "laser_h1", "laser_h2", "laser_h3" }
                    },
                    new Path()
                    {
                        Dummies = new[] { "beam_acceptor_07", "laser_i1", "laser_i2", "laser_i3" }
                    }
                }
            });


            set.Beams.Add(new Block()
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_Passage), "MA_BN_Splitter_Large"),
                Components = new List <Component>()
                {
                    new Optics()
                    {
                        IncomingBeams     = new[] { "beam_acceptor_10" },
                        IntersectionPoint = "beam_splitter_01",
                        OutgoingBeams     = new[]
                        {
                            new Optics.OutgoingBeam()
                            {
                                Dummy = "beam_emitter_03",
                                Color = new Vector4(1, 1, 1, 1)
                            },
                            new Optics.OutgoingBeam()
                            {
                                Dummy = "beam_emitter_04",
                                Color = new Vector4(1, 1, 1, 1)
                            },
                            new Optics.OutgoingBeam()
                            {
                                Dummy = "beam_emitter_05",
                                Color = new Vector4(1, 1, 1, 1)
                            }
                        }
                    },
                }
            });


            set.Beams.Add(new Block()
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_UpgradeModule), "MA_BN_T1PSU_Large"),
                Components = new List <Component>()
                {
                    new Emitter()
                    {
                        ColorMin         = new Vector4(1, 0, 0, 0.25f),
                        ColorMax         = new Vector4(1, 0, 0, 1),
                        CoolingPower     = 1f,
                        MaxPowerOutput   = 5e3f / 4,
                        AutomaticTurnOff = true,
                        Efficiency       = 1f,
                        Dummy            = "laser_a1"
                    },
                    new Path()
                    {
                        Dummies = new[] { "laser_a1", "laser_a2", "laser_c1", "laser_c2" }
                    },
                    new Emitter()
                    {
                        ColorMin         = new Vector4(1, 0, 0, 0.25f),
                        ColorMax         = new Vector4(1, 0, 0, 1),
                        CoolingPower     = 1f,
                        MaxPowerOutput   = 5e3f / 4,
                        AutomaticTurnOff = true,
                        Efficiency       = 1f,
                        Dummy            = "laser_b1"
                    },
                    new Path()
                    {
                        Dummies = new[] { "laser_b1", "laser_b2", "laser_d1", "laser_d2" }
                    },
                    new Emitter()
                    {
                        ColorMin         = new Vector4(1, 0, 0, 0.25f),
                        ColorMax         = new Vector4(1, 0, 0, 1),
                        CoolingPower     = 1f,
                        MaxPowerOutput   = 5e3f / 4,
                        AutomaticTurnOff = true,
                        Efficiency       = 1f,
                        Dummy            = "laser_b4"
                    },
                    new Path()
                    {
                        Dummies = new[] { "laser_b4", "laser_b3", "laser_f1", "laser_f2" }
                    },
                    new Emitter()
                    {
                        ColorMin         = new Vector4(1, 0, 0, 0.25f),
                        ColorMax         = new Vector4(1, 0, 0, 1),
                        CoolingPower     = 1f,
                        MaxPowerOutput   = 5e3f / 4,
                        AutomaticTurnOff = true,
                        Efficiency       = 1f,
                        Dummy            = "laser_a4"
                    },
                    new Path()
                    {
                        Dummies = new[] { "laser_a4", "laser_a3", "laser_e1", "laser_e2" }
                    },
                    new Optics()
                    {
                        IncomingBeams = new[] { "laser_c2", "laser_d2", "laser_f2", "laser_e2" },
                        OutgoingBeams = new[]
                        {
                            new Optics.OutgoingBeam()
                            {
                                Dummy         = "beam_emitter_01",
                                Color         = Vector4.One,
                                MaxThroughput = float.PositiveInfinity
                            }
                        },
                        IntersectionPoint = "laser_g1"
                    }
                }
            });

            set.Beams.Add(new Block()
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_Passage), "MA_BN_Tube0_Large"),
                Components = new List <Component>()
                {
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "beam_acceptor_01", "beam_acceptor_02"
                        }
                    }
                }
            });

            set.Beams.Add(new Block()
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_Passage), "MA_BN_Tubex3_Large"),
                Components = new List <Component>()
                {
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "beam_acceptor_03", "beam_acceptor_04"
                        }
                    }
                }
            });


            set.Beams.Add(new Block()
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_UpgradeModule), "MA_BN_T2PSU_Large"),
                Components = new List <Component>()
                {
                    new Emitter()
                    {
                        ColorMin         = new Vector4(1, 0, 0, 0.25f),
                        ColorMax         = new Vector4(1, .3f, 0, 1),
                        CoolingPower     = 1f,
                        MaxPowerOutput   = 15e3f,
                        AutomaticTurnOff = true,
                        Efficiency       = 1f,
                        Dummy            = "beam_emitter_T2"
                    },
                }
            });


            set.Beams.Add(new Block
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_SmallMissileLauncher), "MA_Fixed_000"),
                Components = new List <Component>
                {
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "beam_acceptor_01",
                            "muzzle_missile_001"
                        }
                    },

                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });

            set.Beams.Add(new Block
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_SmallMissileLauncher), "MA_Fixed_001"),
                Components = new List <Component>
                {
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "beam_acceptor_01",
                            "muzzle_missile_001"
                        }
                    },

                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });

            set.Beams.Add(new Block
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_SmallMissileLauncher), "MA_Fixed_002"),
                Components = new List <Component>
                {
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "beam_acceptor_01",
                            "muzzle_missile_001"
                        }
                    },

                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });

            set.Beams.Add(new Block
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_SmallMissileLauncher), "MA_Fixed_003"),
                Components = new List <Component>
                {
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "beam_acceptor_01",
                            "muzzle_missile_001"
                        }
                    },

                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });

            set.Beams.Add(new Block
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_SmallMissileLauncher), "MA_Fixed_004"),
                Components = new List <Component>
                {
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "beam_acceptor_01",
                            "muzzle_missile_001"
                        }
                    },

                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });

            set.Beams.Add(new Block
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_SmallMissileLauncher), "MA_Fixed_005"),
                Components = new List <Component>
                {
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "beam_acceptor_01",
                            "muzzle_missile_001"
                        }
                    },

                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });

            set.Beams.Add(new Block
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_SmallMissileLauncher), "MA_Fixed_sb_000"),
                Components = new List <Component>
                {
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "beam_acceptor_01",
                            "muzzle_missile_001"
                        }
                    },

                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });

            set.Beams.Add(new Block
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_SmallMissileLauncher), "MA_Fixed_sb_001"),
                Components = new List <Component>
                {
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "beam_acceptor_01",
                            "muzzle_missile_001"
                        }
                    },

                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });

            set.Beams.Add(new Block
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_SmallMissileLauncher), "MA_Fixed_sb_002"),
                Components = new List <Component>
                {
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "beam_acceptor_01",
                            "muzzle_missile_001"
                        }
                    },

                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });

            set.Beams.Add(new Block
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_SmallMissileLauncher), "MA_Fixed_sb_003"),
                Components = new List <Component>
                {
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "beam_acceptor_01",
                            "muzzle_missile_001"
                        }
                    },

                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });

            set.Beams.Add(new Block
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_SmallMissileLauncher), "MA_Fixed_sb_004"),
                Components = new List <Component>
                {
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "beam_acceptor_01",
                            "muzzle_missile_001"
                        }
                    },

                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });

            set.Beams.Add(new Block
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_SmallMissileLauncher), "MA_Fixed_sb_005"),
                Components = new List <Component>
                {
                    new Path()
                    {
                        Dummies = new[]
                        {
                            "beam_acceptor_01",
                            "muzzle_missile_001"
                        }
                    },

                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });


            set.Beams.Add(new Block
            {
                Id         = new MyDefinitionId(typeof(MyObjectBuilder_LargeMissileTurret), "MA_PDX"),
                Components = new List <Component>
                {
                    new Emitter()
                    {
                        ColorMin       = new Vector4(.1f, 0, .1f, .1f),
                        ColorMax       = new Vector4(.3f, 0, .8f, 1f),
                        MaxPowerOutput = .5e3f,
                        CoolingPower   = .1f,
                        Efficiency     = 1f,
                        ThermalFuseMin = 1000,
                        ThermalFuseMax = 1500,
                        Dummy          = "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001",
                    },

                    new Weapon()
                    {
                        MaxLazeDistance        = 1e4f,
                        CoolingPower           = .1f,
                        Efficiency             = 1f,
                        WeaponDamageMultiplier = 100f,
                        FxImpactName           = "WelderContactPoint",
                        FxImpactBirthRate      = 2,
                        FxImpactScale          = 3f,
                        FxImpactMaxCount       = 25,
                        Dummy = "MissileTurretBase1/MissileTurretBarrels/muzzle_missile_001",
                        VoxelDamageMultiplier = 0
                    }
                }
            });
        }
예제 #9
0
        private static TagStructureAttribute GetStructureAttribute(Type type, DefinitionSet version)
        {
            // First match against any TagStructureAttributes that have version restrictions
            var attrib = type.GetCustomAttributes(typeof(TagStructureAttribute), false)
                .Cast<TagStructureAttribute>()
                .Where(a => a.MinVersion != DefinitionSet.Unknown || a.MaxVersion != DefinitionSet.Unknown)
                .FirstOrDefault(a => Definition.IsBetween(version, a.MinVersion, a.MaxVersion));

            // If nothing was found, find the first attribute without any version restrictions
            return attrib ?? type.GetCustomAttributes(typeof(TagStructureAttribute), false)
                .Cast<TagStructureAttribute>()
                .FirstOrDefault(a => a.MinVersion == DefinitionSet.Unknown && a.MaxVersion == DefinitionSet.Unknown);
        }
예제 #10
0
        private void Analyze(Type mainType, DefinitionSet version)
        {
            // Get the attribute for the main structure type
            Structure = GetStructureAttribute(mainType, version);
            if (Structure == null)
                throw new InvalidOperationException("No TagStructure attribute which matches the target version was found on " + mainType.Name);

            // Scan through the type's inheritance hierarchy and analyze each TagStructure attribute
            var currentType = mainType;
            Types = new List<Type>();
            while (currentType != null)
            {
                var attrib = (currentType != mainType) ? GetStructureAttribute(currentType, version) : Structure;
                if (attrib != null)
                {
                    Types.Add(currentType);
                    TotalSize += attrib.Size;
                    if (attrib.Class != null)
                    {
                        if (GroupTag.Value == -1)
                            GroupTag = new Tag(attrib.Class);
                        else if (ParentGroupTag.Value == -1)
                            ParentGroupTag = new Tag(attrib.Class);
                        else if (GrandparentGroupTag.Value == -1)
                            GrandparentGroupTag = new Tag(attrib.Class);
                    }
                }
                currentType = currentType.BaseType;
            }
        }
예제 #11
0
 /// <summary>
 /// Compares two version numbers.
 /// </summary>
 /// <param name="lhs">The left-hand version number.</param>
 /// <param name="rhs">The right-hand version number.</param>
 /// <returns>A positive value if the left version is newer, a negative value if the right version is newer, and 0 if the versions are equivalent.</returns>
 public static int Compare(DefinitionSet lhs, DefinitionSet rhs)
 {
     // Assume the enum values are in order by release date
     return (int)lhs - (int)rhs;
 }
예제 #12
0
        /// <summary>
        /// Connects a tag index to a tag in another version.
        /// </summary>
        /// <param name="version1">The first version.</param>
        /// <param name="index1">The tag index in the first version.</param>
        /// <param name="version2">The second version.</param>
        /// <param name="index2">The tag index in the second version.</param>
        public void Add(DefinitionSet version1, int index1, DefinitionSet version2, int index2)
        {
            // Get both version maps, creating them if they don't exist
            VersionMap map1, map2;
            if (!_versionMaps.TryGetValue(version1, out map1))
            {
                map1 = new VersionMap();
                _versionMaps[version1] = map1;
            }
            if (!_versionMaps.TryGetValue(version2, out map2))
            {
                map2 = new VersionMap();
                _versionMaps[version2] = map2;
            }

            // Check if the first index is in the map for the first version.
            // If it is, then we'll get a "global index" which can be used to look it up in other versions.
            // If it isn't, then we need to make a new global index for it.
            var globalIndex = map1.GetGlobalTagIndex(index1);
            if (globalIndex < 0)
            {
                globalIndex = _nextGlobalTagIndex;
                _nextGlobalTagIndex++;
                map1.Add(globalIndex, index1);
            }

            // Connect the global index to the second index in the second version
            map2.Add(globalIndex, index2);
        }
예제 #13
0
        private bool GetCurrentPropertyInfo()
        {
            // If the field has a TagFieldAttribute, use it, otherwise use the default
            Attribute = Field.GetCustomAttributes(typeof(TagFieldAttribute), false).FirstOrDefault() as TagFieldAttribute ?? DefaultFieldAttribute;
            if (Attribute.Offset >= Info.TotalSize)
                throw new InvalidOperationException("Offset for property \"" + Field.Name + "\" is outside of its structure");

            // Read version restrictions, if any
            var minVersionAttrib = Field.GetCustomAttributes(typeof(MinVersionAttribute), false).FirstOrDefault() as MinVersionAttribute;
            var maxVersionAttrib = Field.GetCustomAttributes(typeof(MaxVersionAttribute), false).FirstOrDefault() as MaxVersionAttribute;
            MinVersion = (minVersionAttrib != null) ? minVersionAttrib.Version : DefinitionSet.Unknown;
            MaxVersion = (maxVersionAttrib != null) ? maxVersionAttrib.Version : DefinitionSet.Unknown;
            return Definition.IsBetween(Info.Version, MinVersion, MaxVersion);
        }
예제 #14
0
 /// <summary>
 /// Apply a set of table definitions. These may have been constructed automatically or loaded by the <see cref="SnapshotDefinitionLoader"/>.
 /// Note that settings from the new definitions will override settings already present on the collection. The order sets are applied matters.
 /// </summary>
 /// <param name="definitionSet">The definition set to apply</param>
 public void ApplyDefinitions(DefinitionSet definitionSet)
 {
     LoadTableDefinitionSet(definitionSet);
 }
예제 #15
0
 /// <summary>
 /// Gets the timestamp for a version.
 /// </summary>
 /// <param name="version">The version.</param>
 /// <returns>The timestamp, or -1 for <see cref="DefinitionSet.Unknown"/>.</returns>
 public static long GetTimestamp(DefinitionSet version)
 {
     if (version == DefinitionSet.Unknown)
         return -1;
     return VersionTimestamps[(int)version];
 }
            public void OverrideBy(DefinitionSet definitionSet)
            {
                for (int i = 0; i < definitionSet.m_cubeSizes.Length; i++)
                {
                    var cubeSize = definitionSet.m_cubeSizes[i];
                    if (cubeSize != 0)
                    {
                        m_cubeSizes[i] = cubeSize;
                    }
                }

                for (int i = 0; i < definitionSet.m_basePrefabNames.Length; i++)
                {
                    if (!string.IsNullOrEmpty(definitionSet.m_basePrefabNames[i]))
                    {
                        m_basePrefabNames[i] = definitionSet.m_basePrefabNames[i];
                    }
                }

                foreach (var definition in definitionSet.m_definitionsById)
                {
                    if (definition.Value.Enabled)
                    {
                        m_definitionsById[definition.Key] = definition.Value;
                    }
                    else
                    {
                        m_definitionsById.Remove(definition.Key);
                    }
                }

                foreach (var voxelMaterial in definitionSet.m_voxelMaterialsByName)
                {
                    m_voxelMaterialsByName[voxelMaterial.Key] = voxelMaterial.Value;
                }

                MergeDefinitionLists(m_physicalItemDefinitions, definitionSet.m_physicalItemDefinitions);

                foreach (var blockPosition in definitionSet.m_blockPositions)
                {
                    m_blockPositions[blockPosition.Key] = blockPosition.Value;
                }

                for (int i = 0; i < definitionSet.m_uniqueCubeBlocksBySize.Length; i++)
                {
                    var uniqueCubeBlocksBySize = definitionSet.m_uniqueCubeBlocksBySize[i];
                    foreach (var uniqueCubeBlocks in uniqueCubeBlocksBySize)
                    {
                        m_uniqueCubeBlocksBySize[i][uniqueCubeBlocks.Key] = uniqueCubeBlocks.Value;
                    }
                }

                foreach (var blueprintsById in definitionSet.m_blueprintsById)
                {
                    if (blueprintsById.Value.Enabled)
                    {
                        m_blueprintsById[blueprintsById.Key] = blueprintsById.Value;
                    }
                    else
                    {
                        m_blueprintsById.Remove(blueprintsById.Key);
                    }
                }

                MergeDefinitionLists(m_spawnGroupDefinitions, definitionSet.m_spawnGroupDefinitions);

                foreach (var containerTypeDefinition in definitionSet.m_containerTypeDefinitions)
                {
                    if (containerTypeDefinition.Value.Enabled)
                    {
                        m_containerTypeDefinitions[containerTypeDefinition.Key] = containerTypeDefinition.Value;
                    }
                    else
                    {
                        m_containerTypeDefinitions.Remove(containerTypeDefinition.Key);
                    }
                }

                foreach (var handItem in definitionSet.m_handItemsById)
                {
                    if (handItem.Value.Enabled)
                    {
                        m_handItemsById[handItem.Key] = handItem.Value;
                    }
                    else
                    {
                        m_handItemsById.Remove(handItem.Key);
                    }
                }

                MergeDefinitionLists(m_scenarioDefinitions, definitionSet.m_scenarioDefinitions);

                foreach (var character in definitionSet.m_characters)
                {
                    if (character.Value.Enabled)
                    {
                        m_characters[character.Key] = character.Value;
                    }
                    else
                    {
                        m_characters.Remove(character.Key);
                    }
                }

                foreach (var classDef in definitionSet.m_blueprintClasses)
                {
                    if (classDef.Value.Enabled)
                    {
                        m_blueprintClasses[classDef.Key] = classDef.Value;
                    }
                    else
                    {
                        m_blueprintClasses.Remove(classDef.Key);
                    }
                }

                foreach (var classEntry in definitionSet.m_categoryClasses)
                {
                    m_categoryClasses.Add(classEntry);

                    string categoryName = classEntry.Name;

                    MyGuiBlockCategoryDefinition categoryDefinition = null;
                    if (false == m_categories.TryGetValue(categoryName, out categoryDefinition))
                    {
                        m_categories.Add(categoryName, classEntry);
                    }
                    else
                    {
                        categoryDefinition.ItemIds.AddRange(classEntry.ItemIds);
                    }
                }

                foreach (var classEntry in definitionSet.m_blueprintClassEntries)
                {
                    if (m_blueprintClassEntries.Contains(classEntry))
                    {
                        if (classEntry.Enabled == false)
                        {
                            m_blueprintClassEntries.Remove(classEntry);
                        }
                    }
                    else
                    {
                        if (classEntry.Enabled == true)
                        {
                            m_blueprintClassEntries.Add(classEntry);
                        }
                    }
                }

                foreach (var entry in definitionSet.m_blueprintsByResultId)
                {
                    if (entry.Value.Enabled)
                    {
                        m_blueprintsByResultId[entry.Key] = entry.Value;
                    }
                    else
                    {
                        m_blueprintsByResultId.Remove(entry.Key);
                    }
                }

                foreach (var classEntry in definitionSet.m_environmentItemsEntries)
                {
                    if (m_environmentItemsEntries.Contains(classEntry))
                    {
                        if (classEntry.Enabled == false)
                        {
                            m_environmentItemsEntries.Remove(classEntry);
                        }
                    }
                    else
                    {
                        if (classEntry.Enabled == true)
                        {
                            m_environmentItemsEntries.Add(classEntry);
                        }
                    }
                }

                foreach (var prefab in definitionSet.m_prefabs)
                {
                    if (prefab.Value.Enabled)
                    {
                        m_prefabs[prefab.Key] = prefab.Value;
                    }
                    else
                    {
                        m_prefabs.Remove(prefab.Key);
                    }
                }

                foreach (var respawnShip in definitionSet.m_respawnShips)
                {
                    if (respawnShip.Value.Enabled)
                    {
                        m_respawnShips[respawnShip.Key] = respawnShip.Value;
                    }
                    else
                    {
                        m_respawnShips.Remove(respawnShip.Key);
                    }
                }

                if (definitionSet.m_environmentDef != null)
                {
                    if (definitionSet.m_environmentDef.Enabled)
                    {
                        m_environmentDef.Merge(definitionSet.m_environmentDef);
                    }
                }

                foreach (var animationSet in definitionSet.m_animationsBySkeletonType)
                {
                    foreach (var animation in animationSet.Value)
                    {
                        if (animation.Value.Enabled)
                        {
                            if (!m_animationsBySkeletonType.ContainsKey(animationSet.Key))
                            {
                                m_animationsBySkeletonType[animationSet.Key] = new Dictionary <string, MyAnimationDefinition>();
                            }

                            m_animationsBySkeletonType[animationSet.Key][animation.Value.Id.SubtypeName] = animation.Value;
                        }
                        else
                        {
                            m_animationsBySkeletonType[animationSet.Key].Remove(animation.Value.Id.SubtypeName);
                        }
                    }
                }

                foreach (var soundDef in definitionSet.m_sounds)
                {
                    // Enabled attribute is handled differently with sounds to prevent confusion between removed sound and missing sound
                    m_sounds[soundDef.Key] = soundDef.Value;
                }

                foreach (var weaponDef in definitionSet.m_weaponDefinitionsById)
                {
                    if (weaponDef.Value.Enabled)
                    {
                        m_weaponDefinitionsById[weaponDef.Key] = weaponDef.Value;
                    }
                    else
                    {
                        m_weaponDefinitionsById.Remove(weaponDef.Key);
                    }
                }

                foreach (var ammoDef in definitionSet.m_ammoDefinitionsById)
                {
                    if (ammoDef.Value.Enabled)
                    {
                        m_ammoDefinitionsById[ammoDef.Key] = ammoDef.Value;
                    }
                    else
                    {
                        m_ammoDefinitionsById.Remove(ammoDef.Key);
                    }
                }

                foreach (var behaviorDef in definitionSet.m_behaviorDefinitions)
                {
                    m_behaviorDefinitions[behaviorDef.Key] = behaviorDef.Value;
                }

                foreach (var voxelMapStorageDef in definitionSet.m_voxelMapStorages)
                {
                    m_voxelMapStorages[voxelMapStorageDef.Key] = voxelMapStorageDef.Value;
                }

                foreach (var nameEntry in definitionSet.m_characterNames)
                {
                    m_characterNames.Add(nameEntry);
                }
            }
예제 #17
0
 internal InvalidInterfaceException(System.Type invalidInterface, MethodInfo badMethod, ParameterInfo badParameter) :
     base(DefinitionSet.FormatBadInterfaceParameter(invalidInterface, badMethod, badParameter))
 {
 }
예제 #18
0
 /// <summary>
 /// Gets the version string corresponding to an <see cref="DefinitionSet"/> value.
 /// </summary>
 /// <param name="version">The version.</param>
 /// <returns>The version string.</returns>
 public static string GetVersionString(DefinitionSet version)
 {
     switch (version)
     {
         case DefinitionSet.HaloOnline106708:
             return "1.106708 cert_ms23";
         case DefinitionSet.HaloOnline235640:
             return "1.235640 cert_ms23";
         case DefinitionSet.HaloOnline301003:
             return "0.0.1.301003 cert_MS26_new";
         case DefinitionSet.HaloOnline327043:
             return "0.4.1.327043 cert_MS26_new";
         case DefinitionSet.HaloOnline372731:
             return "8.1.372731 Live";
         case DefinitionSet.HaloOnline416097:
             return "0.0.416097 Live";
         case DefinitionSet.HaloOnline430475:
             return "10.1.430475 Live";
         case DefinitionSet.HaloOnline454665:
             return "10.1.454665 Live";
         case DefinitionSet.HaloOnline449175:
             return "10.1.449175 Live";
         case DefinitionSet.HaloOnline498295:
             return "11.1.498295 Live";
         case DefinitionSet.HaloOnline530605:
             return "11.1.530605 Live";
         case DefinitionSet.HaloOnline532911:
             return "11.1.532911 Live";
         case DefinitionSet.HaloOnline554482:
             return "11.1.554482 Live";
         case DefinitionSet.HaloOnline571627:
             return "11.1.571627 Live";
         case DefinitionSet.HaloOnline700123:
             return "12.1.700123 cert_ms30_oct19";
         default:
             return version.ToString();
     }
 }
예제 #19
0
 internal InvalidInterfaceException(System.Type invalidInterface) :
     base(DefinitionSet.FormatNotInterface(invalidInterface))
 {
 }
예제 #20
0
        /// <summary>
        /// Detects the engine that a tags.dat was built for based on its timestamp.
        /// </summary>
        /// <param name="timestamp">The timestamp.</param>
        /// <param name="closestGuess">On return, the closest guess for the engine's version.</param>
        /// <returns>The engine version if the timestamp matched directly, otherwise <see cref="DefinitionSet.Unknown"/>.</returns>
        public static DefinitionSet DetectFromTimestamp(long timestamp, out DefinitionSet closestGuess)
        {
            var index = Array.BinarySearch(VersionTimestamps, timestamp);
            if (index >= 0)
            {
                // Version matches a timestamp directly
                closestGuess = (DefinitionSet)(index + 1 + (int)DefinitionSet.HaloODST);
                return closestGuess;
            }

            // Match the closest timestamp
            index = Math.Max(0, Math.Min(~index - 1, VersionTimestamps.Length - 1));
            closestGuess = (DefinitionSet)(index + 1 + (int)DefinitionSet.HaloODST);
            return DefinitionSet.Unknown;
        }
예제 #21
0
 /// <summary>
 /// Detects the engine that a tags.dat was built for.
 /// </summary>
 /// <param name="cache">The cache file.</param>
 /// <param name="closestGuess">On return, the closest guess for the engine's version.</param>
 /// <returns>The engine version if it is known for sure, otherwise <see cref="DefinitionSet.Unknown"/>.</returns>
 public static DefinitionSet Detect(TagCache cache, out DefinitionSet closestGuess)
 {
     return DetectFromTimestamp(cache.Timestamp, out closestGuess);
 }
예제 #22
0
        private static void CompareBlocks(object leftData, DefinitionSet leftVersion, object rightData, DefinitionSet rightVersion, TagVersionMap result, Queue <QueuedTag> tagQueue)
        {
            if (leftData == null || rightData == null)
            {
                return;
            }
            var type = leftData.GetType();

            if (type == typeof(TagInstance))
            {
                // If the objects are tags, then we've found a match
                var leftTag  = (TagInstance)leftData;
                var rightTag = (TagInstance)rightData;
                if (leftTag.Group.Tag != rightTag.Group.Tag)
                {
                    return;
                }
                if (leftTag.IsInGroup("rmt2") || leftTag.IsInGroup("rmdf") || leftTag.IsInGroup("vtsh") || leftTag.IsInGroup("pixl") || leftTag.IsInGroup("rm  ") || leftTag.IsInGroup("bitm"))
                {
                    return;
                }
                var translated = result.Translate(leftVersion, leftTag.Index, rightVersion);
                if (translated >= 0)
                {
                    return;
                }
                result.Add(leftVersion, leftTag.Index, rightVersion, rightTag.Index);
                tagQueue.Enqueue(new QueuedTag {
                    Tag = rightTag
                });
            }
            else if (type.IsArray)
            {
                if (type.GetElementType().IsPrimitive)
                {
                    return;
                }

                // If the objects are arrays, then loop through each element
                var leftArray  = (Array)leftData;
                var rightArray = (Array)rightData;
                if (leftArray.Length != rightArray.Length)
                {
                    return; // If the sizes are different, we probably can't compare them
                }
                for (var i = 0; i < leftArray.Length; i++)
                {
                    CompareBlocks(leftArray.GetValue(i), leftVersion, rightArray.GetValue(i), rightVersion, result, tagQueue);
                }
            }
            else if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List <>))
            {
                if (type.GenericTypeArguments[0].IsPrimitive)
                {
                    return;
                }

                // If the objects are lists, then loop through each element
                var countProperty = type.GetProperty("Count");
                var leftCount     = (int)countProperty.GetValue(leftData);
                var rightCount    = (int)countProperty.GetValue(rightData);
                if (leftCount != rightCount)
                {
                    return; // If the sizes are different, we probably can't compare them
                }
                var getItem = type.GetMethod("get_Item");
                for (var i = 0; i < leftCount; i++)
                {
                    var leftItem  = getItem.Invoke(leftData, new object[] { i });
                    var rightItem = getItem.Invoke(rightData, new object[] { i });
                    CompareBlocks(leftItem, leftVersion, rightItem, rightVersion, result, tagQueue);
                }
            }
            else if (type.GetCustomAttributes(typeof(TagStructureAttribute), false).Length > 0)
            {
                // The objects are structures
                var left  = new TagFieldEnumerator(new TagStructureInfo(leftData.GetType(), leftVersion));
                var right = new TagFieldEnumerator(new TagStructureInfo(rightData.GetType(), rightVersion));
                while (left.Next() && right.Next())
                {
                    // Keep going on the left until the field is on the right
                    while (!Definition.IsBetween(rightVersion, left.MinVersion, left.MaxVersion))
                    {
                        if (!left.Next())
                        {
                            return;
                        }
                    }

                    // Keep going on the right until the field is on the left
                    while (!Definition.IsBetween(leftVersion, right.MinVersion, right.MaxVersion))
                    {
                        if (!right.Next())
                        {
                            return;
                        }
                    }
                    if (left.Field.MetadataToken != right.Field.MetadataToken)
                    {
                        throw new InvalidOperationException("WTF, left and right fields don't match!");
                    }

                    // Process the fields
                    var leftFieldData  = left.Field.GetValue(leftData);
                    var rightFieldData = right.Field.GetValue(rightData);
                    CompareBlocks(leftFieldData, leftVersion, rightFieldData, rightVersion, result, tagQueue);
                }
            }
        }
예제 #23
0
 /// <summary>
 /// Constructs a tag serializer for a specific engine version.
 /// </summary>
 /// <param name="version">The engine version to target.</param>
 public TagSerializer(DefinitionSet version)
 {
     _version = version;
 }
예제 #24
0
 public MinVersionAttribute(DefinitionSet version)
 {
     Version = version;
 }
예제 #25
0
 /// <summary>
 /// Detects the engine that a tags.dat was built for.
 /// </summary>
 /// <param name="cache">The cache file.</param>
 /// <param name="closestGuess">On return, the closest guess for the engine's version.</param>
 /// <returns>The engine version if it is known for sure, otherwise <see cref="DefinitionSet.Unknown"/>.</returns>
 public static DefinitionSet Detect(TagCache cache, out DefinitionSet closestGuess)
 {
     return(DetectFromTimestamp(cache.Timestamp, out closestGuess));
 }
예제 #26
0
 public MinVersionAttribute(DefinitionSet version)
 {
     Version = version;
 }
예제 #27
0
        /// <summary>
        /// Translates a tag index between two versions.
        /// </summary>
        /// <param name="version1">The version of the index to translate.</param>
        /// <param name="index1">The tag index.</param>
        /// <param name="version2">The version to get the equivalent tag index in.</param>
        /// <returns>The equivalent tag index if found, or -1 otherwise.</returns>
        public int Translate(DefinitionSet version1, int index1, DefinitionSet version2)
        {
            // Get both version maps and fail if one doesn't exist
            VersionMap map1, map2;
            if (!_versionMaps.TryGetValue(version1, out map1))
                return -1;
            if (!_versionMaps.TryGetValue(version2, out map2))
                return -1;

            // Get the global index from the first map, then look up that index in the second one
            var globalIndex = map1.GetGlobalTagIndex(index1);
            if (globalIndex < 0)
                return -1;
            return map2.GetVersionedTagIndex(globalIndex);
        }
예제 #28
0
 private void LoadTableDefinitionSet(DefinitionSet loaded)
 {
     _tablesInDefinitionOrder = DefinitionSetMerger.Merge(loaded, _tablesInDefinitionOrder).ToList();
     _tableDefinitions        = _tablesInDefinitionOrder.ToDictionary(t => t.TableName, t => t);
 }
예제 #29
0
 /// <summary>
 /// Determines whether a version number is between two other version numbers (inclusive).
 /// </summary>
 /// <param name="compare">The version number to compare. If this is <see cref="DefinitionSet.Unknown"/>, this function will always return <c>true</c>.</param>
 /// <param name="min">The minimum version number. If this is <see cref="DefinitionSet.Unknown"/>, then the lower bound will be ignored.</param>
 /// <param name="max">The maximum version number. If this is <see cref="DefinitionSet.Unknown"/>, then the upper bound will be ignored.</param>
 /// <returns></returns>
 public static bool IsBetween(DefinitionSet compare, DefinitionSet min, DefinitionSet max)
 {
     if (compare == DefinitionSet.Unknown)
         return true;
     if (min != DefinitionSet.Unknown && Compare(compare, min) < 0)
         return false;
     return (max == DefinitionSet.Unknown || Compare(compare, max) <= 0);
 }
예제 #30
0
        public static ResourceLocation FixResourceLocation(ResourceLocation location, DefinitionSet srcVersion, DefinitionSet destVersion)
        {
            if (Definition.Compare(destVersion, DefinitionSet.HaloOnline235640) >= 0)
            {
                return(location);
            }
            switch (location)
            {
            case ResourceLocation.RenderModels:
                return(ResourceLocation.Resources);

            case ResourceLocation.Lightmaps:
                return(ResourceLocation.Textures);
            }
            return(location);
        }
예제 #31
0
 /// <summary>
 /// Creates a vertex stream for a given engine version.
 /// </summary>
 /// <param name="version">The engine version.</param>
 /// <param name="stream">The base stream.</param>
 /// <returns>The created vertex stream.</returns>
 public static IVertexStream Create(DefinitionSet version, Stream stream)
 {
     if (Definition.Compare(version, DefinitionSet.HaloOnline235640) >= 0)
         return new Definitions.HaloOnline235640.VertexStream(stream);
     return new Definitions.HaloOnline106708.VertexStream(stream);
 }
예제 #32
0
 /// <summary>
 /// Constructs a tag deserializer for a specific engine version.
 /// </summary>
 /// <param name="version">The engine version to target.</param>
 public TagDeserializer(DefinitionSet version)
 {
     _version = version;
 }
예제 #33
0
            public void OverrideBy(DefinitionSet definitionSet)
            {
                base.OverrideBy(definitionSet);

                foreach (var def in definitionSet.m_gridCreateDefinitions)
                {
                    m_gridCreateDefinitions[def.Key] = def.Value;
                }

                for (int i = 0; i < definitionSet.m_cubeSizes.Length; i++)
                {
                    var cubeSize = definitionSet.m_cubeSizes[i];
                    if (cubeSize != 0)
                    {
                        m_cubeSizes[i]         = cubeSize;
                        m_cubeSizesOriginal[i] = definitionSet.m_cubeSizesOriginal[i];
                    }
                }

                for (int i = 0; i < definitionSet.m_basePrefabNames.Length; i++)
                {
                    if (!string.IsNullOrEmpty(definitionSet.m_basePrefabNames[i]))
                    {
                        m_basePrefabNames[i] = definitionSet.m_basePrefabNames[i];
                    }
                }

                m_definitionsById.Merge(definitionSet.m_definitionsById);

                foreach (var voxelMaterial in definitionSet.m_voxelMaterialsByName)
                {
                    m_voxelMaterialsByName[voxelMaterial.Key] = voxelMaterial.Value;
                }

                foreach (var physicalMaterial in definitionSet.m_physicalMaterialsByName)
                {
                    m_physicalMaterialsByName[physicalMaterial.Key] = physicalMaterial.Value;
                }

                MergeDefinitionLists(m_physicalItemDefinitions, definitionSet.m_physicalItemDefinitions);

                foreach (var blockPosition in definitionSet.m_blockPositions)
                {
                    m_blockPositions[blockPosition.Key] = blockPosition.Value;
                }

                for (int i = 0; i < definitionSet.m_uniqueCubeBlocksBySize.Length; i++)
                {
                    var uniqueCubeBlocksBySize = definitionSet.m_uniqueCubeBlocksBySize[i];
                    foreach (var uniqueCubeBlocks in uniqueCubeBlocksBySize)
                    {
                        m_uniqueCubeBlocksBySize[i][uniqueCubeBlocks.Key] = uniqueCubeBlocks.Value;
                    }
                }

                m_blueprintsById.Merge(definitionSet.m_blueprintsById);
                MergeDefinitionLists(m_spawnGroupDefinitions, definitionSet.m_spawnGroupDefinitions);
                m_containerTypeDefinitions.Merge(definitionSet.m_containerTypeDefinitions);
                m_handItemsById.Merge(definitionSet.m_handItemsById);
                MergeDefinitionLists(m_scenarioDefinitions, definitionSet.m_scenarioDefinitions);

                foreach (var character in definitionSet.m_characters)
                {
                    if (character.Value.Enabled)
                    {
                        m_characters[character.Key] = character.Value;
                    }
                    else
                    {
                        m_characters.Remove(character.Key);
                    }
                }

                m_blueprintClasses.Merge(definitionSet.m_blueprintClasses);

                foreach (var classEntry in definitionSet.m_categoryClasses)
                {
                    m_categoryClasses.Add(classEntry);

                    string categoryName = classEntry.Name;

                    MyGuiBlockCategoryDefinition categoryDefinition = null;
                    if (false == m_categories.TryGetValue(categoryName, out categoryDefinition))
                    {
                        m_categories.Add(categoryName, classEntry);
                    }
                    else
                    {
                        categoryDefinition.ItemIds.UnionWith(classEntry.ItemIds);
                    }
                }

                foreach (var classEntry in definitionSet.m_blueprintClassEntries)
                {
                    if (m_blueprintClassEntries.Contains(classEntry))
                    {
                        if (classEntry.Enabled == false)
                        {
                            m_blueprintClassEntries.Remove(classEntry);
                        }
                    }
                    else
                    {
                        if (classEntry.Enabled == true)
                        {
                            m_blueprintClassEntries.Add(classEntry);
                        }
                    }
                }

                m_blueprintsByResultId.Merge(definitionSet.m_blueprintsByResultId);

                foreach (var classEntry in definitionSet.m_environmentItemsEntries)
                {
                    if (m_environmentItemsEntries.Contains(classEntry))
                    {
                        if (classEntry.Enabled == false)
                        {
                            m_environmentItemsEntries.Remove(classEntry);
                        }
                    }
                    else
                    {
                        if (classEntry.Enabled == true)
                        {
                            m_environmentItemsEntries.Add(classEntry);
                        }
                    }
                }

                foreach (var blockEntry in definitionSet.m_componentBlockEntries)
                {
                    if (m_componentBlockEntries.Contains(blockEntry))
                    {
                        if (blockEntry.Enabled == false)
                        {
                            m_componentBlockEntries.Remove(blockEntry);
                        }
                    }
                    else
                    {
                        if (blockEntry.Enabled == true)
                        {
                            m_componentBlockEntries.Add(blockEntry);
                        }
                    }
                }

                foreach (var prefab in definitionSet.m_prefabs)
                {
                    if (prefab.Value.Enabled)
                    {
                        m_prefabs[prefab.Key] = prefab.Value;
                    }
                    else
                    {
                        m_prefabs.Remove(prefab.Key);
                    }
                }

                foreach (var respawnShip in definitionSet.m_respawnShips)
                {
                    if (respawnShip.Value.Enabled)
                    {
                        m_respawnShips[respawnShip.Key] = respawnShip.Value;
                    }
                    else
                    {
                        m_respawnShips.Remove(respawnShip.Key);
                    }
                }

                foreach (var animationSet in definitionSet.m_animationsBySkeletonType)
                {
                    foreach (var animation in animationSet.Value)
                    {
                        if (animation.Value.Enabled)
                        {
                            if (!m_animationsBySkeletonType.ContainsKey(animationSet.Key))
                            {
                                m_animationsBySkeletonType[animationSet.Key] = new Dictionary <string, MyAnimationDefinition>();
                            }

                            m_animationsBySkeletonType[animationSet.Key][animation.Value.Id.SubtypeName] = animation.Value;
                        }
                        else
                        {
                            m_animationsBySkeletonType[animationSet.Key].Remove(animation.Value.Id.SubtypeName);
                        }
                    }
                }

                foreach (var soundDef in definitionSet.m_sounds)
                {
                    // Enabled attribute is handled differently with sounds to prevent confusion between removed sound and missing sound
                    m_sounds[soundDef.Key] = soundDef.Value;
                }

                m_weaponDefinitionsById.Merge(definitionSet.m_weaponDefinitionsById);
                m_ammoDefinitionsById.Merge(definitionSet.m_ammoDefinitionsById);
                m_behaviorDefinitions.Merge(definitionSet.m_behaviorDefinitions);

                foreach (var voxelMapStorageDef in definitionSet.m_voxelMapStorages)
                {
                    m_voxelMapStorages[voxelMapStorageDef.Key] = voxelMapStorageDef.Value;
                }

                foreach (var nameEntry in definitionSet.m_characterNames)
                {
                    m_characterNames.Add(nameEntry);
                }

                if (definitionSet.m_battleDefinition != null)
                {
                    if (definitionSet.m_battleDefinition.Enabled)
                    {
                        m_battleDefinition.Merge(definitionSet.m_battleDefinition);
                    }
                }

                foreach (var entry in definitionSet.m_componentSubstitutions)
                {
                    m_componentSubstitutions[entry.Key] = entry.Value;
                }

                m_componentGroups.Merge(definitionSet.m_componentGroups);
                foreach (var entry in definitionSet.m_planetGeneratorDefinitions)
                {
                    if (entry.Value.Enabled)
                    {
                        m_planetGeneratorDefinitions[entry.Key] = entry.Value;
                    }
                    else
                    {
                        m_planetGeneratorDefinitions.Remove(entry.Key);
                    }
                }

                foreach (var entry in definitionSet.m_planetPrefabDefinitions)
                {
                    if (entry.Value.Enabled)
                    {
                        m_planetPrefabDefinitions[entry.Key] = entry.Value;
                    }
                    else
                    {
                        m_planetPrefabDefinitions.Remove(entry.Key);
                    }
                }

                foreach (var entry in definitionSet.m_groupedIds)
                {
                    if (m_groupedIds.ContainsKey(entry.Key))
                    {
                        var localGroup = m_groupedIds[entry.Key];
                        foreach (var key in entry.Value)
                        {
                            localGroup[key.Key] = key.Value;
                        }
                    }
                    else
                    {
                        m_groupedIds[entry.Key] = entry.Value;
                    }
                }

                m_scriptedGroupDefinitions.Merge(definitionSet.m_scriptedGroupDefinitions);
                m_pirateAntennaDefinitions.Merge(definitionSet.m_pirateAntennaDefinitions);

                if (definitionSet.m_destructionDefinition != null)
                {
                    if (definitionSet.m_destructionDefinition.Enabled)
                    {
                        m_destructionDefinition.Merge(definitionSet.m_destructionDefinition);
                    }
                }

                foreach (var entry in definitionSet.m_mapMultiBlockDefToCubeBlockDef)
                {
                    if (m_mapMultiBlockDefToCubeBlockDef.ContainsKey(entry.Key))
                    {
                        m_mapMultiBlockDefToCubeBlockDef.Remove(entry.Key);
                    }

                    m_mapMultiBlockDefToCubeBlockDef.Add(entry.Key, entry.Value);
                }

                foreach (var entry in definitionSet.m_idToRope)
                {
                    m_idToRope[entry.Key] = entry.Value;
                }

                m_entityComponentDefinitions.Merge(definitionSet.m_entityComponentDefinitions);
                m_entityContainers.Merge(definitionSet.m_entityContainers);

                m_lootBagDefinition = definitionSet.m_lootBagDefinition;
            }
예제 #34
0
        public static void Define <T>(IGraphSource <T, string> graph,
                                      Func <VerticesPair <string>, T> getEdgeDataCallback,
                                      DefinitionSet set,
                                      Func <Edge <string, T>, bool> addEdgePredicate = null)
        {
            var e = new GraphEdgeSequenceAssembler <string>();

            if ((set & DefinitionSet.Set0) != 0)
            {
                for (var idx = 0; idx < VertexSymbolsA2J.Length - 1; ++idx)
                {
                    e.Define(VertexSymbolsA2J[idx], VertexSymbolsA2J[idx + 1]);
                }
            }

            if ((set & DefinitionSet.Set1) != 0)
            {
                e.Define("E", "M");
                e.Define("F", "N");
                e.Define("G", "D");
                e.Define("B", "I");
            }

            if ((set & DefinitionSet.Set2) != 0)
            {
                e.DefineSelfLoops(VertexSymbolsA2J);
            }

            if ((set & DefinitionSet.Set3) != 0)
            {
                e["Q"].DefineTo(VertexSymbolsA2J.Take(7));                 //< A-G
                e["R"].DefineTo(VertexSymbolsA2J.Take(8));                 //< A-H
                e["S"].DefineTo(VertexSymbolsA2J.Take(9));                 //< A-I
            }

            if ((set & DefinitionSet.Set4) != 0)
            {
                e["U"].DefineFrom(VertexSymbolsA2J);
            }

            if ((set & DefinitionSet.Set5) != 0)
            {
                e.Define("X", "Y");
                e.Define("Y", "Z");
                e.Define("Z", "X");
            }

            if ((set & DefinitionSet.Set6) != 0)
            {
                e.Define("Y", "X");
                e.Define("Z", "Y");
                e.Define("X", "Z");
            }

            if ((set & DefinitionSet.Set7) != 0)
            {
                e["T"].DefineSelfLoop();
            }

            if ((set & DefinitionSet.Set8) != 0)
            {
                e.Define("J", "A");
            }

            graph.AddEdgeRange(e.AdjacentVerticesPairs, getEdgeDataCallback, addEdgePredicate);
        }
예제 #35
0
 /// <summary>
 /// Compares two version numbers.
 /// </summary>
 /// <param name="lhs">The left-hand version number.</param>
 /// <param name="rhs">The right-hand version number.</param>
 /// <returns>A positive value if the left version is newer, a negative value if the right version is newer, and 0 if the versions are equivalent.</returns>
 public static int Compare(DefinitionSet lhs, DefinitionSet rhs)
 {
     // Assume the enum values are in order by release date
     return((int)lhs - (int)rhs);
 }