public void SetSprite(Vector2 position, MTexture mTexture, Color color) { this.renderer.sprite = mTexture.USprite; this.renderer.color = color; this.transform.localPosition = new Vector3(position.x, position.y, 0) + new Vector3(mTexture.Offset.x, mTexture.Offset.y, 0); }
/// <summary> /// Override the given MTexutre with the given VirtualTexture and parameters. /// </summary> public static void SetOverride(this MTexture self, VirtualTexture texture, Vector2 drawOffset, int frameWidth, int frameHeight) => ((patch_MTexture)self).SetOverride(texture, drawOffset, frameWidth, frameHeight);
/// <summary> /// Undo the given override applied to the given MTexture. /// </summary> public static void UndoOverride(this MTexture self, ModAsset asset) => ((patch_MTexture)self).UndoOverride(asset);
public override void Render() { GameplayRenderer.End(); // render the edges of the lava rect. if (dirty) { Vector2 zero = Vector2.Zero; Vector2 topLeft = zero; Vector2 topRight = new Vector2(zero.X + Width, zero.Y); Vector2 bottomLeft = new Vector2(zero.X, zero.Y + Height); Vector2 bottomRight = zero + new Vector2(Width, Height); Vector2 fadeOffset = new Vector2(Math.Min(Fade, Width / 2f), Math.Min(Fade, Height / 2f)); vertCount = 0; if (OnlyMode == OnlyModes.OnlyLeft) { Edge(ref vertCount, topRight, bottomRight, fadeOffset.X); Quad(ref vertCount, topLeft, topRight - new Vector2(fadeOffset.X, 0f), bottomRight - new Vector2(fadeOffset.X, 0f), bottomLeft, CenterColor); } else if (OnlyMode == OnlyModes.OnlyRight) { Edge(ref vertCount, bottomLeft, topLeft, fadeOffset.X); Quad(ref vertCount, topLeft + new Vector2(fadeOffset.X, 0f), topRight, bottomRight, bottomLeft + new Vector2(fadeOffset.X, 0f), CenterColor); } dirty = false; } // render the vertices Camera camera = (Scene as Level).Camera; GFX.DrawVertices(Matrix.CreateTranslation(new Vector3(Entity.Position + Position, 0f)) * camera.Matrix, verts, vertCount); GameplayRenderer.Begin(); Vector2 rectPosition = Entity.Position + Position; // render bubbles MTexture bubbleTexture = GFX.Game["particles/bubble"]; for (int i = 0; i < bubbles.Length; i++) { bubbleTexture.DrawCentered(rectPosition + bubbles[i].Position, SurfaceColor * bubbles[i].Alpha); } // render surface bubbles for (int j = 0; j < surfaceBubbles.Length; j++) { if (surfaceBubbles[j].Y >= 0f) { MTexture surfaceBubbleTexture = surfaceBubbleAnimations[surfaceBubbles[j].Animation][(int)surfaceBubbles[j].Frame]; int bubbleOffset = (int)(surfaceBubbles[j].Y / SurfaceStep); float x; if (OnlyMode == OnlyModes.OnlyLeft) { x = Width + 7f + Wave(bubbleOffset, Height); } else { x = 1f - Wave(bubbleOffset, Height); } surfaceBubbleTexture.DrawJustified(rectPosition + new Vector2(x, OnlyMode == OnlyModes.OnlyRight ? Height - bubbleOffset * SurfaceStep : bubbleOffset * SurfaceStep), new Vector2(1f, 0.5f), SurfaceColor); } } }
public static void SetAtlas(this MTexture self, Atlas atlas) => ((patch_MTexture)self).Atlas = atlas;
/// <summary> /// Determine if the MTexture depicts a region of a larger VirtualTexture. /// </summary> /// <param name="input">The input texture.</param> /// <returns>True if the ClipRect is a subregion of the MTexture's VirtualTexture's Texture2D, false otherwise.</returns> public static bool IsSubtexture(this MTexture input) => input.ClipRect.X != 0 || input.ClipRect.Y != 0 || input.ClipRect.Width != input.Texture.Texture.Width || input.ClipRect.Height != input.Texture.Texture.Height;
public override void Awake(Scene scene) { if (animationDelay > 0f) { for (int i = 0; i < lines; i++) { Sprite jumpthruSprite = new Sprite(GFX.Game, "objects/jumpthru/" + overrideTexture); jumpthruSprite.AddLoop("idle", "", animationDelay); jumpthruSprite.Y = i * 8; jumpthruSprite.Rotation = (float)(Math.PI / 2); if (AllowLeftToRight) { jumpthruSprite.X = 8; } else { jumpthruSprite.Scale.Y = -1; } jumpthruSprite.Play("idle"); Add(jumpthruSprite); } } else { AreaData areaData = AreaData.Get(scene); string jumpthru = areaData.Jumpthru; if (!string.IsNullOrEmpty(overrideTexture) && !overrideTexture.Equals("default")) { jumpthru = overrideTexture; } MTexture mTexture = GFX.Game["objects/jumpthru/" + jumpthru]; int num = mTexture.Width / 8; for (int i = 0; i < lines; i++) { int xTilePosition; int yTilePosition; if (i == 0) { xTilePosition = 0; yTilePosition = ((!CollideCheck <Solid>(Position + new Vector2(0f, -1f))) ? 1 : 0); } else if (i == lines - 1) { xTilePosition = num - 1; yTilePosition = ((!CollideCheck <Solid>(Position + new Vector2(0f, 1f))) ? 1 : 0); } else { xTilePosition = 1 + Calc.Random.Next(num - 2); yTilePosition = Calc.Random.Choose(0, 1); } Image image = new Image(mTexture.GetSubtexture(xTilePosition * 8, yTilePosition * 8, 8, 8)); image.Y = i * 8; image.Rotation = (float)(Math.PI / 2); if (AllowLeftToRight) { image.X = 8; } else { image.Scale.Y = -1; } Add(image); } } }
public Fan(Vector2 position, float width, float height, Directions direction, string activationId, bool startActive) : base(position, width, height, false) { Add(Activator = new FactoryActivator()); Activator.ActivationId = activationId != string.Empty ? activationId : null; Activator.StartOn = startActive; Activator.OnTurnOn = () => { _speedingUp = true; }; Activator.OnTurnOff = () => { _speedingUp = false; }; Activator.OnStartOff = () => { _percent = 0f; _speedingUp = false; }; Activator.OnStartOn = () => { _percent = 1f; _speedingUp = true; }; Add(new SteamCollider(OnSteamWall)); Add(_fanSprite = FactoryHelperModule.SpriteBank.Create("fan")); _fanSprite.CenterOrigin(); _fanSprite.Position = new Vector2(width / 2, height / 2); switch (direction) { default: case Directions.Horizontal: _fanSprite.Scale.X = width / 24f; break; case Directions.Vertical: _fanSprite.Scale.X = height / 24f; _fanSprite.Rotation = (float)Math.PI / 2; break; } _fanSprite.Play("rotating", true); MTexture mTexture = GFX.Game["objects/FactoryHelper/fan/body0"]; int size = (int)Math.Max(width, height); for (int i = 0; i < size; i += 8) { int x; Image image; if (i == 0) { x = 0; } else if (i == size - 8) { x = 2; } else { x = 1; } Add(image = new Image(mTexture.GetSubtexture(x * 8, 0, 8, 16))); switch (direction) { default: case Directions.Horizontal: image.X = i; break; case Directions.Vertical: image.Rotation = (float)Math.PI / 2; image.Y = i; image.X += 16; break; } } SurfaceSoundIndex = 7; Add(new LightOcclude(0.5f)); }
/// <summary> /// Sets the parent texture of the given MTexture. /// </summary> public static void SetParent(this MTexture self, MTexture parent) => ((patch_MTexture)self).Parent = (patch_MTexture)parent;
public override void Update() { orig_Update(); // Slightly dirty place to perform this, but oh well... if (CoreModule.Settings.QuickRestart != null) { int slot = CoreModule.Settings.QuickRestart.Value; CoreModule.Settings.QuickRestart = null; CoreModule.Instance.SaveSettings(); SaveData save = UserIO.Load <SaveData>(SaveData.GetFilename(slot)); if (save != null) { SaveData.Start(save, slot); if (slot == -1) { save.DebugMode = true; } if (save.CurrentSession?.InArea ?? false) { LevelEnter.Go(save.CurrentSession, true); } else { Overworld.Goto <OuiChapterSelect>(); } } } if (!updateChecked && Everest.Updater.HasUpdate && Everest.Updater.Newest != null && alpha >= 1f) { updateChecked = true; updateTex = Everest.Updater.Newest.Branch == "stable" ? GFX.Gui["areas/new"] : GFX.Gui["areas/new-yellow"]; Tween tween = Tween.Create(Tween.TweenMode.Oneshot, Ease.CubeInOut, 0.3f, true); tween.OnUpdate = t => { updateAlpha = t.Percent; }; Add(tween); } if (alpha >= 1f && Selected && Input.MenuRight && arrowToVanilla != null && warningMessageMenu == null) { switchingToVanillaBack = Math.Max(0f, switchingToVanillaBack - Engine.DeltaTime * 8f); switchingToVanilla += Engine.DeltaTime; if (switchingToVanilla >= switchingToVanillaDuration && !Everest.RestartVanilla) { if (CoreModule.Settings.RestartIntoVanillaWarningShown) { restartIntoVanilla(); } else { warningMessageMenu = new TextMenu(); Action onCancel = () => { // remove the menu Scene.Remove(warningMessageMenu); warningMessageMenu.Visible = false; warningMessageMenu = null; hideConfirmButton = false; // revert the "switch to vanilla" animation switchingToVanilla = 0f; switchingToVanillaBack = 0f; // fade the vanilla title screen back in alpha = 0f; Tween tween = Tween.Create(Tween.TweenMode.Oneshot, Ease.CubeInOut, 0.6f, start: true); tween.OnUpdate = t => { alpha = t.Percent; textY = MathHelper.Lerp(1200f, 1000f, t.Eased); }; Add(tween); }; warningMessageMenu.OnESC = warningMessageMenu.OnCancel = () => { Audio.Play(SFX.ui_main_button_back); onCancel(); }; warningMessageMenu.Add(new TextMenu.Button(Dialog.Clean("MENU_TITLESCREEN_OK")).Pressed(() => { if (!CoreModule.Settings.RestartIntoVanillaWarningShown) { CoreModule.Settings.RestartIntoVanillaWarningShown = true; CoreModule.Instance.SaveSettings(); } warningMessageMenu.Focused = false; restartIntoVanilla(); })); warningMessageMenu.Add(new TextMenu.Button(Dialog.Clean("MENU_TITLESCREEN_CANCEL")).Pressed(onCancel)); Scene.Add(warningMessageMenu); hideConfirmButton = true; } } } else if (switchingToVanilla < switchingToVanillaDuration) { if (switchingToVanilla > 0f) { switchingToVanillaBack = Math.Max(switchingToVanilla, switchingToVanillaBack); } switchingToVanillaBack = Math.Max(0f, switchingToVanillaBack - Engine.DeltaTime * 4f); switchingToVanilla = 0f; } warningEase = Calc.Approach(warningEase, warningMessageMenu != null ? 1f : 0f, Engine.DeltaTime); }
public override void Render() { if (Everest.Flags.IsDisabled) { orig_Render(); return; } if (CoreModule.Settings.ShowEverestTitleScreen) { logo = everestLogo; title = everestTitle; reflections = everestReflections; } else { logo = vanillaLogo; title = vanillaTitle; reflections = vanillaReflections; } float alphaPrev = alpha; float textYPrev = textY; float switchAlpha = Ease.CubeInOut(Calc.Clamp(Math.Max(switchingToVanilla, switchingToVanillaBack), 0f, 1f)); alpha = Calc.Clamp(alpha - switchAlpha, 0f, 1f); textY += switchAlpha * 200f; orig_Render(); arrowToVanilla?.DrawJustified(new Vector2(1920f - 80f + (textY - 1000f) * 2f, 540f), new Vector2(1f, 0.5f), Color.White * alpha); updateTex?.DrawJustified(new Vector2(80f - 4f, textY + 8f * (1f - updateAlpha) + 2f), new Vector2(1f, 1f), Color.White * updateAlpha, 0.8f); alpha = alphaPrev; textY = textYPrev; if (switchAlpha > 0f) { if (warningMessageMenu != null) { // the restarting message should ease out as the warning message eases in. switchAlpha -= Ease.CubeOut(warningEase); } Draw.Rect(0f, 0f, 1920f, 1080f, Color.Black * switchAlpha); float offs = 40f * (1f - switchAlpha); if (warningMessageMenu != null) { // the restarting message should leave the opposite way it came from. offs *= -1f; } ActiveFont.Draw(Dialog.Clean("MENU_TITLESCREEN_RESTART_VANILLA"), new Vector2(960f + offs, 540f - 4f), new Vector2(0.5f, 1f), Vector2.One, Color.White * switchAlpha); Draw.Rect(960f - 200f + offs, 540f + 4f, 400f, 4f, Color.Black * switchAlpha * switchAlpha); Draw.HollowRect(960f - 200f + offs, 540f + 4f, 400f, 4f, Color.DarkSlateGray * switchAlpha); Draw.Rect(960f - 200f + offs, 540f + 4f, 400f * Calc.Clamp(Math.Max(switchingToVanilla, switchingToVanillaBack) / switchingToVanillaDuration, 0f, 1f), 4f, Color.White * switchAlpha); } if (warningMessageMenu != null) { float warningAlpha = Ease.CubeOut(warningEase); float offs = 40f * (1f - warningAlpha); warningMessageMenu.Position = new Vector2(960f + offs, 735f); warningMessageMenu.Alpha = warningAlpha; ActiveFont.Draw(Dialog.Clean("MENU_TITLESCREEN_WARNING"), new Vector2(960f + offs, 285f), new Vector2(0.5f, 0f), Vector2.One * 1.2f, Color.OrangeRed * warningAlpha); ActiveFont.Draw(Dialog.Clean("MENU_TITLESCREEN_WARNING_TEXT"), new Vector2(960f + offs, 385f), new Vector2(0.5f, 0f), Vector2.One * 0.8f, Color.White * warningAlpha); ActiveFont.Draw(Dialog.Clean("MENU_TITLESCREEN_WARNING_TEXT2"), new Vector2(960f + offs, 510f), new Vector2(0.5f, 0f), Vector2.One * 0.8f, Color.White * warningAlpha); } }
/// <summary> /// Register an emoji. /// </summary> /// <param name="name">The emoji name.</param> /// <param name="emoji">The emoji texture.</param> public static void Register(string name, MTexture emoji) { Register(name, emoji, ((patch_MTexture)emoji)?.ScaleFix ?? 1f); }
private void Render(On.Celeste.SpeedrunTimerDisplay.orig_Render orig, SpeedrunTimerDisplay self) { SpeedrunToolSettings settings = SpeedrunToolModule.Settings; if (!settings.Enabled || settings.RoomTimerType == RoomTimerType.Off) { if (OriginalSpeedrunType != null) { Settings.Instance.SpeedrunClock = (SpeedrunType)OriginalSpeedrunType; } orig(self); return; } // 强制显示时间 Settings.Instance.SpeedrunClock = SpeedrunType.File; RoomTimerType roomTimeType = SpeedrunToolModule.Settings.RoomTimerType; RoomTimerData roomTimerData = roomTimeType == RoomTimerType.NextRoom ? nextRoomTimerData : currentRoomTimerData; string roomTimeString = roomTimerData.TimeString; string pbTimeString = roomTimerData.PbTimeString; pbTimeString = "PB " + pbTimeString; const float topBlackBarWidth = 32f; const float topTimeHeight = 38f; const float pbWidth = 100; const float timeMarginLeft = 32f; const float pbScale = 0.6f; MTexture bg = GFX.Gui["strawberryCountBG"]; float x = -300f * Ease.CubeIn(1f - self.DrawLerp); Draw.Rect(x, self.Y, topBlackBarWidth + 2, topTimeHeight, Color.Black); bg.Draw(new Vector2(x + topBlackBarWidth, self.Y)); float roomTimeScale = 1f; if (roomTimerData.IsCompleted) { Wiggler wiggler = (Wiggler)self.GetField("wiggler"); if (wiggler != null) { roomTimeScale = 1f + wiggler.Value * 0.15f; } } SpeedrunTimerDisplay.DrawTime(new Vector2(x + timeMarginLeft, self.Y + 44f), roomTimeString, roomTimeScale, true, roomTimerData.IsCompleted, roomTimerData.BeatBestTime); if (roomTimerData.IsCompleted) { string comparePbString = ComparePb(roomTimerData.Time, roomTimerData.LastPbTime); DrawTime( new Vector2(x + timeMarginLeft + SpeedrunTimerDisplay.GetTimeWidth(roomTimeString) + 10, self.Y + 36f), comparePbString, 0.5f, true, roomTimerData.IsCompleted, roomTimerData.BeatBestTime); } // 遮住上下两块的间隙,游戏原本的问题 Draw.Rect(x, self.Y + topTimeHeight - 1, pbWidth + bg.Width * pbScale, 1f, Color.Black); Draw.Rect(x, self.Y + topTimeHeight, pbWidth + 2, bg.Height * pbScale + 1f, Color.Black); bg.Draw(new Vector2(x + pbWidth, self.Y + topTimeHeight), Vector2.Zero, Color.White, pbScale); DrawTime(new Vector2(x + timeMarginLeft, (float)(self.Y + 66.4)), pbTimeString, pbScale, true, false, false, 0.6f); }
/// <summary> /// Dump the given asset into an user-friendly and mod-compatible format. /// </summary> /// <param name="assetNameFull">The "full name" of the asset, preferable the relative asset path.</param> /// <param name="asset">The asset to process.</param> public static void Dump(string assetNameFull, object asset) { string assetName = assetNameFull; if (assetName.StartsWith(PathContentOrig)) { assetName = assetName.Substring(PathContentOrig.Length + 1); } else if (File.Exists(assetName)) { return; // Don't dump absolutely loaded files. } string pathDump = Path.Combine(PathDUMP, assetName); Directory.CreateDirectory(Path.GetDirectoryName(pathDump)); if (asset is IMeta) { if (!File.Exists(pathDump + ".meta.yaml")) { using (Stream stream = File.OpenWrite(pathDump + ".meta.yaml")) using (StreamWriter writer = new StreamWriter(stream)) YamlHelper.Serializer.Serialize(writer, asset, asset.GetType()); } } else if (asset is Texture2D) { Texture2D tex = (Texture2D)asset; if (!File.Exists(pathDump + ".png")) { using (Stream stream = File.OpenWrite(pathDump + ".png")) tex.SaveAsPng(stream, tex.Width, tex.Height); } } else if (asset is VirtualTexture) { VirtualTexture tex = (VirtualTexture)asset; Dump(assetName, tex.Texture); } else if (asset is MTexture) { MTexture tex = (MTexture)asset; // Always copy even if !.IsSubtexture() as we need to Postdivide() using (Texture2D region = tex.GetSubtextureCopy().Postdivide()) Dump(assetName, region); if (tex.DrawOffset.X != 0 || tex.DrawOffset.Y != 0 || tex.Width != tex.ClipRect.Width || tex.Height != tex.ClipRect.Height ) { Dump(assetName, new MTextureMeta { X = (int)Math.Round(tex.DrawOffset.X), Y = (int)Math.Round(tex.DrawOffset.Y), Width = tex.Width, Height = tex.Height }); } } else if (asset is Atlas) { Atlas atlas = (Atlas)asset; /* * for (int i = 0; i < atlas.Sources.Count; i++) { * VirtualTexture source = atlas.Sources[i]; * string name = source.Name; * * if (name.StartsWith(assetNameFull)) * name = assetName + "_s_" + name.Substring(assetNameFull.Length); * else * name = Path.Combine(assetName + "_s", name); * if (name.EndsWith(".data") || name.EndsWith(".meta")) * name = name.Substring(0, name.Length - 5); * * Dump(name, source); * } */ Dictionary <string, MTexture> textures = atlas.GetTextures(); foreach (KeyValuePair <string, MTexture> kvp in textures) { string name = kvp.Key; MTexture source = kvp.Value; Dump(Path.Combine(assetName, name.Replace('/', Path.DirectorySeparatorChar)), source); } } // TODO: Dump more asset types if required. }
public TileButton(int id, Vector2 offset, Vector2 size, Vector2 scale, MTexture sel, MTexture unsel, bool selectable, bool blockClickThrough) : base(offset, size, scale, unsel, selectable, blockClickThrough) { this.id = id; this.selected = sel; this.unselected = unsel; }
private void BeforeRender() { List <Entity> glassBlocks = Scene.Tracker.GetEntities <CustomizableGlassBlock>(); hasBlocks = (glassBlocks.Count > 0); if (!hasBlocks) { return; } Camera camera = (Scene as Level).Camera; int screenWidth = 320; int screenHeight = 180; // draw stars if (starsTarget == null) { starsTarget = VirtualContent.CreateRenderTarget("customizable-glass-block-surfaces", screenWidth, screenHeight); } Engine.Graphics.GraphicsDevice.SetRenderTarget(starsTarget); Engine.Graphics.GraphicsDevice.Clear(Color.Transparent); Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone, null, Matrix.Identity); Vector2 origin = new Vector2(8f, 8f); for (int i = 0; i < stars.Length; i++) { MTexture starTexture = stars[i].Texture; Color starColor = stars[i].Color * alpha; Vector2 starScroll = stars[i].Scroll; Vector2 starActualPosition = default; starActualPosition.X = Mod(stars[i].Position.X - camera.X * (1f - starScroll.X), screenWidth); starActualPosition.Y = Mod(stars[i].Position.Y - camera.Y * (1f - starScroll.Y), screenHeight); starTexture.Draw(starActualPosition, origin, starColor); if (starActualPosition.X < origin.X) { starTexture.Draw(starActualPosition + new Vector2(screenWidth, 0f), origin, starColor); } else if (starActualPosition.X > screenWidth - origin.X) { starTexture.Draw(starActualPosition - new Vector2(screenWidth, 0f), origin, starColor); } if (starActualPosition.Y < origin.Y) { starTexture.Draw(starActualPosition + new Vector2(0f, screenHeight), origin, starColor); } else if (starActualPosition.Y > screenHeight - origin.Y) { starTexture.Draw(starActualPosition - new Vector2(0f, screenHeight), origin, starColor); } } Draw.SpriteBatch.End(); // draw rays/beams int vertex = 0; for (int j = 0; j < rays.Length; j++) { Vector2 rayPosition = default; rayPosition.X = Mod(rays[j].Position.X - camera.X * 0.9f, screenWidth); rayPosition.Y = Mod(rays[j].Position.Y - camera.Y * 0.9f, screenHeight); DrawRay(rayPosition, ref vertex, ref rays[j]); if (rayPosition.X < 64f) { DrawRay(rayPosition + new Vector2(screenWidth, 0f), ref vertex, ref rays[j]); } else if (rayPosition.X > (screenWidth - 64)) { DrawRay(rayPosition - new Vector2(screenWidth, 0f), ref vertex, ref rays[j]); } if (rayPosition.Y < 64f) { DrawRay(rayPosition + new Vector2(0f, screenHeight), ref vertex, ref rays[j]); } else if (rayPosition.Y > (screenHeight - 64)) { DrawRay(rayPosition - new Vector2(0f, screenHeight), ref vertex, ref rays[j]); } } if (beamsTarget == null) { beamsTarget = VirtualContent.CreateRenderTarget("customizable-glass-block-beams", screenWidth, screenHeight); } Engine.Graphics.GraphicsDevice.SetRenderTarget(beamsTarget); Engine.Graphics.GraphicsDevice.Clear(Color.Transparent); GFX.DrawVertices(Matrix.Identity, verts, vertex); // if fading in, update the alpha value to fade in in ~0.25 seconds. if (alpha != 1f) { alpha = Calc.Approach(alpha, 1f, Engine.DeltaTime * 4f); } }
private void CreateSprites() { if (!expanded) { Calc.PushRandom(randomSeed); Image image; List <MTexture> atlasSubtextures = GFX.Game.GetAtlasSubtextures(fgDirectory); MTexture mtexture = Calc.Random.Choose(atlasSubtextures); int imgCount = 0; bool c1, c2, c3, c4 = false; c1 = false; c2 = false; c3 = false; if (!SolidCheck(new Vector2(X - 4f, Y - 4f))) { c1 = true; imgCount++; } if (!SolidCheck(new Vector2(X + 4f, Y - 4f))) { c2 = true; imgCount++; } if (!SolidCheck(new Vector2(X + 4f, Y + 4f))) { c3 = true; imgCount++; } if (!SolidCheck(new Vector2(X - 4f, Y + 4f))) { c4 = true; imgCount++; } // technically this solution is twice as fast! Unfortunately it has side-effects that make this not usable /* * image = new Image(mtexture).CenterOrigin(); * image.Color = Calc.HexToColor(tint); * Add(image); */ foreach (Entity entity in Scene.Tracker.GetEntities <CustomSpinner>()) { CustomSpinner crystalStaticSpinner = (CustomSpinner)entity; if (crystalStaticSpinner.ID > ID && crystalStaticSpinner.AttachToSolid == AttachToSolid && (crystalStaticSpinner.Position - Position).LengthSquared() < 576f) { AddSprite((Position + crystalStaticSpinner.Position) / 2f - Position); AddSprite((Position + crystalStaticSpinner.Position) / 2f - Position); } } if (imgCount == 4) { image = new Image(mtexture).CenterOrigin(); image.Color = Tint; Add(image); //image.Visible = false; image.Active = false; //Scene.Add(border = new Border(image, filler, this)); GetBorderRenderer().Spinners.Add(this); } else { // only spawn quarter images if it's needed to avoid edge cases if (c1) { image = new Image(mtexture.GetSubtexture(0, 0, 14, 14, null)).SetOrigin(12f, 12f); image.Color = Tint; Add(image); } if (c2) { image = new Image(mtexture.GetSubtexture(10, 0, 14, 14, null)).SetOrigin(2f, 12f); image.Color = Tint; Add(image); } if (c3) { image = new Image(mtexture.GetSubtexture(10, 10, 14, 14, null)).SetOrigin(2f, 2f); image.Color = Tint; Add(image); } if (c4) { image = new Image(mtexture.GetSubtexture(0, 10, 14, 14, null)).SetOrigin(12f, 2f); image.Color = Tint; Add(image); } //Scene.Add(border = new Border(null, filler, this)); GetBorderRenderer().Spinners.Add(this); } expanded = true; Calc.PopRandom(); } }
public override void Render() { Vector2 position = this.Position; this.Position += base.Shake; Draw.Rect(base.X, base.Y, base.Width, base.Height, Color.Black); int num = 1; float num2 = 0f; int count = this.innerCogs.Count; int num3 = 4; while ((float)num3 <= base.Height - 4f) { int num4 = num; int num5 = 4; while ((float)num5 <= base.Width - 4f) { int index = (int)(this.mod((num2 + (float)num * this.percent * 3.14159274f * 4f) / 1.57079637f, 1f) * (float)count); MTexture mtexture = this.innerCogs[index]; Rectangle rectangle = new Rectangle(0, 0, mtexture.Width, mtexture.Height); Vector2 zero = Vector2.Zero; bool flag = num5 <= 4; if (flag) { zero.X = 2f; rectangle.X = 2; rectangle.Width -= 2; } else { bool flag2 = (float)num5 >= base.Width - 4f; if (flag2) { zero.X = -2f; rectangle.Width -= 2; } } bool flag3 = num3 <= 4; if (flag3) { zero.Y = 2f; rectangle.Y = 2; rectangle.Height -= 2; } else { bool flag4 = (float)num3 >= base.Height - 4f; if (flag4) { zero.Y = -2f; rectangle.Height -= 2; } } mtexture = mtexture.GetSubtexture(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, this.temp); mtexture.DrawCentered(this.Position + new Vector2((float)num5, (float)num3) + zero, Color.White * ((num < 0) ? 0.5f : 1f)); num = -num; num2 += 1.04719758f; num5 += 8; } bool flag5 = num4 == num; if (flag5) { num = -num; } num3 += 8; } int num6 = 0; while ((float)num6 < base.Width / 8f) { int num7 = 0; while ((float)num7 < base.Height / 8f) { int num8 = (num6 == 0) ? 0 : (((float)num6 == base.Width / 8f - 1f) ? 2 : 1); int num9 = (num7 == 0) ? 0 : (((float)num7 == base.Height / 8f - 1f) ? 2 : 1); bool flag6 = num8 != 1 || num9 != 1; if (flag6) { this.edges[num8, num9].Draw(new Vector2(base.X + (float)(num6 * 8), base.Y + (float)(num7 * 8))); } num7++; } num6++; } base.Render(); this.Position = position; }
public FlagSwitchGate(EntityData data, Vector2 offset) : base(data.Position + offset, data.Width, data.Height, safe: false) { isShatter = data.Bool("isShatter", defaultValue: false); if (data.Nodes.Length > 0) { node = data.Nodes[0] + offset; } ID = data.ID; Flag = data.Attr("flag"); inactiveColor = Calc.HexToColor(data.Attr("inactiveColor", "5FCDE4")); activeColor = Calc.HexToColor(data.Attr("activeColor", "FFFFFF")); finishColor = Calc.HexToColor(data.Attr("finishColor", "F141DF")); shakeTime = data.Float("shakeTime", 0.5f); moveTime = data.Float("moveTime", 1.8f); moveEased = data.Bool("moveEased", true); moveSound = data.Attr("moveSound", "event:/game/general/touchswitch_gate_open"); finishedSound = data.Attr("finishedSound", "event:/game/general/touchswitch_gate_finish"); allowReturn = data.Bool("allowReturn", false); P_RecoloredFire = new ParticleType(TouchSwitch.P_Fire) { Color = finishColor }; P_RecoloredFireBack = new ParticleType(TouchSwitch.P_Fire) { Color = inactiveColor }; string iconAttribute = data.Attr("icon", "vanilla"); icon = new Sprite(GFX.Game, iconAttribute == "vanilla" ? "objects/switchgate/icon" : $"objects/MaxHelpingHand/flagSwitchGate/{iconAttribute}/icon"); Add(icon); icon.Add("spin", "", 0.1f, "spin"); icon.Play("spin"); icon.Rate = 0f; icon.Color = inactiveColor; icon.Position = (iconOffset = new Vector2(data.Width / 2f, data.Height / 2f)); icon.CenterOrigin(); Add(wiggler = Wiggler.Create(0.5f, 4f, f => { icon.Scale = Vector2.One * (1f + f); })); blockSpriteName = data.Attr("sprite", "block"); MTexture nineSliceTexture = GFX.Game["objects/switchgate/" + blockSpriteName]; nineSlice = new MTexture[3, 3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { nineSlice[i, j] = nineSliceTexture.GetSubtexture(new Rectangle(i * 8, j * 8, 8, 8)); } } Add(openSfx = new SoundSource()); Add(new LightOcclude(0.5f)); }
public override void Added(Scene scene) { AreaData areaData = AreaData.Get(scene); string crumbleBlock = areaData.CrumbleBlock; if (OverrideTexture != null) { areaData.CrumbleBlock = OverrideTexture; } base.Added(scene); MTexture mTexture = GFX.Game["objects/crumbleBlock/outline"]; outline = new List <Image>(); if (base.Width <= 8f) { Image image = new Image(mTexture.GetSubtexture(24, 0, 8, 8)); image.Color = Color.White * 0f; Add(image); outline.Add(image); } else { for (int i = 0; (float)i < base.Width; i += 8) { int num = (i != 0) ? ((i > 0 && (float)i < base.Width - 8f) ? 1 : 2) : 0; Image image2 = new Image(mTexture.GetSubtexture(num * 8, 0, 8, 8)); image2.Position = new Vector2(i, 0f); image2.Color = Color.White * 0f; Add(image2); outline.Add(image2); } } Add(outlineFader = new Coroutine()); outlineFader.RemoveOnComplete = false; images = new List <Image>(); falls = new List <Coroutine>(); fallOrder = new List <int>(); MTexture mTexture2 = GFX.Game["objects/crumbleBlock/" + AreaData.Get(scene).CrumbleBlock]; for (int j = 0; (float)j < base.Width; j += 8) { int num2 = (int)((Math.Abs(base.X) + (float)j) / 8f) % 4; Image image3 = new Image(mTexture2.GetSubtexture(num2 * 8, 0, 8, 8)); image3.Position = new Vector2(4 + j, 4f); image3.CenterOrigin(); Add(image3); images.Add(image3); Coroutine coroutine = new Coroutine(); coroutine.RemoveOnComplete = false; falls.Add(coroutine); Add(coroutine); fallOrder.Add(j / 8); } fallOrder.Shuffle(); Add(new Coroutine(Sequence())); Add(shaker = new ShakerList(images.Count, false, delegate(Vector2[] v) { for (int k = 0; k < images.Count; k++) { images[k].Position = new Vector2(4 + k * 8, 4f) + v[k]; } })); Add(occluder = new LightOcclude(0.2f)); areaData.CrumbleBlock = crumbleBlock; }
public patch_OuiChapterSelectIcon(int area, MTexture front, MTexture back) : base(area, front, back) { // no-op. MonoMod ignores this - we only need this to make the compiler shut up. }
public override void Added(Scene scene) { base.Added(scene); // read the matching texture if (string.IsNullOrEmpty(overrideTexture)) { overrideTexture = AreaData.Get(scene).WoodPlatform; } MTexture platformTexture = GFX.Game["objects/woodPlatform/" + overrideTexture]; textures = new MTexture[platformTexture.Width / 8]; for (int i = 0; i < textures.Length; i++) { textures[i] = platformTexture.GetSubtexture(i * 8, 0, 8, 8); } // draw lines between all nodes if (Visible || forcedTrackOffset != null) { Vector2 lineOffset = forcedTrackOffset ?? new Vector2(Width, Height + 4f) / 2f; scene.Add(new MovingPlatformLine(nodes[0] + lineOffset, nodes[1] + lineOffset)); if (nodes.Length > 2) { for (int i = 1; i < nodes.Length - 1; i++) { scene.Add(new MovingPlatformLine(nodes[i] + lineOffset, nodes[i + 1] + lineOffset)); } if (mode == Mode.Loop || mode == Mode.LoopNoPause) { scene.Add(new MovingPlatformLine(nodes[nodes.Length - 1] + lineOffset, nodes[0] + lineOffset)); } } } // if count > 1, spawn other platforms to simulate multiple evenly spread platforms. for (int i = 1; i < amount; i++) { // each platform has 1 / amount of offset more than the previous. float newOffset = startingOffset; newOffset += (1f / amount) * i; if (newOffset >= 1f) { newOffset -= 1f; } // copy the entity data and inject the new offset in it. Dictionary <string, object> newEntityProperties = new Dictionary <string, object>(); newEntityProperties.AddRange(entityProperties); newEntityProperties["offset"] = newOffset; // force-set the amount to 1 because the spawned platform should definitely not spawn platforms! newEntityProperties["amount"] = 1; // assemble everything into a new EntityData and build a new platform with it. EntityData data = new EntityData { Position = entityPosition, Nodes = entityNodes, Width = entityWidth, Values = newEntityProperties }; Scene.Add(new MultiNodeMovingPlatform(data, entityOffset, callbackOnAdded) { Visible = Visible }); } callbackOnAdded?.Invoke(this); if (startingOffsetIsNotZero && !moveLater) { updatePosition(); } }
public AutoModUpdater(HiresSnow snow) { this.snow = snow; cogwheel = GFX.Gui["reloader/cogwheel"]; }
private void ColorGradeOnSet_MTexture_MTexture_float(On.Celeste.ColorGrade.orig_Set_MTexture_MTexture_float orig, MTexture fromTex, MTexture toTex, float p) { bool?origEnabled = null; if (Settings.SimplifiedGraphics && Settings.SimplifiedColorGrade) { origEnabled = ColorGrade.Enabled; ColorGrade.Enabled = false; } orig(fromTex, toTex, p); if (origEnabled.HasValue) { ColorGrade.Enabled = origEnabled.Value; } }
public static Atlas GetAtlas(this MTexture self) => ((patch_MTexture)self).Atlas;
public override IEnumerator Enter(Oui from) { // Fix "out of bounds" level selection. GetMinMaxArea(out int areaOffs, out int areaMax); int areaUnclamp = area; area = Calc.Clamp(area, areaOffs, areaMax); Visible = true; EaseCamera(); display = true; currentLevelSet = SaveData.Instance?.GetLevelSet() ?? "Celeste"; journalEnabled = string.IsNullOrEmpty(currentLevelSet) || Celeste.PlayMode == Celeste.PlayModes.Debug || (SaveData.Instance?.CheatMode ?? false); for (int i = 0; i <= SaveData.Instance.UnlockedAreas && !journalEnabled; i++) { if (SaveData.Instance.Areas[i].Modes[0].TimePlayed > 0L && !AreaData.Get(i).Interlude) { journalEnabled = true; } } OuiChapterSelectIcon unselected = null; if (from is OuiChapterPanel) { (unselected = icons[areaUnclamp]).Unselect(); if (areaUnclamp != area) { unselected.Hide(); } } levelSetScarf = GFX.Gui.GetOrDefault("areas/" + currentLevelSet + "/hover", GFX.Gui["areas/hover"]); updateScarf(); bool isVanilla = currentLevelSet == "Celeste"; foreach (OuiChapterSelectIcon icon in icons) { AreaData area = AreaData.Get(icon.Area); if (area == null || area.GetLevelSet() != currentLevelSet) { continue; } int index = area.ToKey().ID; if ((string.IsNullOrEmpty(currentLevelSet) || index <= Math.Max(1, SaveData.Instance.UnlockedAreas)) && icon != unselected) { icon.Position = icon.HiddenPosition; icon.Show(); icon.AssistModeUnlockable = false; } else if (SaveData.Instance.AssistMode && index == SaveData.Instance.UnlockedAreas + 1) { icon.Position = icon.HiddenPosition; icon.Show(); icon.AssistModeUnlockable = true; } if (isVanilla) { yield return(0.01f); } } if (from is OuiChapterPanel) { yield return(0.25f); } }
/// <summary> /// Undo the latest override applied to the given MTexture. /// </summary> public static void UndoOverride(this MTexture self) => ((patch_MTexture)self).UndoOverride();
public MTexture LoadTexFromFile(String name) { return(MTexture.FromFile(name)); }
/// <summary> /// Gets the parent texture of the given MTexture. /// </summary> public static MTexture GetParent(this MTexture self) => ((patch_MTexture)self).Parent;
public void SetSprite(MTexture mTexture) { this.renderer.sprite = mTexture.USprite; this.transform.localPosition = new Vector3(mTexture.Offset.x, mTexture.Offset.y, 0); }