Skip to content

Commit

Permalink
Gameplay: Add autoplay and judgement remap group properties
Browse files Browse the repository at this point in the history
  • Loading branch information
0thElement committed Jan 26, 2024
1 parent b66040a commit 4a10ec6
Show file tree
Hide file tree
Showing 29 changed files with 541 additions and 148 deletions.
196 changes: 159 additions & 37 deletions Assets/Fonts/NotoSans-Regular SDF.asset

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Assets/Scenes/Compose.unity
Original file line number Diff line number Diff line change
Expand Up @@ -28471,7 +28471,7 @@ RectTransform:
- {fileID: 944069816}
- {fileID: 1288592921}
m_Father: {fileID: 2092054170}
m_RootOrder: 0
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 0}
Expand Down Expand Up @@ -47958,7 +47958,7 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 2092054170}
m_RootOrder: 1
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1}
Expand Down Expand Up @@ -98418,8 +98418,8 @@ RectTransform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 497225745}
- {fileID: 940952970}
- {fileID: 497225745}
m_Father: {fileID: 86582844}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand Down
17 changes: 17 additions & 0 deletions Assets/Scripts/ChartFormat/Types/JudgementMap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace ArcCreate.ChartFormat
{
// agony
public enum JudgementMap
{
MissEarly,
GoodEarly,
PerfectEarly,
Max,
PerfectLate,
GoodLate,
MissLate,
PerfectMapped,
GoodMapped,
MissMapped,
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/ChartFormat/Types/JudgementMap.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

170 changes: 153 additions & 17 deletions Assets/Scripts/ChartFormat/Types/RawTimingGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,6 @@ public class RawTimingGroup
{
// Might be problematic when multiple chart formats is introduced, as this class only serialize / deserialize to aff.
// Don't wnat to think about it now though.
public RawTimingGroup()
{
NoInput = false;
NoClip = false;
FadingHolds = false;
NoHeightIndicator = false;
NoShadow = false;
NoArcCap = false;
NoHead = false;
AngleX = 0;
AngleY = 0;
ArcResolution = 1;
Side = SideOverride.None;
}

public string Name { get; set; } = null;

public bool NoInput { get; set; } = false;
Expand All @@ -38,13 +23,20 @@ public RawTimingGroup()

public bool FadingHolds { get; set; } = false;

public bool IgnoreMirror { get; set; } = false;

public bool Autoplay { get; set; } = false;

public Dictionary<JudgementMap, JudgementMap> JudgementMaps { get; }
= new Dictionary<JudgementMap, JudgementMap>();

public float ArcResolution { get; set; } = 1;

public float AngleX { get; set; } = 0;

public float AngleY { get; set; } = 0;

public SideOverride Side { get; set; }
public SideOverride Side { get; set; } = SideOverride.None;

public string File { get; set; } = "";

Expand Down Expand Up @@ -94,6 +86,36 @@ public static Result<RawTimingGroup, ChartError> Parse(string def, int lineNumbe
val = UnityEngine.Mathf.Clamp(val, 0, 10);
tg.ArcResolution = valid ? val : 1;
break;
case "max":
AddRemapRules(tg, value, JudgementMap.Max);
break;
case "perfect":
AddRemapRules(tg, value, JudgementMap.PerfectEarly, JudgementMap.PerfectLate);
break;
case "perfectearly":
AddRemapRules(tg, value, JudgementMap.PerfectEarly);
break;
case "perfectlate":
AddRemapRules(tg, value, JudgementMap.PerfectLate);
break;
case "good":
AddRemapRules(tg, value, JudgementMap.GoodEarly, JudgementMap.GoodLate);
break;
case "goodearly":
AddRemapRules(tg, value, JudgementMap.GoodEarly);
break;
case "goodlate":
AddRemapRules(tg, value, JudgementMap.GoodLate);
break;
case "miss":
AddRemapRules(tg, value, JudgementMap.MissEarly, JudgementMap.MissLate);
break;
case "missearly":
AddRemapRules(tg, value, JudgementMap.MissEarly);
break;
case "misslate":
AddRemapRules(tg, value, JudgementMap.MissLate);
break;
default:
return ChartError.Property(
def,
Expand Down Expand Up @@ -135,6 +157,12 @@ public static Result<RawTimingGroup, ChartError> Parse(string def, int lineNumbe
case "fadingholds":
tg.FadingHolds = true;
break;
case "ignoremirror":
tg.IgnoreMirror = true;
break;
case "autoplay":
tg.Autoplay = true;
break;
default:
return ChartError.Property(
def,
Expand Down Expand Up @@ -162,6 +190,36 @@ public string ToStringWithoutName()
return string.Join(",", opts);
}

private static bool TryGetJudgement(string mapTo, out JudgementMap result)
{
switch (mapTo)
{
case "max": result = JudgementMap.Max; return true;
case "perfectearly": result = JudgementMap.PerfectEarly; return true;
case "goodearly": result = JudgementMap.GoodEarly; return true;
case "missearly": result = JudgementMap.MissEarly; return true;
case "perfectlate": result = JudgementMap.PerfectLate; return true;
case "goodlate": result = JudgementMap.GoodLate; return true;
case "misslate": result = JudgementMap.MissLate; return true;
case "perfect": result = JudgementMap.PerfectMapped; return true;
case "good": result = JudgementMap.GoodMapped; return true;
case "miss": result = JudgementMap.MissMapped; return true;
default: result = default; return false;
}
}

private static void AddRemapRules(RawTimingGroup tg, string value, params JudgementMap[] fromJudgements)
{
string mapTo = value.Trim('"').ToLower();
if (TryGetJudgement(mapTo, out JudgementMap res))
{
foreach (var j in fromJudgements)
{
tg.JudgementMaps.Add(j, res);
}
}
}

private List<string> GetPropertyStrings(bool withName)
{
List<string> opts = new List<string>();
Expand Down Expand Up @@ -205,6 +263,66 @@ private List<string> GetPropertyStrings(bool withName)
opts.Add("fadingholds");
}

if (IgnoreMirror)
{
opts.Add("ignoremirror");
}

if (Autoplay)
{
opts.Add("autoplay");
}

if (JudgementMaps.TryGetValue(JudgementMap.Max, out JudgementMap maxTo))
{
opts.Add($"max={GetStringFrom(maxTo)}");
}

if (JudgementMaps.TryGetValue(JudgementMap.PerfectEarly, out JudgementMap pearlyTo)
&& JudgementMaps.TryGetValue(JudgementMap.PerfectLate, out JudgementMap plateTo)
&& pearlyTo == plateTo)
{
opts.Add($"perfect={GetStringFrom(pearlyTo)}");
}
else if (JudgementMaps.TryGetValue(JudgementMap.PerfectEarly, out JudgementMap pe))
{
opts.Add($"perfectearly={GetStringFrom(pe)}");
}
else if (JudgementMaps.TryGetValue(JudgementMap.PerfectLate, out JudgementMap pl))
{
opts.Add($"perfectlate={GetStringFrom(pl)}");
}

if (JudgementMaps.TryGetValue(JudgementMap.GoodEarly, out JudgementMap gearlyTo)
&& JudgementMaps.TryGetValue(JudgementMap.GoodLate, out JudgementMap glateTo)
&& gearlyTo == glateTo)
{
opts.Add($"good={GetStringFrom(gearlyTo)}");
}
else if (JudgementMaps.TryGetValue(JudgementMap.GoodEarly, out JudgementMap ge))
{
opts.Add($"goodearly={GetStringFrom(ge)}");
}
else if (JudgementMaps.TryGetValue(JudgementMap.GoodLate, out JudgementMap gl))
{
opts.Add($"goodlate={GetStringFrom(gl)}");
}

if (JudgementMaps.TryGetValue(JudgementMap.MissEarly, out JudgementMap mearlyTo)
&& JudgementMaps.TryGetValue(JudgementMap.MissLate, out JudgementMap mlateTo)
&& mearlyTo == mlateTo)
{
opts.Add($"miss={GetStringFrom(mearlyTo)}");
}
else if (JudgementMaps.TryGetValue(JudgementMap.MissEarly, out JudgementMap me))
{
opts.Add($"missearly={GetStringFrom(me)}");
}
else if (JudgementMaps.TryGetValue(JudgementMap.MissLate, out JudgementMap ml))
{
opts.Add($"misslate={GetStringFrom(ml)}");
}

if (AngleX != 0)
{
opts.Add($"anglex={AngleX:f2}");
Expand All @@ -227,5 +345,23 @@ private List<string> GetPropertyStrings(bool withName)

return opts;
}

private string GetStringFrom(JudgementMap j)
{
switch (j)
{
case JudgementMap.MissEarly: return "missearly";
case JudgementMap.GoodEarly: return "goodearly";
case JudgementMap.PerfectEarly: return "perfectearly";
case JudgementMap.Max: return "max";
case JudgementMap.PerfectLate: return "perfectlate";
case JudgementMap.GoodLate: return "goodlate";
case JudgementMap.MissLate: return "misslate";
case JudgementMap.PerfectMapped: return "perfect";
case JudgementMap.GoodMapped: return "good";
case JudgementMap.MissMapped: return "miss";
default: return j.ToString().ToLower();
}
}
}
}
}
7 changes: 5 additions & 2 deletions Assets/Scripts/Compose/EventsEditor/Timing/TimingTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,11 @@ private void OnChart()

private void ReloadGroup(int group)
{
TimingGroup tg = Services.Gameplay.Chart.GetTimingGroup(group);
SetData(tg.Timings);
if (Services.Gameplay?.Chart != null)
{
TimingGroup tg = Services.Gameplay.Chart.GetTimingGroup(group);
SetData(tg.Timings);
}
}

private void OnMarker(Marker marker, int timing)
Expand Down
12 changes: 9 additions & 3 deletions Assets/Scripts/Data/PlayResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ public class PlayResult

public int EarlyMissCount { get; set; }

public int MappedPerfectCount { get; set; } = 0;

public int MappedGoodCount { get; set; } = 0;

public int MappedMissCount { get; set; } = 0;

public int MaxCombo { get; set; }

public int RetryCount { get; set; }
Expand All @@ -43,13 +49,13 @@ public class PlayResult
public int NoteCount { get; set; }

[BsonIgnore]
public int PerfectCount => LatePerfectCount + EarlyPerfectCount + MaxCount;
public int PerfectCount => LatePerfectCount + EarlyPerfectCount + MappedPerfectCount + MaxCount;

[BsonIgnore]
public int GoodCount => LateGoodCount + EarlyGoodCount;
public int GoodCount => LateGoodCount + EarlyGoodCount + MappedGoodCount;

[BsonIgnore]
public int MissCount => LateMissCount + EarlyMissCount;
public int MissCount => LateMissCount + EarlyMissCount + MappedMissCount;

[BsonIgnore]
public double Score
Expand Down
16 changes: 16 additions & 0 deletions Assets/Scripts/Gameplay/Data/ArcChart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ public ArcChart(ChartReader reader)
{
foreach (ChartTimingGroup tg in TimingGroups)
{
if (tg.Properties.IgnoreMirror)
{
continue;
}

foreach (var tap in tg.Taps)
{
tap.Lane = 5 - tap.Lane;
Expand All @@ -155,6 +160,17 @@ public ArcChart(ChartReader reader)
arc.Color = arc.Color == 0 ? 1 : (arc.Color == 1 ? 0 : arc.Color);
}
}

foreach (var cam in Cameras)
{
if (TimingGroups[cam.TimingGroup].Properties.IgnoreMirror)
{
continue;
}

cam.Move = new UnityEngine.Vector3(-cam.Move.x, cam.Move.y, cam.Move.z);
cam.Rotate = new UnityEngine.Vector3(-cam.Rotate.x, cam.Rotate.y, -cam.Rotate.z);
}
}
}

Expand Down
Loading

0 comments on commit 4a10ec6

Please sign in to comment.