Ejemplo n.º 1
0
        private IEnumerator EnterFirstAreaRoutine()
        {
            // Replace ID 0 with SaveData.Instance.LastArea.ID

            Overworld overworld = fileSelect.Overworld;
            AreaData  area      = AreaData.Areas[SaveData.Instance.LastArea.ID];

            if (area.GetLevelSet() != "Celeste")
            {
                // Pretend that we've beaten Prologue.
                LevelSetStats stats = SaveData.Instance.GetLevelSetStatsFor("Celeste");
                stats.UnlockedAreas = 1;
                stats.AreasIncludingCeleste[0].Modes[0].Completed = true;
            }

            yield return(fileSelect.Leave(null));

            yield return(overworld.Mountain.EaseCamera(0, area.MountainIdle));

            yield return(0.3f);

            overworld.Mountain.EaseCamera(0, area.MountainZoom, 1f);
            yield return(0.4f);

            area.Wipe(overworld, false, null);
            overworld.RendererList.UpdateLists();
            overworld.RendererList.MoveToFront(overworld.Snow);

            yield return(0.5f);

            LevelEnter.Go(new Session(SaveData.Instance.LastArea), false);
        }
 public EncounterIntro(Overworld overworld, Party enemyParty)
     : base(overworld)
 {
     if (enemyParty == null)
         throw new Exception("Party enemyParty cannot be null");
     this.enemyParty = enemyParty;
 }
Ejemplo n.º 3
0
        public override void Update(Scene scene)
        {
            AreaData area = -1 < Area && Area < (AreaData.Areas?.Count ?? 0) ? AreaData.Get(Area) : null;
            MapMeta  meta = area?.GetMeta();

            bool wasFreeCam = inFreeCameraDebugMode;

            if (meta?.Mountain?.ShowCore ?? false)
            {
                Area = 9;
                orig_Update(scene);
                Area = area.ID;
            }
            else
            {
                orig_Update(scene);
            }

            Overworld overworld = scene as Overworld;

            if (!wasFreeCam && inFreeCameraDebugMode && (
                    ((overworld.Current ?? overworld.Next) is patch_OuiFileNaming naming && naming.UseKeyboardInput) ||
                    ((overworld.Current ?? overworld.Next) is OuiModOptionString stringInput && stringInput.UseKeyboardInput)))
            {
                // we turned on free cam mode (by pressing Space) while on an text entry screen using keyboard input... we should turn it back off.
                inFreeCameraDebugMode = false;
            }
        }
Ejemplo n.º 4
0
    public void ReadData(Overworld world)
    {
        world.TogglePause(); // Keep things from moving around for the save.

        saveFile = world.saveFile;

        nextActorId = world.nextActorId;
        nextItemId  = world.nextActorId;

        actorsData = world.actorsData;
        cellsData  = world.cellsData;
        itemsData  = world.itemsData;

        foreach (int id in world.actors.Keys)
        {
            actorsData.Add(id, world.actors[id].GetData());
        }

        foreach (int id in world.cells.Keys)
        {
            cellsData.Add(id, world.cells[id].GetData());
        }

        foreach (int id in world.items.Keys)
        {
            itemsData.Add(id, world.items[id].GetData());
        }

        world.TogglePause();
    }
Ejemplo n.º 5
0
        public override void Update()
        {
            if (menu != null && menu.Focused && Selected)
            {
                if (Input.MenuCancel.Pressed && builderThread == null)
                {
                    Audio.Play(SFX.ui_main_button_back);
                    Overworld.Goto <OuiMainMenu>();
                }
                else if (Input.Pause.Pressed)
                {
                    Audio.Play(SFX.ui_main_button_select);
                    menu.Selection = menu.LastPossibleSelection;
                    menu.Current.OnPressed();
                }
                else if (Input.MenuJournal.Pressed)
                {
                    Audio.Play(SFX.ui_world_journal_select);
                    Overworld.Goto <OuiRandoRecords>();
                }
            }

            journalEase = Calc.Approach(journalEase, (menu?.Focused ?? false) ? 1f : 0f, Engine.DeltaTime * 4f);

            base.Update();
        }
Ejemplo n.º 6
0
        public ChunkGeneratorSettings(int Seed, float NoiseScale, Overworld Overworld)
        {
            this.Overworld = Overworld;

            NoiseGenerator  = new Perlin(Seed);
            this.NoiseScale = NoiseScale;

            CaveNoiseScale  = NoiseScale * 10.0f;
            CaveSize        = 0.03f;
            CaveFrequencies = new List <float>()
            {
                0.5f, 0.7f, 0.9f, 1.0f
            };

            CaveNoise = new FastRidgedMultifractal(Seed)
            {
                Frequency    = 0.5f,
                Lacunarity   = 0.5f,
                NoiseQuality = NoiseQuality.Standard,
                OctaveCount  = 1,
                Seed         = Seed
            };

            CaveLevels = new List <int>();
            var caveStep = 48 / Overworld.NumCaveLayers;

            for (var i = 0; i < Overworld.NumCaveLayers; ++i)
            {
                CaveLevels.Add(4 + (caveStep * i));
            }
        }
Ejemplo n.º 7
0
        private void handlePlayerMovement(Delta delta)
        {
            Vector2 velocity = Vector2.Zero;

            if (Input.Up())
            {
                velocity.Y -= 1.0f;
            }
            if (Input.Down())
            {
                velocity.Y += 1.0f;
            }
            if (Input.Left())
            {
                velocity.X -= 1.0f;
            }
            if (Input.Right())
            {
                velocity.X += 1.0f;
            }

            if (velocity != Vector2.Zero)
            {
                velocity.Normalize();
                velocity *= movementVelocity;
            }

            Entity entity = Overworld.PlayerParty.PrimaryPartyMember.OverworldEntity;

            handleWallCollisions(entity, delta, ref velocity);
            handleSceneryCollisions(entity, delta, ref velocity);
            entity.Velocity = velocity;

            Overworld.SetEntityAnimationForVelocity(entity);
        }
Ejemplo n.º 8
0
        // Temp - start a test wild battle
        public void TempCreateWildBattle(Map map, Map.Layout.Block block, EncounterTable.Encounter encounter)
        {
            Save sav      = Save;
            var  me       = new PBETrainerInfo(sav.PlayerParty, sav.PlayerName);
            var  wildPkmn = PartyPokemon.GetTestWildPokemon(encounter);
            var  wild     = new PBETrainerInfo(new Party {
                wildPkmn
            }, "Wild " + PBELocalizedString.GetSpeciesName(wildPkmn.Species).English);

            void OnBattleEnded()
            {
                void FadeFromTransitionEnded()
                {
                    _fadeFromTransition = null;
                }

                _fadeFromTransition = new FadeFromColorTransition(20, 0, FadeFromTransitionEnded);
                _battleGUI          = null;
            }

            _battleGUI = new BattleGUI(new PBEBattle(PBEBattleFormat.Single, PBESettings.DefaultSettings, me, wild,
                                                     battleTerrain: Overworld.GetPBEBattleTerrainFromBlock(block.BlocksetBlock),
                                                     weather: Overworld.GetPBEWeatherFromMap(map)),
                                       OnBattleEnded);
            void OnBattleTransitionEnded()
            {
                _battleTransition = null;
            }

            _battleTransition = new SpiralTransition(OnBattleTransitionEnded);
        }
        public override IEnumerator Enter(Oui from)
        {
            if (Direction == 0)
            {
                Overworld.Goto <OuiChapterSelect>();
                goto Done;
            }
            Direction = Math.Sign(Direction);

            yield return(0.25f);

            int    startID       = SaveData.Instance.LastArea.ID;
            string startLevelSet = SaveData.Instance.GetLevelSet();
            int    count         = AreaData.Areas.Count;

            for (int i = (count + startID + Direction) % count; i != startID; i = (count + i + Direction) % count)
            {
                AreaData area = AreaData.Areas[i];
                if (area.GetLevelSet() != startLevelSet)
                {
                    SaveData.Instance.LastArea = area.ToKey();
                    goto Done;
                }
            }

Done:
            Audio.Play("event:/ui/main/whoosh_large_in");
            Overworld.Goto <OuiChapterSelect>();
            yield break;
        }
Ejemplo n.º 10
0
 private IEnumerator EnterClose(Oui from)
 {
     Overworld.Goto <OuiChapterSelect>();
     Visible      = false;
     instantClose = false;
     yield break;
 }
Ejemplo n.º 11
0
 // This is a bit of a hack. is there a better way to control this?
 private void HideMaddy(On.Celeste.Overworld.orig_ctor orig, Overworld self, OverworldLoader loader)
 {
     orig(self, loader);
     if (this.InRandomizer)
     {
         self.Maddy.Hide();
     }
 }
Ejemplo n.º 12
0
 public override bool IsStart(Overworld overworld, Overworld.StartMode start)
 {
     if (CoreModule.Settings.CurrentVersion == null && !overworld.IsCurrent <OuiOOBE>())
     {
         start = Overworld.StartMode.MainMenu;
     }
     return(orig_IsStart(overworld, start));
 }
Ejemplo n.º 13
0
    public OverworldData(Overworld world)
    {
        actorsData = new System.Collections.Generic.Dictionary <int, ActorData>();
        cellsData  = new System.Collections.Generic.Dictionary <int, TerrainCellData>();
        itemsData  = new System.Collections.Generic.Dictionary <int, ItemData>();

        ReadData(world);
    }
        public Encounter(Overworld overworld, Party enemyParty)
            : base(overworld)
        {
            this.enemyParty = enemyParty;

            // In here instead of Start() to stop flicker when the state is rendered before Start() is called. The EncounterRenderer doesn't rely on the state of Encounter anyway
            OverworldStateRenderer = new EncounterRenderer(this);
        }
Ejemplo n.º 15
0
 private static bool ElevationCheck(BlocksetBlockBehavior curBehavior, BlocksetBlockBehavior targetBehavior, byte curElevation, byte targetElevations)
 {
     if (targetElevations.HasElevation(curElevation))
     {
         return(true);
     }
     return(Overworld.AllowsElevationChange(curBehavior) || Overworld.AllowsElevationChange(targetBehavior));
 }
Ejemplo n.º 16
0
        public Encounter(Overworld overworld, Party enemyParty)
            : base(overworld)
        {
            this.enemyParty = enemyParty;

            // In here instead of Start() to stop flicker when the state is rendered before Start() is called. The EncounterRenderer doesn't rely on the state of Encounter anyway
            OverworldStateRenderer = new EncounterRenderer(this);
        }
Ejemplo n.º 17
0
 public void Exit()
 {
     task = null;
     Lines.Clear();
     ((patch_OuiMainMenu)Overworld.GetUI <OuiMainMenu>())?.RebuildMainAndTitle();
     Audio.Play(SFX.ui_main_button_back);
     Overworld.Goto <OuiModOptions>();
 }
Ejemplo n.º 18
0
    void Awake()
    {
        that = this;
        max = levelLocations.Count - 1;

        GlobalScript.currentLevel = 1;
        levelLocations[cur].GetComponent<SpriteRenderer>().color = highlight;
    }
Ejemplo n.º 19
0
 public EncounterIntro(Overworld overworld, Party enemyParty)
     : base(overworld)
 {
     if (enemyParty == null)
     {
         throw new Exception("Party enemyParty cannot be null");
     }
     this.enemyParty = enemyParty;
 }
Ejemplo n.º 20
0
 public unsafe void RenderTick(uint *bmpAddress, int bmpWidth, int bmpHeight)
 {
     RenderUtils.FillColor(bmpAddress, bmpWidth, bmpHeight, 0xFF000000);
     CameraObj.Render(bmpAddress, bmpWidth, bmpHeight);
     if (Overworld.ShouldRenderDayTint())
     {
         DayTint.Render(bmpAddress, bmpWidth, bmpHeight);
     }
 }
Ejemplo n.º 21
0
        private void ReceiveDiscardChunk(BinaryReader reader)
        {
            int x = reader.ReadInt16() * Overworld.ChunkWidth;
            int y = reader.ReadInt16() * Overworld.ChunkHeight;

            OverworldTile tile = Overworld.GetOverworldTile(x, y);

            tile.UnloadChunks();
        }
Ejemplo n.º 22
0
        private void ReceiveExteriorChunk(BinaryReader reader)
        {
            int x = reader.ReadInt16() * Overworld.ChunkWidth;
            int y = reader.ReadInt16() * Overworld.ChunkHeight;

            OverworldTile tile = Overworld.GetOverworldTile(x, y);

            tile.LoadChunks(reader);
        }
Ejemplo n.º 23
0
 public override bool IsStart(Overworld overworld, Overworld.StartMode start)
 {
     if (start == RandoModule.STARTMODE_RANDOMIZER)
     {
         this.Add(new Coroutine(this.Enter(null)));
         return(true);
     }
     return(false);
 }
Ejemplo n.º 24
0
 public override bool IsStart(Overworld overworld, Overworld.StartMode start)
 {
     if (start != Overworld.StartMode.Titlescreen || CoreModule.Settings.CurrentVersion != null)
     {
         return(false);
     }
     Add(new Coroutine(Enter(null)));
     return(true);
 }
Ejemplo n.º 25
0
 public Menu(Overworld overworld)
     : base(overworld)
 {
     inputButtonListener = new InputButtonListener(new Dictionary<InputButton, ButtonEventHandlers> {
         { InputButton.Up, new ButtonEventHandlers(down: previousOption) },
         { InputButton.Down, new ButtonEventHandlers(down: nextOption) },
         { InputButton.A, new ButtonEventHandlers(up: selectOption) }
     });
 }
Ejemplo n.º 26
0
 public Menu(Overworld overworld)
     : base(overworld)
 {
     inputButtonListener = new InputButtonListener(new Dictionary <InputButton, ButtonEventHandlers> {
         { InputButton.Up, new ButtonEventHandlers(down: previousOption) },
         { InputButton.Down, new ButtonEventHandlers(down: nextOption) },
         { InputButton.A, new ButtonEventHandlers(up: selectOption) }
     });
 }
Ejemplo n.º 27
0
 public override bool IsStart(Overworld overworld, Overworld.StartMode start)
 {
     if (start == (Overworld.StartMode) 55)
     {
         this.Add((Component) new Coroutine(this.Enter((Oui)null), true));
         return(true);
     }
     return(false);
 }
Ejemplo n.º 28
0
 public Treadmill(Overworld world, int radius, Actor actor)
 {
     this.world         = world;
     this.radius        = radius;
     this.actor         = actor;
     this.scale         = Overworld.GetCellScale();
     this.currentCoords = Util.CoordsFromPosition(actor.Translation, scale);
     InitialRequests();
 }
        public override IEnumerator Enter(Oui from)
        {
            yield return(0.25f);

            Reload();

            Audio.Play(Sfxs.ui_world_whoosh_400ms_back);
            Overworld.Goto <OuiChapterSelect>();
        }
Ejemplo n.º 30
0
 public override bool IsStart(Overworld overworld, Overworld.StartMode start)
 {
     if (SaveData.Instance != null && SaveData.Instance.LastArea.ID == AreaKey.None.ID)
     {
         SaveData.Instance.LastArea = AreaKey.Default;
         instantClose = true;
     }
     return(orig_IsStart(overworld, start));
 }
Ejemplo n.º 31
0
 private void AddRecord(Ruleset rules, RecordTuple record)
 {
     menu.Add(new TextMenu.Button(Dialog.Clean("MODOPTIONS_RANDOMIZER_RULES_" + rules) + ": " + Dialog.Time(record.Item1) + " (" + record.Item2 + ")").Pressed(() => {
         Settings.Rules    = rules;
         Settings.SeedType = SeedType.Custom;
         Settings.Seed     = record.Item2;
         Settings.Enforce();
         Overworld.Goto <OuiRandoSettings>();
     }));
 }
Ejemplo n.º 32
0
        public override void Update()
        {
            if (!(Selected && Focused))
            {
                goto End;
            }

            if (Input.MenuRight.Pressed && selectedDigit < (digits.Length - 1))
            {
                selectedDigit = Math.Min(selectedDigit + 1, (digits.Length - 1));
                wigglerDigits[selectedDigit].Start();
                Audio.Play(SFX.ui_main_roll_down);
            }
            else if (Input.MenuLeft.Pressed && selectedDigit > 0)
            {
                selectedDigit = Math.Max(selectedDigit - 1, 0);
                wigglerDigits[selectedDigit].Start();
                Audio.Play(SFX.ui_main_roll_up);
            }
            else if (Input.MenuDown.Pressed)
            {
                UpdateDigits(selectedDigit, -1);
            }
            else if (Input.MenuUp.Pressed)
            {
                UpdateDigits(selectedDigit, +1);
            }
            else if (Input.MenuConfirm.Pressed)
            {
                if (playing != null)
                {
                    Audio.Stop(playing);
                }
                if (!string.IsNullOrEmpty(selectedPath))
                {
                    playing = Audio.Play(selectedPath);
                }
            }
            else if (Input.MenuCancel.Pressed || Input.Pause.Pressed || Input.ESC.Pressed)
            {
                Focused = false;
                Audio.Play(SFX.ui_main_button_back);
                Overworld.Goto <OuiModOptions>();
            }

End:
            pressedTimer -= Engine.DeltaTime;
            timer        += Engine.DeltaTime;
            for (int i = 0; i < digits.Length; i++)
            {
                wigglerDigits[i].Update();
            }
            wigglerPath.Update();
            wigglerBankPath.Update();
        }
Ejemplo n.º 33
0
 public override void Update()
 {
     if (instantClose)
     {
         Overworld.Goto <OuiChapterSelect>();
         Visible      = false;
         instantClose = false;
         return;
     }
     orig_Update();
 }
Ejemplo n.º 34
0
        public override void Update()
        {
            if (menu != null && menu.Focused &&
                Selected && Input.MenuCancel.Pressed)
            {
                Audio.Play("event:/ui/main/button_back");
                Overworld.Goto <OuiChapterSelect>();
            }

            base.Update();
        }
Ejemplo n.º 35
0
 public Run(Party party, Party partyToAvoid, Overworld overworld)
     : base(party, overworld)
 {
 }
Ejemplo n.º 36
0
 public Wander(Party party, Overworld overworld)
     : base(party, overworld)
 {
     thinkTime = 0.0f;
     destination = entity.Position;
 }
Ejemplo n.º 37
0
        private void Erode(int width, int height, float seaLevel, Overworld.MapData[,] heightMap, int numRains, int rainLength, int numRainSamples, float[,] buffer)
        {
            float remaining = 1.0f - Progress.Value - 0.2f;
            float orig = Progress.Value;
            for(int x = 0; x < width; x++)
            {
                for(int y = 0; y < height; y++)
                {
                    buffer[x, y] = heightMap[x, y].Height;
                }
            }

            for(int i = 0; i < numRains; i++)
            {
                LoadingMessage = "Erosion " + i + "/" + numRains;
                Progress.Value = orig + remaining * ((float) i / (float) numRains);
                Vector2 currentPos = new Vector2(0, 0);
                Vector2 bestPos = currentPos;
                float bestHeight = 0.0f;
                for(int k = 0; k < numRainSamples; k++)
                {
                    int randX = PlayState.Random.Next(1, width - 1);
                    int randY = PlayState.Random.Next(1, height - 1);

                    currentPos = new Vector2(randX, randY);
                    float h = Overworld.GetHeight(buffer, currentPos);

                    if(h > bestHeight)
                    {
                        bestHeight = h;
                        bestPos = currentPos;
                    }
                }

                currentPos = bestPos;

                const float erosionRate = 0.99f;
                Vector2 velocity = Vector2.Zero;
                for(int j = 0; j < rainLength; j++)
                {
                    Vector2 g = Overworld.GetMinNeighbor(buffer, currentPos);

                    float h = Overworld.GetHeight(buffer, currentPos);

                    if(h < seaLevel|| g.LengthSquared() < 1e-12)
                    {
                        break;
                    }

                    Overworld.MinBlend(Overworld.Map, currentPos, erosionRate * Overworld.GetValue(Overworld.Map, currentPos, Overworld.ScalarFieldType.Erosion), Overworld.ScalarFieldType.Erosion);

                    velocity = 0.1f * g + 0.7f * velocity + 0.2f * MathFunctions.RandVector2Circle();
                    currentPos += velocity;
                }
            }
        }
Ejemplo n.º 38
0
        private static void ScaleMap(Overworld.MapData[,] map, int width, int height, Overworld.ScalarFieldType fieldType)
        {
            float min = 99999;
            float max = -99999;

            for(int x = 0; x < width; x++)
            {
                for(int y = 0; y < height; y++)
                {
                    float v = map[x, y].GetValue(fieldType);
                    if(v < min)
                    {
                        min = v;
                    }

                    if(v > max)
                    {
                        max = v;
                    }
                }
            }

            for(int x = 0; x < width; x++)
            {
                for(int y = 0; y < height; y++)
                {
                    float v = map[x, y].GetValue(fieldType);
                    map[x, y].SetValue(fieldType, ((v - min) / (max - min)) + 0.001f);
                }
            }
        }
Ejemplo n.º 39
0
        public void SeedCivs(Overworld.MapData[,] map, int numCivs, List<Faction> civs )
        {
            for (int i = 0; i < numCivs; i++)
            {
                Point? randomPoint = GetRandomLandPoint(map);

                if (randomPoint == null) continue;
                else
                {
                    map[randomPoint.Value.X, randomPoint.Value.Y].Faction = (byte)(i + 1);
                    civs[i].StartingPlace = randomPoint.Value;
                }
            }
        }
Ejemplo n.º 40
0
        public void GrowCivs(Overworld.MapData[,] map, int iters, List<Faction> civs)
        {
            int width = map.GetLength(0);
            int height = map.GetLength(1);
            byte[] neighbors = new byte[] {0, 0, 0, 0};
            float[] neighborheights = new float[] { 0, 0, 0, 0};
            Point[] deltas = new Point[] { new Point(1, 0), new Point(0, 1), new Point(-1, 0), new Point(1, -1) };
            for (int i = 0; i < iters; i++)
            {
                for (int x = 1; x < width - 1; x++)
                {
                    for (int y = 1; y < height - 1; y++)
                    {
                        bool isUnclaimed = map[x, y].Faction == 0;
                        bool isWater = map[x, y].Height < Settings.SeaLevel;
                        if (!isUnclaimed && !isWater)
                        {
                            neighbors[0] = map[x + 1, y].Faction;
                            neighbors[1] = map[x, y + 1].Faction;
                            neighbors[2] = map[x - 1, y].Faction;
                            neighbors[3] = map[x, y - 1].Faction;
                            neighborheights[0] = map[x + 1, y].Height;
                            neighborheights[1] = map[x, y + 1].Height;
                            neighborheights[2] = map[x - 1, y].Height;
                            neighborheights[3] = map[x, y - 1].Height;

                            int minNeighbor = -1;
                            float minHeight = float.MaxValue;

                            for (int k = 0; k < 4; k++)
                            {
                                if (neighbors[k] == 0 && neighborheights[k] < minHeight && neighborheights[k] > Settings.SeaLevel)
                                {
                                    minHeight = neighborheights[k];
                                    minNeighbor = k;
                                }
                            }

                            if (minNeighbor >= 0 && MathFunctions.RandEvent(0.25f / (neighborheights[minNeighbor] + 1e-2f)))
                            {
                                map[x + deltas[minNeighbor].X, y + deltas[minNeighbor].Y].Faction = map[x, y].Faction;
                            }
                        }
                    }
                }
            }

            for (int x = 1; x < width - 1; x++)
            {
                for (int y = 1; y < height - 1; y++)
                {
                    byte f = map[x, y].Faction;
                    if (f> 0)
                    {
                        civs[f - 1].Center = new Point(x + civs[f - 1].Center.X, y + civs[f - 1].Center.Y);
                        civs[f - 1].TerritorySize++;
                    }
                }
            }

            foreach (Faction f in civs)
            {
                if(f.TerritorySize > 0)
                    f.Center = new Point(f.Center.X / f.TerritorySize, f.Center.Y / f.TerritorySize);
            }
        }
Ejemplo n.º 41
0
        public Point? GetRandomLandPoint(Overworld.MapData[,] map)
        {
            const int maxIters = 1000;
            int i = 0;
            int width = map.GetLength(0);
            int height = map.GetLength(1);
            while (i < maxIters)
            {
                int x = PlayState.Random.Next(0, width);
                int y = PlayState.Random.Next(0, height);

                if (map[x, y].Height > Settings.SeaLevel)
                {
                    return new Point(x, y);
                }

                i++;
            }

            return null;
        }
Ejemplo n.º 42
0
 public Follow(Party party, Party partyToFollow, Overworld overworld)
     : base(party, overworld)
 {
 }
Ejemplo n.º 43
0
 public Play(Overworld overworld)
     : base(overworld)
 {
     npcMovers = new List<NpcMover>();
 }