Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

didnt feel like making a new branch #77

Merged
merged 3 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Code/FLCC/CustomPuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public enum BoostModes
private bool legacyBoost = true;
private bool absoluteVector = false;
private bool launchState = true;
private bool renderEye = true;

public CustomPuffer(Vector2 position, bool faceRight, float angle = 0f, float radius = 32f, float launchSpeed = 280f, string spriteName = "pufferFish")
: base(position)
Expand Down Expand Up @@ -136,6 +137,7 @@ public CustomPuffer(EntityData data, Vector2 offset, EntityID id)
legacyBoost = data.Bool("legacyBoost", true);
absoluteVector = data.Bool("absoluteVector", false);
launchState = data.Bool("setLaunchState", true);
renderEye = data.Bool("renderEye", true);

if (data.Bool("holdable"))
{
Expand Down Expand Up @@ -494,7 +496,7 @@ public override void Render()
}
}
base.Render();
if (!isHappy && sprite.CurrentAnimationID == "alerted")
if (renderEye && !isHappy && sprite.CurrentAnimationID == "alerted")
{
Vector2 vector3 = Position + new Vector2(3f, (Facing.X < 0f) ? (-5) : (-4)) * sprite.Scale;
Vector2 to = lastPlayerPos + new Vector2(0f, -4f);
Expand Down Expand Up @@ -733,7 +735,7 @@ private void OnPlayer(Player player)
{
return;
}
if (Hold != null && Input.Grab.Check && !player.Ducking && !player.IsTired)
if (Hold != null && Input.Grab.Check && !player.Ducking && !player.IsTired && (player.Holding == null))
return;
if (cannotHitTimer <= 0f)
{
Expand Down
44 changes: 44 additions & 0 deletions Code/TriggerTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using FMOD;
using Microsoft.Xna.Framework;
using Monocle;
using MonoMod.Cil;
using System;
using System.Collections;
using System.Collections.Generic;
Expand All @@ -16,12 +17,14 @@ public static void Load() {
On.Celeste.Level.LoadLevel += Level_LoadLevel;
On.Celeste.Player.Jump += Player_Jump;
On.Celeste.PlayerCollider.Check += PlayerCollider_Check;
IL.Monocle.Engine.Update += Engine_Update;
}

public static void Unload() {
On.Celeste.Level.LoadLevel -= Level_LoadLevel;
On.Celeste.Player.Jump -= Player_Jump;
On.Celeste.PlayerCollider.Check -= PlayerCollider_Check;
IL.Monocle.Engine.Update -= Engine_Update;
}

private static readonly HashSet<Entity> collidedEntities = new();
Expand Down Expand Up @@ -67,7 +70,9 @@ public TriggerTrigger(EntityData data, Vector2 offset) : base(data, offset) {
break;
}
}
excludeTalkers = data.Bool("excludeTalkers", false);
ifSafe = data.Bool("onlyIfSafe", false);
includeCoyote = data.Bool("includeCoyote", false);
playerState = data.Int("playerState", 0);
if (string.IsNullOrEmpty(data.Attr("entityType", ""))) {
collideType = data.Attr("entityTypeToCollide", "Celeste.Strawberry");
Expand Down Expand Up @@ -320,6 +325,8 @@ public bool GetActivateCondition(Player player) {
result = player.OnGround();
if (ifSafe)
result &= player.OnSafeGround;
if (includeCoyote)
result |= player.jumpGraceTimer > 0f;
break;
case ActivationTypes.OnPlayerState:
result = player.StateMachine.State == playerState;
Expand All @@ -330,6 +337,11 @@ public bool GetActivateCondition(Player player) {
}
if (externalActivation) {
result = true;
if (resetActivation)
{
externalActivation = false;
resetActivation = false;
}
}
if (invertCondition) {
result = !result;
Expand Down Expand Up @@ -462,6 +474,10 @@ private bool CheckInput(InputTypes inputType, bool held) {
case InputTypes.Dash:
return (held ? Input.Dash.Check : Input.Dash.Pressed);
case InputTypes.Interact:
if (excludeTalkers && TalkComponent.PlayerOver != null)
{
return false;
}
return (held ? Input.Talk.Check : Input.Talk.Pressed);
case InputTypes.CrouchDash:
return (held ? Input.CrouchDash.Check : Input.CrouchDash.Pressed);
Expand Down Expand Up @@ -532,6 +548,31 @@ private static bool PlayerCollider_Check(On.Celeste.PlayerCollider.orig_Check or
return result;
}

private static void Engine_Update(MonoMod.Cil.ILContext il)
{
// code taken from communal helper's AbstractInputController
// https://github.com/CommunalHelper/CommunalHelper/blob/dev/src/Entities/Misc/AbstractInputController.cs

ILCursor cursor = new(il);
if (cursor.TryGotoNext(instr => instr.MatchLdsfld<Engine>("FreezeTimer"),
instr => instr.MatchCall<Engine>("get_RawDeltaTime")))
{
cursor.EmitDelegate<Action>(UpdateFreezeInput);
}
}

public static void UpdateFreezeInput()
{
foreach (TriggerTrigger trigger in Engine.Scene.Tracker.GetEntities<TriggerTrigger>())
{
if (trigger.activationType == ActivationTypes.OnInput && !trigger.inputHeld && trigger.CheckInput(trigger.inputType, false))
{
trigger.externalActivation = true;
trigger.resetActivation = true;
}
}
}

public bool Global;
public bool Activated;

Expand All @@ -548,12 +589,15 @@ private static bool PlayerCollider_Check(On.Celeste.PlayerCollider.orig_Check or
private Session.CoreModes coreMode;
private InputTypes inputType;
private bool inputHeld;
private bool excludeTalkers;
private bool ifSafe;
private bool includeCoyote;
private int playerState;
private TalkComponent talker;
private List<Entity> entitiesInside;
private string collideSolid;
public bool externalActivation;
public bool resetActivation;
private bool invertCondition;
private ComparisonTypes comparisonType;
private bool absoluteValue;
Expand Down
18 changes: 11 additions & 7 deletions Code/VitModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -597,14 +597,18 @@ private void Level_LoadLevel(On.Celeste.Level.orig_LoadLevel orig, Level self, P
private void Level_Reload(On.Celeste.Level.orig_Reload orig, Level self)
{
orig(self);
CustomWindController customWind = self.Entities.FindFirst<CustomWindController>();
if (customWind != null)
if (!self.Completed)
{
customWind.SnapWind();
}
else
{
self.Wind = Vector2.Zero;
CustomWindController customWind = self.Entities.FindFirst<CustomWindController>();
WindController vanillaWind = self.Entities.FindFirst<WindController>();
if (customWind != null)
{
customWind.SnapWind();
}
else if (vanillaWind == null)
{
self.Wind = Vector2.Zero;
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions Loenn/entities/custom_puffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ customPuffer.placements = {
boostMode = "SetSpeed",
legacyBoost = false,
absoluteVector = false,
renderEye = true,
}
},
{
Expand All @@ -46,6 +47,7 @@ customPuffer.placements = {
boostMode = "SetSpeed",
legacyBoost = false,
absoluteVector = false,
renderEye = true,
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions Loenn/triggers/trigger_trigger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ function triggerTrigger.ignoredFields(entity)
"entityType",
"inputType",
"holdInput",
"excludeTalkers",
"onlyIfSafe",
"playerState",
"includeCoyote"
}

local function doNotIgnore(value)
Expand Down Expand Up @@ -137,8 +139,12 @@ function triggerTrigger.ignoredFields(entity)
elseif atype == "OnInput" then
doNotIgnore("inputType")
doNotIgnore("holdInput")
if entity.inputType == "Interact" then
doNotIgnore("excludeTalkers")
end
elseif atype == "OnGrounded" then
doNotIgnore("onlyIfSafe")
doNotIgnore("includeCoyote")
elseif atype == "OnPlayerState" then
doNotIgnore("playerState")
end
Expand Down Expand Up @@ -180,8 +186,10 @@ for _, mode in pairs(activationTypes) do
entityType = "",
inputType = "Grab",
holdInput = false,
excludeTalkers = false,
onlyIfSafe = false,
playerState = 0,
includeCoyote = false,
}
}
table.insert(triggerTrigger.placements, placement)
Expand Down
2 changes: 1 addition & 1 deletion everest.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- Name: CrystallineHelper
Version: 1.16.3
Version: 1.16.4
DLL: Code/bin/vitmod.dll
Dependencies:
- Name: EverestCore
Expand Down
Loading