Skip to content

Commit c922fab

Browse files
authored
Merge pull request #77 from CommunalHelper/misc-additions
didnt feel like making a new branch
2 parents 6a8f14a + d312939 commit c922fab

File tree

6 files changed

+70
-10
lines changed

6 files changed

+70
-10
lines changed

Code/FLCC/CustomPuffer.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public enum BoostModes
7878
private bool legacyBoost = true;
7979
private bool absoluteVector = false;
8080
private bool launchState = true;
81+
private bool renderEye = true;
8182

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

140142
if (data.Bool("holdable"))
141143
{
@@ -494,7 +496,7 @@ public override void Render()
494496
}
495497
}
496498
base.Render();
497-
if (!isHappy && sprite.CurrentAnimationID == "alerted")
499+
if (renderEye && !isHappy && sprite.CurrentAnimationID == "alerted")
498500
{
499501
Vector2 vector3 = Position + new Vector2(3f, (Facing.X < 0f) ? (-5) : (-4)) * sprite.Scale;
500502
Vector2 to = lastPlayerPos + new Vector2(0f, -4f);
@@ -733,7 +735,7 @@ private void OnPlayer(Player player)
733735
{
734736
return;
735737
}
736-
if (Hold != null && Input.Grab.Check && !player.Ducking && !player.IsTired)
738+
if (Hold != null && Input.Grab.Check && !player.Ducking && !player.IsTired && (player.Holding == null))
737739
return;
738740
if (cannotHitTimer <= 0f)
739741
{

Code/TriggerTrigger.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using FMOD;
44
using Microsoft.Xna.Framework;
55
using Monocle;
6+
using MonoMod.Cil;
67
using System;
78
using System.Collections;
89
using System.Collections.Generic;
@@ -16,12 +17,14 @@ public static void Load() {
1617
On.Celeste.Level.LoadLevel += Level_LoadLevel;
1718
On.Celeste.Player.Jump += Player_Jump;
1819
On.Celeste.PlayerCollider.Check += PlayerCollider_Check;
20+
IL.Monocle.Engine.Update += Engine_Update;
1921
}
2022

2123
public static void Unload() {
2224
On.Celeste.Level.LoadLevel -= Level_LoadLevel;
2325
On.Celeste.Player.Jump -= Player_Jump;
2426
On.Celeste.PlayerCollider.Check -= PlayerCollider_Check;
27+
IL.Monocle.Engine.Update -= Engine_Update;
2528
}
2629

2730
private static readonly HashSet<Entity> collidedEntities = new();
@@ -67,7 +70,9 @@ public TriggerTrigger(EntityData data, Vector2 offset) : base(data, offset) {
6770
break;
6871
}
6972
}
73+
excludeTalkers = data.Bool("excludeTalkers", false);
7074
ifSafe = data.Bool("onlyIfSafe", false);
75+
includeCoyote = data.Bool("includeCoyote", false);
7176
playerState = data.Int("playerState", 0);
7277
if (string.IsNullOrEmpty(data.Attr("entityType", ""))) {
7378
collideType = data.Attr("entityTypeToCollide", "Celeste.Strawberry");
@@ -320,6 +325,8 @@ public bool GetActivateCondition(Player player) {
320325
result = player.OnGround();
321326
if (ifSafe)
322327
result &= player.OnSafeGround;
328+
if (includeCoyote)
329+
result |= player.jumpGraceTimer > 0f;
323330
break;
324331
case ActivationTypes.OnPlayerState:
325332
result = player.StateMachine.State == playerState;
@@ -330,6 +337,11 @@ public bool GetActivateCondition(Player player) {
330337
}
331338
if (externalActivation) {
332339
result = true;
340+
if (resetActivation)
341+
{
342+
externalActivation = false;
343+
resetActivation = false;
344+
}
333345
}
334346
if (invertCondition) {
335347
result = !result;
@@ -462,6 +474,10 @@ private bool CheckInput(InputTypes inputType, bool held) {
462474
case InputTypes.Dash:
463475
return (held ? Input.Dash.Check : Input.Dash.Pressed);
464476
case InputTypes.Interact:
477+
if (excludeTalkers && TalkComponent.PlayerOver != null)
478+
{
479+
return false;
480+
}
465481
return (held ? Input.Talk.Check : Input.Talk.Pressed);
466482
case InputTypes.CrouchDash:
467483
return (held ? Input.CrouchDash.Check : Input.CrouchDash.Pressed);
@@ -532,6 +548,31 @@ private static bool PlayerCollider_Check(On.Celeste.PlayerCollider.orig_Check or
532548
return result;
533549
}
534550

551+
private static void Engine_Update(MonoMod.Cil.ILContext il)
552+
{
553+
// code taken from communal helper's AbstractInputController
554+
// https://github.com/CommunalHelper/CommunalHelper/blob/dev/src/Entities/Misc/AbstractInputController.cs
555+
556+
ILCursor cursor = new(il);
557+
if (cursor.TryGotoNext(instr => instr.MatchLdsfld<Engine>("FreezeTimer"),
558+
instr => instr.MatchCall<Engine>("get_RawDeltaTime")))
559+
{
560+
cursor.EmitDelegate<Action>(UpdateFreezeInput);
561+
}
562+
}
563+
564+
public static void UpdateFreezeInput()
565+
{
566+
foreach (TriggerTrigger trigger in Engine.Scene.Tracker.GetEntities<TriggerTrigger>())
567+
{
568+
if (trigger.activationType == ActivationTypes.OnInput && !trigger.inputHeld && trigger.CheckInput(trigger.inputType, false))
569+
{
570+
trigger.externalActivation = true;
571+
trigger.resetActivation = true;
572+
}
573+
}
574+
}
575+
535576
public bool Global;
536577
public bool Activated;
537578

@@ -548,12 +589,15 @@ private static bool PlayerCollider_Check(On.Celeste.PlayerCollider.orig_Check or
548589
private Session.CoreModes coreMode;
549590
private InputTypes inputType;
550591
private bool inputHeld;
592+
private bool excludeTalkers;
551593
private bool ifSafe;
594+
private bool includeCoyote;
552595
private int playerState;
553596
private TalkComponent talker;
554597
private List<Entity> entitiesInside;
555598
private string collideSolid;
556599
public bool externalActivation;
600+
public bool resetActivation;
557601
private bool invertCondition;
558602
private ComparisonTypes comparisonType;
559603
private bool absoluteValue;

Code/VitModule.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -597,14 +597,18 @@ private void Level_LoadLevel(On.Celeste.Level.orig_LoadLevel orig, Level self, P
597597
private void Level_Reload(On.Celeste.Level.orig_Reload orig, Level self)
598598
{
599599
orig(self);
600-
CustomWindController customWind = self.Entities.FindFirst<CustomWindController>();
601-
if (customWind != null)
600+
if (!self.Completed)
602601
{
603-
customWind.SnapWind();
604-
}
605-
else
606-
{
607-
self.Wind = Vector2.Zero;
602+
CustomWindController customWind = self.Entities.FindFirst<CustomWindController>();
603+
WindController vanillaWind = self.Entities.FindFirst<WindController>();
604+
if (customWind != null)
605+
{
606+
customWind.SnapWind();
607+
}
608+
else if (vanillaWind == null)
609+
{
610+
self.Wind = Vector2.Zero;
611+
}
608612
}
609613
}
610614

Loenn/entities/custom_puffer.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ customPuffer.placements = {
2323
boostMode = "SetSpeed",
2424
legacyBoost = false,
2525
absoluteVector = false,
26+
renderEye = true,
2627
}
2728
},
2829
{
@@ -46,6 +47,7 @@ customPuffer.placements = {
4647
boostMode = "SetSpeed",
4748
legacyBoost = false,
4849
absoluteVector = false,
50+
renderEye = true,
4951
}
5052
}
5153
}

Loenn/triggers/trigger_trigger.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,10 @@ function triggerTrigger.ignoredFields(entity)
9191
"entityType",
9292
"inputType",
9393
"holdInput",
94+
"excludeTalkers",
9495
"onlyIfSafe",
9596
"playerState",
97+
"includeCoyote"
9698
}
9799

98100
local function doNotIgnore(value)
@@ -137,8 +139,12 @@ function triggerTrigger.ignoredFields(entity)
137139
elseif atype == "OnInput" then
138140
doNotIgnore("inputType")
139141
doNotIgnore("holdInput")
142+
if entity.inputType == "Interact" then
143+
doNotIgnore("excludeTalkers")
144+
end
140145
elseif atype == "OnGrounded" then
141146
doNotIgnore("onlyIfSafe")
147+
doNotIgnore("includeCoyote")
142148
elseif atype == "OnPlayerState" then
143149
doNotIgnore("playerState")
144150
end
@@ -180,8 +186,10 @@ for _, mode in pairs(activationTypes) do
180186
entityType = "",
181187
inputType = "Grab",
182188
holdInput = false,
189+
excludeTalkers = false,
183190
onlyIfSafe = false,
184191
playerState = 0,
192+
includeCoyote = false,
185193
}
186194
}
187195
table.insert(triggerTrigger.placements, placement)

everest.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
- Name: CrystallineHelper
2-
Version: 1.16.3
2+
Version: 1.16.4
33
DLL: Code/bin/vitmod.dll
44
Dependencies:
55
- Name: EverestCore

0 commit comments

Comments
 (0)