Skip to content

Commit 8775116

Browse files
committed
trying out interop and extended variants
1 parent 9b8b5e0 commit 8775116

File tree

6 files changed

+63
-3
lines changed

6 files changed

+63
-3
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using Celeste;
3+
using Celeste.Mod.VinkiMod;
4+
using ExtendedVariants.Module;
5+
using MonoMod.Utils;
6+
using On.Celeste;
7+
8+
namespace ExtendedVariants.Variants;
9+
10+
public class AlwaysPressGraffitiButton : AbstractExtendedVariant
11+
{
12+
public override void Load()
13+
{
14+
VinkiModModule.Session.AlwaysGrafButton=true;
15+
}
16+
17+
public override void Unload()
18+
{
19+
VinkiModModule.Session.AlwaysGrafButton=false;
20+
}
21+
22+
public override Type GetVariantType()
23+
{
24+
return typeof(bool);
25+
}
26+
27+
public override object GetDefaultVariantValue()
28+
{
29+
return false;
30+
}
31+
32+
public override object ConvertLegacyVariantValue(int value)
33+
{
34+
return value != 0;
35+
}
36+
}

Source/VinkiMod.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<ItemGroup>
1515
<Reference Include="./lib/SkinModHelperPlus.dll" Private="false" />
1616
<Reference Include="./lib/Procedurline.dll" Private="false" />
17+
<Reference Include="./lib/ExtendedVariantMode.dll" Private="false" />
1718
<Reference Include="$(CelestePrefix)\YamlDotNet.dll">
1819
<Private>false</Private>
1920
</Reference>

Source/VinkiModInterop.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Celeste.Mod.VinkiMod;
2+
using ExtendedVariants.Variants;
3+
using MonoMod.ModInterop;
4+
using System;
5+
using System.Linq;
6+
7+
namespace VinkiMod.Module {
8+
// A class providing some methods that can be called from Lua cutscenes, by doing:
9+
// local luaCutscenesUtils = require("#ExtendedVariants.Module.LuaCutscenesUtils")
10+
// luaCutscenesUtils.TriggerIntegerVariant(...)
11+
[ModExportName("VinkiMod")]
12+
public static class VinkiModInterop {
13+
public static void AddGraffitiCharacter(string characterID) {
14+
VinkiModModule.graffitiUsers=VinkiModModule.graffitiUsers.Append(characterID).ToArray();
15+
}
16+
}
17+
}

Source/VinkiModModule.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
using Microsoft.Xna.Framework;
1515
using Microsoft.Xna.Framework.Graphics;
1616
using MonoMod.Cil;
17+
using VinkiMod.Module;
1718

1819
namespace Celeste.Mod.VinkiMod;
1920

2021
public class VinkiModModule : EverestModule {
22+
//ExtendedVariants.Module.ExtendedVariantsModule.Variant=ExtendedVariants.Variants.AlwaysPressGraffitiButton;
2123

2224
public static VinkiModModule Instance;// { get; private set; }
2325

@@ -30,6 +32,8 @@ public class VinkiModModule : EverestModule {
3032
public override Type SaveDataType => typeof(VinkiModSaveData);
3133
public static VinkiModSaveData SaveData => (VinkiModSaveData) Instance._SaveData;
3234

35+
public static String[] graffitiUsers = ["Vinki_Scug"];
36+
3337
//but here's the :hunterglee: (the constants)
3438
public static String[] textureNamespaces = [
3539
"scenery/car/body","decals/1-forsakencity/big_sign_b","decals/1-forsakencity/camping_medium","decals/1-forsakencity/hanging_sign","decals/1-forsakencity/big_sign_e",//0-4
@@ -77,6 +81,7 @@ public VinkiModModule() {
7781
}
7882
private static List<ILHook> hooks = new List<ILHook>();
7983
public override void Load() {
84+
typeof(VinkiModInterop).ModInterop();
8085
if (!Settings.MasterSwitch) {
8186
Everest.Events.Level.OnTransitionTo += triggerVinkiGUI1;
8287
Everest.Events.Level.OnEnter += triggerVinkiGUI2;
@@ -172,7 +177,7 @@ public static void vinkiButtonPress(On.Celeste.Player.orig_Update orig, Player s
172177
orig(self);
173178
// Then, the graffiti indicator is turned off.
174179
Session.vinkiRenderIt[0]=0;
175-
if (SkinModHelperModule.GetPlayerSkinName(-1)=="Vinki_Scug") {
180+
if (Array.IndexOf(graffitiUsers,SkinModHelperModule.GetPlayerSkinName(-1))!=-1) {
176181
if (!Session.sessionStuffLoaded) {
177182
if (Array.IndexOf(hasArtSpots,self.SceneAs<Level>().Session.Area.SID+"_"+self.SceneAs<Level>().Session.Area.Mode.ToString())!=-1) {
178183
Session.sessionArtSpots=artSpots[Array.IndexOf(hasArtSpots,self.SceneAs<Level>().Session.Area.SID+"_"+self.SceneAs<Level>().Session.Area.Mode.ToString())];
@@ -200,7 +205,7 @@ public static void vinkiButtonPress(On.Celeste.Player.orig_Update orig, Player s
200205
}
201206
// but here's the graffiti indicator
202207
private static void vinkiRenderer(Level self) {
203-
if (SkinModHelperModule.GetPlayerSkinName(-1)=="Vinki_Scug") {
208+
if (Array.IndexOf(graffitiUsers,SkinModHelperModule.GetPlayerSkinName(-1))!=-1) {
204209
// If Vinki's Skin is enabled, it adds these entities to the level first.
205210
self.Add(new GraffitiIndicator());
206211
// Also, if you're playing Prologue, the intro car's depth is set to 2. (I think.)
@@ -249,7 +254,7 @@ private static void DrawManipulator(ILContext ctx) {
249254
private static MTexture TextureReplacer(MTexture tex) {
250255
var among = -1;
251256
// Check if the player is ingame
252-
if (SaveData!=null&&(SkinModHelperModule.GetPlayerSkinName(-1)=="Vinki_Scug"||Settings.HideIfNotVinki==0)) {
257+
if (SaveData!=null&&(Array.IndexOf(graffitiUsers,SkinModHelperModule.GetPlayerSkinName(-1))!=-1||Settings.HideIfNotVinki==0)) {
253258
// If so, check if the settingsArtChanged.length is equal to or more than textureNamespaces.Length to prevent errors
254259
if (SaveData.settingsArtChanged.Length>=textureNamespaces.Length) {
255260
// If so, check each textureNamespace to see if it's changed in the save data.

Source/VinkiModSession.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ public class VinkiModSession : EverestModuleSession {
66
public int[][] sessionArtSpots = [];
77
public bool sessionStuffLoaded = false;
88
public int[] vinkiRenderIt = [0,0,0,0,-1];
9+
public bool AlwaysGrafButton = false;
910
}

Source/lib/ExtendedVariantMode.dll

327 KB
Binary file not shown.

0 commit comments

Comments
 (0)