Example #1
0
        private Dictionary <int, TR2Entity> GetSecretItems(TR2Level level)
        {
            Dictionary <int, TR2Entity> entities = new Dictionary <int, TR2Entity>();

            for (int i = 0; i < level.NumEntities; i++)
            {
                if (TR2EntityUtilities.IsSecretType((TR2Entities)level.Entities[i].TypeID))
                {
                    entities[i] = level.Entities[i];
                }
            }

            return(entities);
        }
Example #2
0
        private void RandomizeStartPosition(TR2CombinedLevel level)
        {
            if (level.Script.HasStartAnimation)
            {
                // Don't change either the position or angle in Rig or HSH as the start cutscene looks odd and
                // for HSH Lara doesn't end up on the trigger for the enemies.
                return;
            }

            List <TR2Entity> entities = level.Data.Entities.ToList();
            TR2Entity        lara     = entities.Find(e => e.TypeID == (short)TR2Entities.Lara);

            if (!RotateOnly)
            {
                // We only change position if there is not a secret in the same room as Lara, This is just in case it ends up
                // where she starts on a slope (GW or Opera House for example), as its X,Y,Z values may not be identical to Lara's.
                if (entities.Find(e => e.Room == lara.Room && TR2EntityUtilities.IsSecretType((TR2Entities)e.TypeID)) == null)
                {
                    // If we haven't defined anything for a level, Lara will just be rotated. This is most likely where there are
                    // triggers just after Lara's starting spot, so we just skip them here.
                    if (_startLocations.ContainsKey(level.Name))
                    {
                        List <Location> locations = _startLocations[level.Name];
                        if (DevelopmentMode)
                        {
                            foreach (Location loc in locations)
                            {
                                entities.Add(new TR2Entity
                                {
                                    TypeID     = (short)TR2Entities.Lara,
                                    Room       = Convert.ToInt16(loc.Room),
                                    X          = loc.X,
                                    Y          = loc.Y,
                                    Z          = loc.Z,
                                    Angle      = 0,
                                    Intensity1 = -1,
                                    Intensity2 = -1,
                                    Flags      = 0
                                });
                            }
                        }
                        else
                        {
                            Location location = locations[_generator.Next(0, locations.Count)];
                            lara.Room  = (short)location.Room;
                            lara.X     = location.X;
                            lara.Y     = location.Y;
                            lara.Z     = location.Z;
                            lara.Angle = location.Angle;
                        }
                    }
                }
            }

            RotateLara(lara, level);

            if (DevelopmentMode)
            {
                level.Data.Entities    = entities.ToArray();
                level.Data.NumEntities = (uint)entities.Count;
            }
        }