Skip to content

Commit d43cb56

Browse files
committed
Collab Utils: The Nettening
1 parent 5ea1158 commit d43cb56

22 files changed

+497
-377
lines changed

.github/workflows/autobuild.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
cat DOCUMENTATION.md >> documentation.txt
5252
rm Ahorn/triggers/mapSwapTrigger.jl
5353
ZIPNAME=$ZIPNAME-${GITHUB_SHA:0:8}.zip
54-
zip -qq -r $ZIPNAME everest.yaml bin/Release/net452 Ahorn Graphics Audio Dialog Loenn documentation.txt
54+
zip -qq -r $ZIPNAME everest.yaml bin/CollabUtils2.* Ahorn Graphics Audio Dialog Loenn documentation.txt
5555
url=$(curl -H 'Content-Type: multipart/form-data' -X POST -F "file=@$ZIPNAME" "$DISCORD_WEBHOOK"| jq -r '.attachments[0].url')
5656
msg=$(git log -n 1 "--format=%B" | head -n 1 | tr -d '\n')
5757
curl -H 'Content-Type: application/json' -X POST -d "$(jq -n \

CollabUtils2.csproj

Lines changed: 104 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,108 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFrameworks>net452</TargetFrameworks>
5-
<AssemblyName>CollabUtils2</AssemblyName>
6-
<RootNamespace>Celeste.Mod.CollabUtils2</RootNamespace>
7-
</PropertyGroup>
8-
9-
<ItemGroup>
10-
<PackageReference Include="MonoMod.RuntimeDetour" Version="22.1.4.3" PrivateAssets="all" ExcludeAssets="runtime">
11-
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
12-
</PackageReference>
13-
<PackageReference Include="YamlDotNet" Version="8.1.2" PrivateAssets="all" ExcludeAssets="runtime">
14-
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
15-
</PackageReference>
16-
</ItemGroup>
17-
18-
<ItemGroup>
19-
<Reference Include="CelesteNet.Client">
20-
<HintPath>lib-stripped\CelesteNet.Client.dll</HintPath>
21-
<Private>false</Private>
22-
</Reference>
23-
<Reference Include="CelesteNet.Shared">
24-
<HintPath>lib-stripped\CelesteNet.Shared.dll</HintPath>
25-
<Private>false</Private>
26-
</Reference>
27-
</ItemGroup>
28-
29-
<Choose>
30-
<When Condition="Exists('..\..\Celeste.exe')">
31-
<ItemGroup>
32-
<Reference Include="Celeste" HintPath="..\..\Celeste.exe" Private="false" />
33-
<Reference Include="MMHOOK_Celeste" HintPath="..\..\MMHOOK_Celeste.dll" Private="false" />
34-
</ItemGroup>
35-
36-
<Choose>
37-
<When Condition="'$(OS)' != 'Windows_NT' Or Exists('..\..\FNA.dll')">
38-
<ItemGroup>
39-
<Reference Include="FNA" HintPath="..\..\FNA.dll" Private="false" />
40-
</ItemGroup>
41-
</When>
42-
43-
<Otherwise>
44-
<ItemGroup>
45-
<Reference Include="Microsoft.Xna.Framework" HintPath="$(WINDIR)\Microsoft.NET\assembly\GAC_32\Microsoft.Xna.Framework\v4.0_4.0.0.0__842cf8be1de50553\Microsoft.Xna.Framework.dll" Private="false" />
46-
<Reference Include="Microsoft.Xna.Framework.Game" HintPath="$(WINDIR)\Microsoft.NET\assembly\GAC_32\Microsoft.Xna.Framework.Game\v4.0_4.0.0.0__842cf8be1de50553\Microsoft.Xna.Framework.Game.dll" Private="false" />
47-
<Reference Include="Microsoft.Xna.Framework.Graphics" HintPath="$(WINDIR)\Microsoft.NET\assembly\GAC_32\Microsoft.Xna.Framework.Graphics\v4.0_4.0.0.0__842cf8be1de50553\Microsoft.Xna.Framework.Graphics.dll" Private="false" />
48-
</ItemGroup>
49-
</Otherwise>
50-
</Choose>
51-
</When>
52-
53-
<Otherwise>
54-
<ItemGroup>
55-
<Reference Include="Celeste" HintPath="lib-stripped\Celeste.exe" Private="false" />
56-
<Reference Include="MMHOOK_Celeste" HintPath="lib-stripped\MMHOOK_Celeste.dll" Private="false" />
57-
<Reference Include="FNA" HintPath="lib-stripped\FNA.dll" Private="false" />
58-
</ItemGroup>
59-
</Otherwise>
60-
</Choose>
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<AssemblyName>CollabUtils2</AssemblyName>
6+
<RootNamespace>Celeste.Mod.CollabUtils2</RootNamespace>
7+
<LangVersion>preview</LangVersion>
8+
<CelestePrefix Condition="'$(CelestePrefix)' == '' And Exists('..\..\Celeste.dll')">..\..</CelestePrefix>
9+
<CelestePrefix Condition="'$(CelestePrefix)' == ''">lib-stripped</CelestePrefix>
10+
<ZippedFiles>everest.yaml;bin\CollabUtils2.*;Audio\**\*.*;Dialog\**\*.*;Graphics\**\*.*;Ahorn\**\*.*;Loenn\**\*.*</ZippedFiles>
11+
</PropertyGroup>
12+
13+
<!--Disable "Copy Local" for all references-->
14+
<ItemDefinitionGroup>
15+
<PackageReference PrivateAssets="all" ExcludeAssets="runtime" />
16+
<Reference Private="false" />
17+
</ItemDefinitionGroup>
18+
19+
<ItemGroup>
20+
<PackageReference Include="MonoMod.RuntimeDetour" Version="25.3.1.0" PrivateAssets="all" ExcludeAssets="runtime" />
21+
<PackageReference Include="MonoMod.Patcher" Version="25.0.0-prerelease.2" />
22+
<PackageReference Include="CelesteAnalyzer" Version="*" />
23+
</ItemGroup>
24+
25+
<ItemGroup>
26+
<PackageReference Include="CelesteMod.Publicizer" Version="*" CelesteAssembly="$(CelestePrefix)\Celeste.dll" />
27+
<Reference Include="$(CelestePrefix)\MMHOOK_Celeste.dll" Private="false" />
28+
<Reference Include="$(CelestePrefix)\FNA.dll" Private="false" />
29+
30+
<Reference Include="lib-stripped\CelesteNet.Client.dll" Private="false" />
31+
<Reference Include="lib-stripped\CelesteNet.Shared.dll" Private="false" />
32+
33+
<PackageReference Include="YamlDotNet" Version="16.0.0.0" />
34+
<PackageReference Include="Mono.Cecil" Version="0.11.6.0" />
35+
</ItemGroup>
36+
37+
<Target Name="CopyFiles" AfterTargets="Build" Inputs="$(OutputPath)\$(AssemblyName).dll;$(OutputPath)\$(AssemblyName).pdb" Outputs="bin\$(AssemblyName).dll;bin\$(AssemblyName).pdb">
38+
<Copy SourceFiles="$(OutputPath)\$(AssemblyName).dll" DestinationFolder="bin" />
39+
<Copy SourceFiles="$(OutputPath)\$(AssemblyName).pdb" DestinationFolder="bin" />
40+
</Target>
41+
42+
<Target Name="PackageMod" AfterTargets="CopyFiles" Inputs="$(ZippedFiles)" Outputs="CollabUtils2.zip" Condition="'$(Configuration)' == 'Release'">
43+
<ItemGroup>
44+
<FilesToPackage Include="$(ZippedFiles)" />
45+
</ItemGroup>
46+
<PackageMod Files="@(FilesToPackage)" OutputPath="CollabUtils2.zip" />
47+
</Target>
48+
49+
<PropertyGroup>
50+
<PathMap>$(MSBuildProjectDirectory)=CollabUtils2/</PathMap>
51+
</PropertyGroup>
52+
53+
<!-- Inline task used to create a .zip for the mod -->
54+
<UsingTask TaskName="PackageMod"
55+
TaskFactory="RoslynCodeTaskFactory"
56+
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" >
57+
<ParameterGroup>
58+
<Files ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
59+
<OutputPath ParameterType="System.String" Required="true" />
60+
</ParameterGroup>
61+
<Task>
62+
<Using Namespace="System.IO" />
63+
<Using Namespace="System.IO.Compression" />
64+
<Code Type="Fragment" Language="cs">
65+
<![CDATA[
66+
var projectDir = @"$(ProjectDir)";
67+
projectDir = Uri.UnescapeDataString(projectDir);
68+
69+
if (File.Exists(OutputPath))
70+
File.Delete(OutputPath);
71+
72+
using (ZipArchive zip = ZipFile.Open(OutputPath, ZipArchiveMode.Create))
73+
{
74+
foreach (var file in Files)
75+
{
76+
string filePath = file.GetMetadata("FullPath");
77+
string entryName = GetRelativePath(projectDir, filePath);
78+
79+
zip.CreateEntryFromFile(filePath, entryName);
80+
}
81+
}
82+
83+
string GetRelativePath(string fromPath, string toPath)
84+
{
85+
if (string.IsNullOrEmpty(fromPath)) throw new ArgumentNullException(nameof(fromPath));
86+
if (string.IsNullOrEmpty(toPath)) throw new ArgumentNullException(nameof(toPath));
87+
88+
Uri fromUri = new Uri(fromPath);
89+
Uri toUri = new Uri(toPath);
90+
91+
if (fromUri.Scheme != toUri.Scheme) { return toPath; } // path can't be made relative.
92+
93+
Uri relativeUri = fromUri.MakeRelativeUri(toUri);
94+
string relativePath = Uri.UnescapeDataString(relativeUri.ToString());
95+
96+
if (toUri.Scheme.Equals("file", StringComparison.InvariantCultureIgnoreCase))
97+
{
98+
relativePath = relativePath.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
99+
}
100+
101+
return relativePath;
102+
}
103+
]]>
104+
</Code>
105+
</Task>
106+
</UsingTask>
61107

62108
</Project>

CollabUtils2.zip

5.03 MB
Binary file not shown.

Entities/CollabCrystalHeart.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,14 @@ private static void onCompleteArea(ILContext il) {
7575

7676
// this is a bit confusing, but this function is returning a function that the vanilla code will run
7777
// (instead of the vanilla function that goes Engine.Scene = new LevelExit(...))
78-
cursor.EmitDelegate<Func<Action, Level, Action>>((orig, self) => () => {
79-
Engine.Scene = new LevelExitToLobby(LevelExit.Mode.Completed, self.Session);
80-
});
78+
cursor.EmitDelegate<Func<Action, Level, Action>>(exitToLobby);
8179

8280
cursor.Index++;
8381
}
8482
}
83+
84+
private static Action exitToLobby(Action orig, Level self) {
85+
return () => Engine.Scene = new LevelExitToLobby(LevelExit.Mode.Completed, self.Session);
86+
}
8587
}
8688
}

Entities/MiniHeart.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public class MiniHeart : AbstractMiniHeart {
1919
private EventInstance pauseMusicSnapshot;
2020
private SoundEmitter collectSound;
2121

22+
private TimeRateModifier timeRateModifier;
23+
2224
public MiniHeart(EntityData data, Vector2 position, EntityID gid)
2325
: base(data, position, gid) {
2426

@@ -48,6 +50,9 @@ private IEnumerator SmashRoutine(Player player, Level level) {
4850
foreach (IStrawberry item in list) {
4951
item.OnCollect();
5052
}
53+
54+
timeRateModifier = new TimeRateModifier(1);
55+
Add(timeRateModifier);
5156

5257
// play the collect jingle
5358
collectSound = SoundEmitter.Play("event:/SC2020_heartShard_get", this);
@@ -63,7 +68,7 @@ private IEnumerator SmashRoutine(Player player, Level level) {
6368
yield return null;
6469
Celeste.Freeze(0.2f);
6570
yield return null;
66-
Engine.TimeRate = 0.5f;
71+
timeRateModifier.Multiplier = 0.5f;
6772
player.Depth = Depths.FormationSequences;
6873
for (int i = 0; i < 10; i++) {
6974
Scene.Add(new AbsorbOrb(Position));
@@ -78,7 +83,7 @@ private IEnumerator SmashRoutine(Player player, Level level) {
7883
// slow down time further, to a freeze
7984
Visible = false;
8085
for (float time = 0f; time < 2f; time += Engine.RawDeltaTime) {
81-
Engine.TimeRate = Calc.Approach(Engine.TimeRate, 0f, Engine.RawDeltaTime * 0.25f);
86+
timeRateModifier.Multiplier = Calc.Approach(timeRateModifier.Multiplier, 0f, Engine.RawDeltaTime * 0.25f);
8287
yield return null;
8388
}
8489

@@ -91,7 +96,7 @@ private IEnumerator SmashRoutine(Player player, Level level) {
9196
yield return 100f;
9297
}
9398

94-
Engine.TimeRate = 1f;
99+
Remove(timeRateModifier);
95100
Tag = Tags.FrozenUpdate;
96101
level.Frozen = true;
97102

@@ -129,7 +134,7 @@ private void interruptCollection() {
129134
level.Frozen = false;
130135
level.CanRetry = true;
131136
level.FormationBackdrop.Display = false;
132-
Engine.TimeRate = 1f;
137+
if (timeRateModifier != null) Remove(timeRateModifier);
133138

134139
if (collectSound != null) {
135140
collectSound.RemoveSelf();

0 commit comments

Comments
 (0)