Skip to content

Commit

Permalink
Update for Beat Saber 0.12.x
Browse files Browse the repository at this point in the history
Breaks:
- `game.mode` (see issue #12)

Changes:
- `game.scene` now only has two values: `Menu` and `Song`
- `mod.noEnergy` is now `mod.instaFail`
- `mod.mirror` was removed
- `start`, `paused`, `songTimeOffset` and `length` properties of the `beatmap` object are adjusted with the speed multiplier
- `beatmap.maxScore`, `performance.score` and `performance.currentMaxScore` are now adjusted with the modifier multiplier
- New detection system for `obstacleEnter` and `obstacleExit` events for faster detection
- Logging is now done using the static method `Plugin.PluginLog`
- Finding classes is now done using the static method `Plugin.FindFirstOrDefault`
- Plugin now listens to `SceneManager.activeSceneChanged` instead of `SceneManager.sceneLoaded`

Adds:
- `Plugin.PluginVersion` and `Plugin.GameVersion`
- `game.pluginVersion`
- `game.gameVersion`
- `beatmap.bombsCount`
- `beatmap.obstaclesCount`
- `beatmap.maxRank`
- `performance.batteryEnergy`
- `mod.multiplier`
- `mod.batteryLives`
- `mod.songSpeedMultiplier`
- `mod.instaFail`
- `mod.batteryEnergy`
- `mod.disappearingArrows`
- `mod.noBombs`
- `mod.songSpeed`
- `mod.failOnSaberClash`
- `mod.strictAngles`
- `playerSettings.staticLights`
- `playerSettings.leftHanded`
- `playerSettings.swapColors`
- `playerSettings.playerHeight`
- `playerSettings.disableSFX`
- `playerSettings.reduceDebris`
- `playerSettings.noHUD`
- `playerSettings.advancedHUD`
- `noteCut.noteLine`
- `noteCut.noteLayer`

Removes:
- `scene` event

Co-authored-by: Zingabopp <[email protected]>
  • Loading branch information
opl- and Zingabopp committed Dec 22, 2018
1 parent 913ff1c commit da4eb2b
Show file tree
Hide file tree
Showing 7 changed files with 229 additions and 125 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ libs/beatsaber/*
bin
obj

.vs/
.vs/
9 changes: 5 additions & 4 deletions BeatSaberHTTPStatus/BeatSaberHTTPStatusPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<Version>1.2.0</Version>
<BeatSaberVersion>0.11.2</BeatSaberVersion>
<Version>1.3.0</Version>
<BeatSaberVersion>0.12.2</BeatSaberVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -88,6 +88,7 @@
<Output TaskParameter="CopiedFiles" ItemName="Compile" />
</Copy>
<ReplaceFileText InputFilename="$(IntermediateSourcePath)Plugin.cs" OutputFilename="$(IntermediateSourcePath)Plugin.cs" MatchExpression="$VERSION$" ReplacementText="$(Version)" />
<ReplaceFileText InputFilename="$(IntermediateSourcePath)Plugin.cs" OutputFilename="$(IntermediateSourcePath)Plugin.cs" MatchExpression="$BS_VERSION$" ReplacementText="$(BeatSaberVersion)" />
</Target>
<!-- Package built DLLs into a zip -->
<Target Name="AfterBuild" Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
Expand Down Expand Up @@ -148,10 +149,10 @@
<Using Namespace="System.Text.RegularExpressions" />
<Code Type="Fragment" Language="cs">
<![CDATA[
Log.LogMessage(string.Format("Replacing {0} in {1}", MatchExpression, InputFilename));
Log.LogMessage(string.Format("Replacing {0} in {1} to {2}", MatchExpression, InputFilename, ReplacementText));
File.WriteAllText(
OutputFilename,
Regex.Replace(File.ReadAllText(InputFilename), MatchExpression, ReplacementText)
File.ReadAllText(InputFilename).Replace(MatchExpression, ReplacementText)
);
]]>
</Code>
Expand Down
34 changes: 30 additions & 4 deletions BeatSaberHTTPStatus/GameStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ namespace BeatSaberHTTPStatus {
public class GameStatus {
public string updateCause;

public string scene = null;
public string scene = "Menu";
public bool partyMode = false;
public string mode = null;

// Beatmap
Expand All @@ -20,8 +21,10 @@ public class GameStatus {
public long paused = 0;
public string difficulty = null;
public int notesCount = 0;
public int bombsCount = 0;
public int obstaclesCount = 0;
public int maxScore = 0;
public string maxRank = "E";

// Performance
public int score = 0;
Expand All @@ -37,11 +40,14 @@ public class GameStatus {
public int maxCombo = 0;
public int multiplier = 0;
public float multiplierProgress = 0;
public int batteryEnergy = 1;

// Note cut
public int noteID = -1;
public string noteType = null;
public string noteCutDirection = null;
public int noteLine = 0;
public int noteLayer = 0;
public bool speedOK = false;
public bool directionOK = false;
public bool saberTypeOK = false;
Expand All @@ -66,9 +72,28 @@ public class GameStatus {
public float cutDistanceToCenter = 0;

// Mods
public string modObstacles = "None";
public bool modNoEnergy = false;
public bool modMirror = false;
public float modifierMultiplier = 1f;
public string modObstacles = "All";
public bool modInstaFail = false;
public bool modNoFail = false;
public bool modBatteryEnergy = false;
public int batteryLives = 1;
public bool modDisappearingArrows = false;
public bool modNoBombs = false;
public string modSongSpeed = "Normal";
public float songSpeedMultiplier = 1f;
public bool modFailOnSaberClash = false;
public bool modStrictAngles = false;

// Player settings
public bool staticLights = false;
public bool leftHanded = false;
public bool swapColors = false;
public float playerHeight = 1.7f;
public bool disableSFX = false;
public bool reduceDebris = false;
public bool noHUD = false;
public bool advancedHUD = false;

// Beatmap event
public int beatmapEventType = 0;
Expand All @@ -88,6 +113,7 @@ public void ResetMapInfo() {
this.notesCount = 0;
this.obstaclesCount = 0;
this.maxScore = 0;
this.maxRank = "E";
}

public void ResetPerformance() {
Expand Down
9 changes: 6 additions & 3 deletions BeatSaberHTTPStatus/HTTPServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public void InitServer() {

server.AddWebSocketService<StatusBroadcastBehavior>("/socket", behavior => behavior.SetStatusManager(statusManager));

Console.WriteLine("[HTTP Status] Starting HTTP server on port " + ServerPort);
BeatSaberHTTPStatus.Plugin.PluginLog("Starting HTTP server on port " + ServerPort);
server.Start();
}

public void StopServer() {
Console.WriteLine("[HTTP Status] Stopping HTTP server");
BeatSaberHTTPStatus.Plugin.PluginLog("Stopping HTTP server");
server.Stop();
}

Expand Down Expand Up @@ -91,7 +91,10 @@ public void OnStatusChange(StatusManager statusManager, ChangedProperties change
if (changedProps.game) status["game"] = statusManager.statusJSON["game"];
if (changedProps.beatmap) status["beatmap"] = statusManager.statusJSON["beatmap"];
if (changedProps.performance) status["performance"] = statusManager.statusJSON["performance"];
if (changedProps.mod) status["mod"] = statusManager.statusJSON["mod"];
if (changedProps.mod) {
status["mod"] = statusManager.statusJSON["mod"];
status["playerSettings"] = statusManager.statusJSON["playerSettings"];
}
}

if (changedProps.noteCut) {
Expand Down
Loading

0 comments on commit da4eb2b

Please sign in to comment.