Skip to content

Commit

Permalink
Published Backward Compatible Version
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaPiggy committed Jun 1, 2021
1 parent 7f7ee13 commit b707a8f
Show file tree
Hide file tree
Showing 42 changed files with 210 additions and 2,033 deletions.
55 changes: 0 additions & 55 deletions Character.cs

This file was deleted.

75 changes: 0 additions & 75 deletions CharacterExtensions.cs

This file was deleted.

70 changes: 0 additions & 70 deletions CharacterIdentifiable.cs

This file was deleted.

11 changes: 1 addition & 10 deletions Config/ConfigElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ static bool GetAttributeOfType<T>(FieldInfo field, out T attribute) where T : At
return attribute != null;
}

public override void SetValue<T>(T value)
{
if (value is int) value = (T)Options.Range.GetValue(value);
base.SetValue(value);
}

public static ConfigElementOptions GenerateAttributesOptions(FieldInfo field)
{

Expand All @@ -42,15 +36,13 @@ public static ConfigElementOptions GenerateAttributesOptions(FieldInfo field)
Comment = GetAttributeOfType<ConfigCommentAttribute>(field, out var comment) ? comment.Comment : null,
Name = GetAttributeOfType<ConfigNameAttribute>(field, out var name) ? name.Name : field.Name,
Parser = GetAttributeOfType<ConfigParserAttribute>(field, out var parser) ? parser.Parser : ParserRegistry.TryGetParser(field.FieldType, out var backupParser) ? backupParser : null,
ReloadMode = GetAttributeOfType<ConfigReloadAttribute>(field, out var reload) ? reload.Mode : ReloadMode.NORMAL,
Range = GetAttributeOfType<ConfigRangeAttribute>(field, out var range) ? new DoubleConstrainedInt(0, range.min, range.max) : DoubleConstrainedInt.zero
ReloadMode = GetAttributeOfType<ConfigReloadAttribute>(field, out var reload) ? reload.Mode : ReloadMode.NORMAL
};
}

public FieldBackedConfigElement(FieldInfo field) : base(GenerateAttributesOptions(field))
{
this.field = field;
if (Value is int) Value = Options.Range.GetValue((int)Value);
Options.DefaultValue = Value;
if (Value is IStringParserProvider val) Options.Parser = val.GetParser();
if (Options.Parser == null) throw new Exception(field.FieldType.ToString());
Expand Down Expand Up @@ -132,7 +124,6 @@ public class ConfigElementOptions
public string Comment { get; internal set; }
public object DefaultValue { get; internal set; }
public string Name { get; internal set; }
public DoubleConstrainedInt Range { get; internal set; }
public ReloadMode ReloadMode { get; internal set; }
}

Expand Down
1 change: 0 additions & 1 deletion Console/Commands/CheckpointCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public override bool Execute(string[] args)
Console.LogError("Failed to create a checkpoint");
return false;
}
Main.StopSave();
PlayerScript.player.SetCheckpoint(CreateCheckpoint().transform);
Console.LogSuccess("Successfully created a checkpoint");
return true;
Expand Down
32 changes: 2 additions & 30 deletions Console/Commands/CompleteLevelCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,7 @@ public override bool Execute(string[] args)
Console.LogError("Cannot complete a level when there is no level to complete.");
return false;
}
if (Levels.isRedHeart())
{
var FakeBtn = Object.FindObjectOfType<FakeButtonScript>();
if (FakeBtn != null)
FakeBtn.Pound();
else
Console.LogError("No fake button found.");
var potClose = Object.FindObjectOfType<PotCloseTrigger>();
if (potClose != null)
{
Patches.PotClosedPatch.OnPotClosed += CompleteRedHeart;
potClose.OnTriggerEnter2D(Main.CreatePlayerCollider());
return true;
}
else
Console.LogError("No pot found.");
}
return CompleteLevel();//Levels.isRedHeart() ? CompleteRedHeart() : CompleteLevel();
}

private static void CompleteRedHeart()
{
SAObjects.GetRootGameObject("PotTrap").SetChildActive("LevelClearEmpty", true);
CompleteLevel();
Patches.PotClosedPatch.OnPotClosed -= CompleteRedHeart;
return CompleteLevel();
}

private static bool CompleteLevel()
Expand All @@ -53,11 +29,7 @@ private static bool CompleteLevel()
Console.LogError("Failed to complete level. No 'mom' button found.");
return false;
}
Main.StopSave();
LevelManager.levelManager.deaths = 0;
LevelManager.levelManager.bubbaTokens = new bool[3] { true, true, true };
LevelManager.levelManager.collectedMoustaches = LevelManager.levelManager.totalMoustaches;
MainScript.main.levelTime = 0.0f;
MainScript.main.levelTime = 0.01f;
ClearBtn.Pound();
Console.LogSuccess("Successfully completed level.");
return true;
Expand Down
1 change: 0 additions & 1 deletion Console/Commands/CoordinatesCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public override bool Execute(string[] args)
float result3;
if (float.TryParse(args[1], out result1) & float.TryParse(args[2], out result2) & float.TryParse(args[3], out result3))
{
Main.StopSave();
PlayerScript.player.transform.position = new UnityEngine.Vector3(result1, result2, result3);
return true;
}
Expand Down
14 changes: 12 additions & 2 deletions Console/Commands/LoadLevelCommand.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.SceneManagement;
using SALT.Extensions;

namespace SALT.Console.Commands
Expand All @@ -18,7 +19,7 @@ internal class LoadLevelCommand : ConsoleCommand
public static int Increment()
{
i += 1;
if (i > (int)EnumUtils.GetHighestValue<Level>())
if (i >= SceneManager.sceneCountInBuildSettings)
i = 0;
return i;
}
Expand Down Expand Up @@ -47,7 +48,16 @@ public override List<string> GetAutoComplete(int argIndex, string argText)
if (argIndex == 0)
{
List<Level> levels = EnumUtils.GetAll<Level>().ToList();
return levels.Select<Level,string>(l => l.ToString()).ToList();
List<Level> realLevels = new List<Level>();
int index = 1;
foreach (Level lvl in levels)
{
if (index > SceneManager.sceneCountInBuildSettings)
break;
realLevels.Add(lvl);
index++;
}
return realLevels.Select<Level,string>(l => l.ToString()).ToList();
}
return base.GetAutoComplete(argIndex, argText);
}
Expand Down
2 changes: 1 addition & 1 deletion Console/Commands/OldDumpCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public override List<string> GetAutoComplete(int argIndex, string argText)
{
if (argIndex == 0)
{
List<string> vs = new List<string>() { "all" };
List<string> vs = new List<string>{ "all" };
vs.AddRange(Console.dumpActions.Keys);
return vs;
}
Expand Down
1 change: 0 additions & 1 deletion Console/Commands/RespawnCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public override bool Execute(string[] args)
Console.LogError("Respawn failed");
return false;
}
Main.StopSave();
player.Kill();//InvokePrivateMethod("Kill");
Console.LogSuccess("Successfully Respawned");
return true;
Expand Down
Loading

0 comments on commit b707a8f

Please sign in to comment.