Example #1
0
        public static SpawnTypeEnum TagSpawnTypeEnumCheck(string tag)
        {
            SpawnTypeEnum result   = SpawnTypeEnum.CustomSpawn;
            var           tagSplit = ProcessTag(tag);

            if (tagSplit.Length == 2)
            {
                if (SpawnTypeEnum.TryParse(tagSplit[1], out result) == false)
                {
                    return(SpawnTypeEnum.CustomSpawn);
                }
            }

            return(result);
        }
Example #2
0
        public SpawnProfile()
        {
            UseSpawn         = false;
            StartsReady      = false;
            FirstSpawnTimeMs = 0;
            SpawnMinCooldown = 0;
            SpawnMaxCooldown = 1;
            MaxSpawns        = -1;
            SpawnGroups      = new List <string>();

            CooldownTime  = 0;
            SpawnCount    = 0;
            LastSpawnTime = MyAPIGateway.Session.GameDateTime;

            UseRelativeSpawnPosition = false;
            MinDistance           = 0;
            MaxDistance           = 1;
            MinAltitude           = 0;
            MaxAltitude           = 1;
            RelativeSpawnOffset   = Vector3D.Zero;
            RelativeSpawnVelocity = Vector3D.Zero;
            IgnoreSafetyChecks    = false;
            InheritNpcAltitude    = false;
            ProfileSubtypeId      = "";

            ForceSameFactionOwnership = false;

            SpawningType = SpawnTypeEnum.CustomSpawn;

            CustomRelativeForward = Direction.None;
            CustomRelativeUp      = Direction.None;

            CurrentPositionMatrix = MatrixD.Identity;
            CurrentFactionTag     = "";
            Rnd = new Random();
        }
Example #3
0
        public void InitTags(string customData)
        {
            if (string.IsNullOrWhiteSpace(customData) == false)
            {
                var descSplit = customData.Split('\n');

                foreach (var tag in descSplit)
                {
                    //UseSpawn
                    if (tag.Contains("[UseSpawn:") == true)
                    {
                        UseSpawn = TagHelper.TagBoolCheck(tag);
                    }

                    //FirstSpawnTimeMs
                    if (tag.Contains("[FirstSpawnTimeMs:") == true)
                    {
                        FirstSpawnTimeMs = TagHelper.TagFloatCheck(tag, FirstSpawnTimeMs);
                    }

                    //SpawnMinCooldown
                    if (tag.Contains("[SpawnMinCooldown:") == true)
                    {
                        SpawnMinCooldown = TagHelper.TagFloatCheck(tag, SpawnMinCooldown);
                    }

                    //SpawnMaxCooldown
                    if (tag.Contains("[SpawnMaxCooldown:") == true)
                    {
                        SpawnMaxCooldown = TagHelper.TagFloatCheck(tag, SpawnMaxCooldown);
                    }

                    //MaxSpawns
                    if (tag.Contains("MaxSpawns:") == true)
                    {
                        MaxSpawns = TagHelper.TagIntCheck(tag, MaxSpawns);
                    }

                    //SpawnGroups
                    if (tag.Contains("SpawnGroups:") == true)
                    {
                        var tempvalue = TagHelper.TagStringCheck(tag);

                        if (string.IsNullOrWhiteSpace(tempvalue) == false)
                        {
                            SpawnGroups.Add(tempvalue);
                        }
                    }

                    //UseRelativeSpawnPosition
                    if (tag.Contains("[UseRelativeSpawnPosition:") == true)
                    {
                        UseRelativeSpawnPosition = TagHelper.TagBoolCheck(tag);
                    }

                    //MinDistance
                    if (tag.Contains("[MinDistance:") == true)
                    {
                        MinDistance = TagHelper.TagDoubleCheck(tag, MinDistance);
                    }

                    //MaxDistance
                    if (tag.Contains("[MaxDistance:") == true)
                    {
                        MaxDistance = TagHelper.TagDoubleCheck(tag, MaxDistance);
                    }

                    //MinAltitude
                    if (tag.Contains("[MinAltitude:") == true)
                    {
                        MinAltitude = TagHelper.TagDoubleCheck(tag, MinAltitude);
                    }

                    //MaxAltitude
                    if (tag.Contains("[MaxAltitude:") == true)
                    {
                        MaxAltitude = TagHelper.TagDoubleCheck(tag, MaxAltitude);
                    }

                    //RelativeSpawnOffset
                    if (tag.Contains("[RelativeSpawnOffset:") == true)
                    {
                        RelativeSpawnOffset = TagHelper.TagVector3DCheck(tag);
                    }

                    //RelativeSpawnVelocity
                    if (tag.Contains("[RelativeSpawnVelocity:") == true)
                    {
                        RelativeSpawnVelocity = TagHelper.TagVector3DCheck(tag);
                    }

                    //IgnoreSafetyChecks
                    if (tag.Contains("[IgnoreSafetyChecks:") == true)
                    {
                        IgnoreSafetyChecks = TagHelper.TagBoolCheck(tag);
                    }

                    //InheritNpcAltitude
                    if (tag.Contains("[InheritNpcAltitude:") == true)
                    {
                        InheritNpcAltitude = TagHelper.TagBoolCheck(tag);
                    }

                    //ForceSameFactionOwnership
                    if (tag.Contains("[ForceSameFactionOwnership:") == true)
                    {
                        ForceSameFactionOwnership = TagHelper.TagBoolCheck(tag);
                    }

                    //SpawningType
                    if (tag.Contains("[SpawningType:") == true)
                    {
                        SpawningType = TagHelper.TagSpawnTypeEnumCheck(tag);
                    }

                    //CustomRelativeForward
                    if (tag.Contains("[CustomRelativeForward:") == true)
                    {
                        CustomRelativeForward = TagHelper.TagDirectionEnumCheck(tag);
                    }

                    //CustomRelativeUp
                    if (tag.Contains("[CustomRelativeUp:") == true)
                    {
                        CustomRelativeUp = TagHelper.TagDirectionEnumCheck(tag);
                    }
                }
            }

            if (SpawnMinCooldown > SpawnMaxCooldown)
            {
                SpawnMinCooldown = SpawnMaxCooldown;
            }
        }
Example #4
0
            /// <summary>
            /// For ScaleRotateYawPitchRollSpawn objects, the first 52 bytes are all
            /// generic for Halo 2.
            /// </summary>
            /// <param name="map">The HaloMap.Map.Map</param>
            public override void Read(Map map)
            {
                map.BR.BaseStream.Position = this.offset;
                this.PaletteIndex = map.BR.ReadInt16();
                this.NameIndex = map.BR.ReadInt16();
                this.Placements = (PlacementFlags)map.BR.ReadInt32();

                this.X = map.BR.ReadSingle();
                this.Y = map.BR.ReadSingle();
                this.Z = map.BR.ReadSingle();
                switch (map.HaloVersion)
                {
                    // Halo 1 Stores values in Degrees
                    case HaloVersionEnum.Halo1:
                        this.Yaw = Renderer.DegreeToRadian(map.BR.ReadSingle());
                        this.Pitch = Renderer.DegreeToRadian(map.BR.ReadSingle());
                        this.Roll = Renderer.DegreeToRadian(map.BR.ReadSingle());
                        break;

                    case HaloVersionEnum.Halo2:
                    case HaloVersionEnum.Halo2Vista:
                        // Is this correct? I think it should be Yaw, Pitch, Roll.
                        // Before cleaing code into this shared read section some spawns
                        // were Y,P,R and some were R,P,Y.
                        this.Yaw = map.BR.ReadSingle();
                        this.Pitch = map.BR.ReadSingle();
                        this.Roll = map.BR.ReadSingle();
                        this.Scale = map.BR.ReadSingle();

                        // None of this is currently saved
                        this.Transforms = (TransformFlags)map.BR.ReadInt16();
                        this.ManualBSPs = (ManualBSPFlags)map.BR.ReadInt16();
                        this.UniqueID = map.BR.ReadUInt32();
                        this.OriginBSP = map.BR.ReadInt16();
                        this.MetaSpawnType = (SpawnTypeEnum)map.BR.ReadByte();
                        this.Source = (SourceEnum)map.BR.ReadByte();
                        this.BSPPolicy = (BSPPolicyEnum)map.BR.ReadByte(); ;
                        this.Unused = map.BR.ReadByte();
                        this.EditorFolder = map.BR.ReadInt16();
                        break;
                }
            }