Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into headless
Browse files Browse the repository at this point in the history
  • Loading branch information
psyGamer committed Feb 2, 2025
2 parents e72939f + 41b7e39 commit e79ac94
Show file tree
Hide file tree
Showing 49 changed files with 1,933 additions and 626 deletions.
4 changes: 3 additions & 1 deletion Celeste.Mod.mm/Celeste.Mod.mm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,16 @@
<ProjectReference Include="..\external\MonoMod\src\MonoMod.Utils\MonoMod.Utils.csproj" />
<ProjectReference Include="..\external\MonoMod\src\MonoMod.RuntimeDetour\MonoMod.RuntimeDetour.csproj" />
<ProjectReference Include="..\external\MonoMod\src\MonoMod.RuntimeDetour.HookGen\MonoMod.RuntimeDetour.HookGen.csproj" />
<PackageReference Include="DotNetZip" Version="1.16.0" />
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="YamlDotNet" Version="8.1.2" />
<PackageReference Include="Jdenticon-net" Version="2.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<ProjectReference Include="..\external\NLua\build\net6.0\NLua.net6.0.csproj" />
<PackageReference Include="MAB.DotIgnore" Version="3.0.2" />

<!-- Dependency not used by Everest itself, but kept for mod compatibility reasons -->
<PackageReference Include="DotNetZip" Version="1.16.0" />
</ItemGroup>

<!--
Expand Down
14 changes: 14 additions & 0 deletions Celeste.Mod.mm/Content/Dialog/English.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,20 @@
MODOPTIONS_COREMODULE_DISCORDSHOWBERRIES= Show Berry Count
MODOPTIONS_COREMODULE_DISCORDSHOWDEATHS= Show Death Count
MODOPTIONS_COREMODULE_DISCORDFAILED= Could not connect to Discord. Turn off and back on to retry.

MODOPTIONS_COREMODULE_PSOPTIONS= Everest Photosensitivity Options
MODOPTIONS_COREMODULE_PSOPTIONS_DESC= Allows toggling parts of Photosensitive Mode. Added by Everest.
MODOPTIONS_COREMODULE_PSDISTORT= Anxiety & Distortion Effects
MODOPTIONS_COREMODULE_PSDISTORT_DESC= Controls the distortion effect created by getting near a Seeker.
MODOPTIONS_COREMODULE_PSGLITCH= Glitch Effects
MODOPTIONS_COREMODULE_PSGLITCH_DESC= Controls the glitch effect from the transition to Event Horizon in Farewell.
MODOPTIONS_COREMODULE_PSLIGHTNING= Internal Lightning Flashes
MODOPTIONS_COREMODULE_PSLIGHTNING_DESC= Controls whether the electricity from Farewell will flash on the inside.
MODOPTIONS_COREMODULE_PSSCREENFLASH= Screen Flashes
MODOPTIONS_COREMODULE_PSSCREENFLASH_DESC= Controls whether the screen can flash white, like on activating a core switch.
MODOPTIONS_COREMODULE_PSTEXTHIGHLIGHT= Text Highlighting
MODOPTIONS_COREMODULE_PSTEXTHIGHLIGHT_DESC= Controls whether text will flash a different color on select.


MODOPTIONS_COREMODULE_MIRRORPREFERENCES= Use Mirror by Default
MODOPTIONS_COREMODULE_MIRRORPREFERENCES_GB= Disabled
Expand Down
119 changes: 119 additions & 0 deletions Celeste.Mod.mm/Mod/Core/CoreModuleSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using MonoMod;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices;
using YamlDotNet.Serialization;
Expand Down Expand Up @@ -308,6 +309,76 @@ public bool ColorizedLogging {
[SettingIgnore]
public int DebugRCPort { get; set; } = 32270;

public bool PhotosensitiveMode {
get => Settings.Instance.DisableFlashes;
set => Settings.Instance.DisableFlashes = value;
}

[SettingIgnore]
[EditorBrowsable(EditorBrowsableState.Never)]
// This option is exclusively used internally; do not use it in mods. Use AllowDistort instead.
// It needs to be public for YamlDotNet to not have an aneurysm, but it really shouldn't be.
public bool PhotosensitivityDistortOverride { get; set; } = false;

/// <summary>
/// Whether a distortion effect should be rendered, respecting Everest's photosensitivity setting overrides.
/// </summary>
[SettingIgnore]
[YamlIgnore]
public bool AllowDistort => !Settings.Instance.DisableFlashes || PhotosensitivityDistortOverride;

[SettingIgnore]
[EditorBrowsable(EditorBrowsableState.Never)]
// This option is exclusively used internally; do not use it in mods. Use AllowGlitch instead.
// It needs to be public for YamlDotNet to not have an aneurysm, but it really shouldn't be.
public bool PhotosensitivityGlitchOverride { get; set; } = false;

/// <summary>
/// Whether a glitch effect should be rendered, respecting Everest's photosensitivity setting overrides.
/// </summary>
[SettingIgnore]
[YamlIgnore]
public bool AllowGlitch => !Settings.Instance.DisableFlashes || PhotosensitivityGlitchOverride;

[SettingIgnore]
[EditorBrowsable(EditorBrowsableState.Never)]
// This option is exclusively used internally; do not use it in mods. Use AllowLightning instead.
// It needs to be public for YamlDotNet to not have an aneurysm, but it really shouldn't be.
public bool PhotosensitivityLightningOverride { get; set; } = false;

/// <summary>
/// Whether lightning should have internal flashes, respecting Everest's photosensitivity setting overrides.
/// </summary>
[SettingIgnore]
[YamlIgnore]
public bool AllowLightning => !Settings.Instance.DisableFlashes || PhotosensitivityLightningOverride;

[SettingIgnore]
[EditorBrowsable(EditorBrowsableState.Never)]
// This option is exclusively used internally; do not use it in mods. Use AllowScreenFlash instead.
// It needs to be public for YamlDotNet to not have an aneurysm, but it really shouldn't be.
public bool PhotosensitivityScreenFlashOverride { get; set; } = false;

/// <summary>
/// Whether to render a screenwide flash, respecting Everest's photosensitivity setting overrides.
/// </summary>
[SettingIgnore]
[YamlIgnore]
public bool AllowScreenFlash => !Settings.Instance.DisableFlashes || PhotosensitivityScreenFlashOverride;

[SettingIgnore]
[EditorBrowsable(EditorBrowsableState.Never)]
// This option is exclusively used internally; do not use it in mods. Use AllowTextHighlight instead.
// It needs to be public for YamlDotNet to not have an aneurysm, but it really shouldn't be.
public bool PhotosensitivityTextHighlightOverride { get; set; } = false;

/// <summary>
/// Whether text in menus should flash when selected, respecting Everest's photosensitivity setting overrides.
/// </summary>
[SettingIgnore]
[YamlIgnore]
public bool AllowTextHighlight => !Settings.Instance.DisableFlashes || PhotosensitivityTextHighlightOverride;

[SettingIgnore]
public int? QuickRestart { get; set; }

Expand Down Expand Up @@ -612,6 +683,54 @@ public void CreateDiscordRichPresenceEntry(TextMenu menu, bool inGame) {
menu.Add(submenu);
}


// If we want to put the advanced photosensitivity settings in Mod Options, just uncomment this.
// Left in (albeit commented) in case the implementation changes.
/*
public void CreatePhotosensitiveModeEntry(TextMenu menu, bool inGame) {
TextMenu.Item distort = new TextMenu.OnOff(Dialog.Clean("MODOPTIONS_COREMODULE_PSDISTORT"), PhotosensitivityDistortOverride)
.Change(value => {
PhotosensitivityDistortOverride = value;
});
TextMenu.Item glitch = new TextMenu.OnOff(Dialog.Clean("MODOPTIONS_COREMODULE_PSGLITCH"), PhotosensitivityGlitchOverride)
.Change(value => {
PhotosensitivityGlitchOverride = value;
});
TextMenu.Item lightning = new TextMenu.OnOff(Dialog.Clean("MODOPTIONS_COREMODULE_PSLIGHTNING"), PhotosensitivityLightningOverride)
.Change(value => {
PhotosensitivityLightningOverride = value;
});
TextMenu.Item screenFlash = new TextMenu.OnOff(Dialog.Clean("MODOPTIONS_COREMODULE_PSSCREENFLASH"), PhotosensitivityScreenFlashOverride)
.Change(value => {
PhotosensitivityScreenFlashOverride = value;
});
TextMenu.Item textHighlight = new TextMenu.OnOff(Dialog.Clean("MODOPTIONS_COREMODULE_PSTEXTHIGHLIGHT"), PhotosensitivityTextHighlightOverride)
.Change(value => {
PhotosensitivityTextHighlightOverride = value;
});
TextMenuExt.SubMenu submenu = new TextMenuExt.SubMenu(Dialog.Clean("MODOPTIONS_COREMODULE_PSOPTIONS"), false)
.Add(distort)
.Add(glitch)
.Add(lightning)
.Add(screenFlash)
.Add(textHighlight);
TextMenu.Item masterSwitch = new TextMenu.OnOff(Dialog.Clean("OPTIONS_DISABLE_FLASH"), PhotosensitiveMode)
.Change(value => {
PhotosensitiveMode = value;
submenu.Disabled = !value;
});
menu.Add(masterSwitch);
menu.Add(submenu);
} */

public void CreateMirrorPreferencesEntry(TextMenu menu, bool inGame) {
if (inGame) return;

Expand Down
71 changes: 71 additions & 0 deletions Celeste.Mod.mm/Mod/Entities/EntityCollider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using Monocle;
using System;
using Microsoft.Xna.Framework;

namespace Celeste.Mod.Entities {
/// <summary>
/// Allows for Collision with any type of entity in the game, similar to a PlayerCollider or PufferCollider.
/// Performs the Action provided on collision.
/// </summary>
/// <typeparam name="T">The specific type of Entity this component should try to collide with</typeparam>
public class EntityCollider<T> : Component where T : Entity {
/// <summary>
/// The Action invoked on Collision, with the Entity collided with passed as a parameter
/// </summary>
public Action<T> OnEntityAction;

public Collider Collider;

public EntityCollider(Action<T> onEntityAction, Collider collider = null)
: base(active: true, visible: true) {
OnEntityAction = onEntityAction;
Collider = collider;
}

public override void Added(Entity entity) {
base.Added(entity);
//Only called if Component is added post Scene Begin and Entity Adding and Awake time.
if (Scene != null) {
if (!Scene.Tracker.IsEntityTracked<T>()) {
patch_Tracker.AddTypeToTracker(typeof(T));
}
patch_Tracker.Refresh(Scene);
}
}

public override void EntityAdded(Scene scene) {
if (!scene.Tracker.IsEntityTracked<T>()) {
patch_Tracker.AddTypeToTracker(typeof(T));
}
base.EntityAdded(scene);
}

public override void EntityAwake() {
patch_Tracker.Refresh(Scene);
}

public override void Update() {
if (OnEntityAction == null) {
return;
}

Collider collider = Entity.Collider;
if (Collider != null) {
Entity.Collider = Collider;
}

Entity.CollideDo(OnEntityAction);

Entity.Collider = collider;
}

public override void DebugRender(Camera camera) {
if (Collider != null) {
Collider collider = Entity.Collider;
Entity.Collider = Collider;
Collider.Render(camera, Color.HotPink);
Entity.Collider = collider;
}
}
}
}
72 changes: 72 additions & 0 deletions Celeste.Mod.mm/Mod/Entities/EntityColliderByComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using Monocle;
using System;
using Microsoft.Xna.Framework;

namespace Celeste.Mod.Entities {
/// <summary>
/// Allows for Collision with any type of entity in the game, similar to a PlayerCollider or PufferCollider.
/// Collision is done by component, as in, it will get all the components of the type and try to collide with their entities.
/// Performs the Action provided on collision.
/// </summary>
/// <typeparam name="T">The specific type of Component this component should try to collide with</typeparam>
public class EntityColliderByComponent<T> : Component where T : Component {
/// <summary>
/// The Action invoked on Collision, with the Component collided with passed as a parameter
/// </summary>
public Action<T> OnComponentAction;

public Collider Collider;

public EntityColliderByComponent(Action<T> onComponentAction, Collider collider = null)
: base(active: true, visible: true) {
OnComponentAction = onComponentAction;
Collider = collider;
}

public override void Added(Entity entity) {
base.Added(entity);
//Only called if Component is added post Scene Begin and Entity Adding and Awake time.
if (Scene != null) {
if (!Scene.Tracker.IsComponentTracked<T>()) {
patch_Tracker.AddTypeToTracker(typeof(T));
}
patch_Tracker.Refresh(Scene);
}
}

public override void EntityAdded(Scene scene) {
if (!scene.Tracker.IsComponentTracked<T>()) {
patch_Tracker.AddTypeToTracker(typeof(T));
}
base.EntityAdded(scene);
}

public override void EntityAwake() {
patch_Tracker.Refresh(Scene);
}

public override void Update() {
if (OnComponentAction == null) {
return;
}

Collider collider = Entity.Collider;
if (Collider != null) {
Entity.Collider = Collider;
}

Entity.CollideDoByComponent(OnComponentAction);

Entity.Collider = collider;
}

public override void DebugRender(Camera camera) {
if (Collider != null) {
Collider collider = Entity.Collider;
Entity.Collider = Collider;
Collider.Render(camera, Color.HotPink);
Entity.Collider = collider;
}
}
}
}
Loading

0 comments on commit e79ac94

Please sign in to comment.