Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Chasmical authored May 24, 2020
1 parent e05ff61 commit 972a562
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 108 deletions.
18 changes: 16 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,27 @@
1. [Main page](https://github.com/Abbysssal/RogueLibs/blob/master/README.md)
2. [RogueLibs](https://github.com/Abbysssal/RogueLibs/blob/master/RogueLibs.md)
3. [Mutators](https://github.com/Abbysssal/RogueLibs/blob/master/Mutators.md)
4. [Mutators](https://github.com/Abbysssal/RogueLibs/blob/master/CustomNames.md)
5. **RogueLibs Changelog**
4. [CustomNames](https://github.com/Abbysssal/RogueLibs/blob/master/CustomNames.md)
5. [Extras](https://github.com/Abbysssal/RogueLibs/blob/master/Extras.md)
6. **RogueLibs Changelog**

## Changelog ##
Here you will find all updates on RogueLibs, so you can specify your RogueLibs' version dependency better.

#### RogueLibs v1.1 ####
* **Renamed Mutator class to CustomMutator!**;
* **Removed MutatorInfo class, use CustomNameInfo instead!**;
* **Removed Mutator.Cancellations and CancelledBy, use Conflicting instead!**;
* **Removed SetMutator(id, unlocked, english,..), use SetMutator(id, unlocked, name, description) instead!**;
* **Removed SetCustomName(id, type, english,..), use SetCustomName(id, type, info) instead!**;
* **Removed GetCustomName(id), use GetCustomName(id, type) instead!**;
* **Removed DeleteCustomName(id), use DeleteCustomName(id, type) instead!**;
* CustomNameInfo is now a struct;
* Changed some configuration loading code;
* Added class RoguePatcher, more info [here](https://github.com/Abbysssal/RogueLibs/blob/master/Extras.md#roguepatcher);
* Added static class RogueUtilities, more info [here](https://github.com/Abbysssal/RogueLibs/blob/master/Extras.md#rogueutilities);

#### RogueLibs v1.0.1 ####
* Fixed a bug, when deleted mods' mutators were showing in the Mutator Menu;

#### RogueLibs v1.0 ####
Expand Down
29 changes: 5 additions & 24 deletions CustomNames.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
2. [RogueLibs](https://github.com/Abbysssal/RogueLibs/blob/master/RogueLibs.md)
3. [Mutators](https://github.com/Abbysssal/RogueLibs/blob/master/Mutators.md)
4. **CustomNames**
5. [RogueLibs Changelog](https://github.com/Abbysssal/RogueLibs/blob/master/Changelog.md)
5. [Extras](https://github.com/Abbysssal/RogueLibs/blob/master/Extras.md)
6. [RogueLibs Changelog](https://github.com/Abbysssal/RogueLibs/blob/master/Changelog.md)

## Creating CustomNames ##
```cs
Expand All @@ -24,36 +25,16 @@ CustomName name = RogueLibs.SetCustomName("myId", "Agent", new CustomNameInfo(
// If you don't know which type you need, use null.
```
You can also get CustomName by its id and type:
```cs
public static CustomName SetCustomName(string id, string type, string english, string schinese = null, string german = null, string spanish = null, string brazilian = null, string russian = null, string french = null, string koreana = null);
```
```cs
CustomName name2 = RogueLibs.SetCustomName("myId", null,
"english",
"schinese",
null,
null,
null,
null,
null,
null);
// null strings will default to english.
// If you don't know which type you need, use null.
```
You can also get CustomName by its Id (or both Id and type):
```cs
public static CustomName GetCustomName(string id);
public static CustomName GetCustomName(string id, string type);
```
```cs
CustomName found = RogueLibs.GetCustomName("MyNameId");
CustomName found2 = RogueLibs.GetCustomName("MyNameId", "MyType");
CustomName found = RogueLibs.GetCustomName("MyNameId", "MyType");
```
## Deleting CustomNames ##
Just in case you don't need your CustomNames anymore:
```cs
public static bool DeleteCustomName(string id);
public static bool DeleteCustomName(CustomName customName);
public static bool DeleteCustomName(string id, string type);
```
Expand All @@ -67,7 +48,7 @@ public string Type { get; }
string myId = myCustomName.Id;
string myType = myCustomName.Type;
```
You can access different localization lines:
You can access different localization strings:
```cs
public string English { get; set; }
public string SChinese { get; set; }
Expand Down
73 changes: 73 additions & 0 deletions Extras.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
## [Contents](https://github.com/Abbysssal/RogueLibs) ##

1. [Main page](https://github.com/Abbysssal/RogueLibs/blob/master/README.md)
2. [RogueLibs](https://github.com/Abbysssal/RogueLibs/blob/master/RogueLibs.md)
3. [Mutators](https://github.com/Abbysssal/RogueLibs/blob/master/Mutators.md)
4. [CustomNames](https://github.com/Abbysssal/RogueLibs/blob/master/CustomNames.md)
5. **Extras**
6. [RogueLibs Changelog](https://github.com/Abbysssal/RogueLibs/blob/master/Changelog.md)

## RogueUtilities ##
With RogueUtilities class you can convert .png or .jpg files into Sprites:
```cs
public static Sprite ConvertToSprite(string filePath);
public static Sprite ConvertToSprite(byte[] data);
```
```cs
Sprite sprite = RogueUtilities.ConvertToSprite("D:\Images\MyImage.png");

byte[] data = File.ReadAllBytes("D:\Images\MyImage.png");
Sprite sprite2 = RogueUtilities.ConvertToSprite(data);
```
And convert .mp3, .ogg, .wav, .aiff files into Audioclips:
```cs
public static AudioClip ConvertToAudioClip(string filePath);
```
```cs
AudioClip clip = RogueUtilities.ConvertToAudioClip("D:\Sounds\MySound.ogg");
```
It is recommended to use .ogg, because other formats might not load properly.
## RoguePatcher ##
This class allows you to further simplify this code:
```cs
// Harmony harmony = new Harmony(pluginGuid);
// MethodInfo original = AccessTools.Method(typeof(SomeClass), "DoSomething");
// MethodInfo patch = AccessTools.Method(typeof(MyPatches), "DoSomething_Patch");
// harmony.Patch(original, patch);
//
// original = AccessTools.Method(typeof(SomeOtherClass), "Start");
// patch = AccessTools.Method(typeof(MyPatches), "Start_Patch");
// harmony.Patch(original, null, patch);
this.PatchPrefix(typeof(SomeClass), "DoSomething", typeof(MyPatches), "DoSomething_Patch");
this.PatchPostfix(typeof(SomeOtherClass), "Start", typeof(MyPatches), "Start_Patch");
```
To this:
```cs
RoguePatcher patcher = new RoguePatcher(this, typeof(MyPatches));
patcher.Prefix(typeof(SomeClass), "DoSomething");
patcher.Postfix(typeof(SomeOtherClass), "Start");

// It will search for a patch method named "<TypeName>_<MethodName>" in class MyPatches.
// For example: Method "DoSomething" in "SomeClass" class will be patched
// by a method "SomeClass_DoSomething" in class "MyPatches".
```
It uses this.PatchPrefix(..) and this.PatchPostfix(..) methods for patching, so it will catch and log all exceptions that can happen during patching. If the patch was successful, methods return true, otherwise - false.

You can also switch to a different patches class:
```cs
RoguePatcher patcher = new RoguePatcher(this, typeof(MyPatches1));
patcher.Patch(..);
patcher.SwitchTo(typeof(MyPatches2));
// OR: patcher.TypeWithPatches = typeof(MyPatches2);
patcher.Patch(..);
```
This class is probably not very useful, but I think it makes writing code for manual patching a little bit faster.








90 changes: 22 additions & 68 deletions Mutators.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,48 @@

1. [Main page](https://github.com/Abbysssal/RogueLibs/blob/master/README.md)
2. [RogueLibs](https://github.com/Abbysssal/RogueLibs/blob/master/RogueLibs.md)
3. **Mutators**
3. **CustomMutators**
4. [CustomNames](https://github.com/Abbysssal/RogueLibs/blob/master/CustomNames.md)
5. [RogueLibs Changelog](https://github.com/Abbysssal/RogueLibs/blob/master/Changelog.md)
5. [Extras](https://github.com/Abbysssal/RogueLibs/blob/master/Extras.md)
6. [RogueLibs Changelog](https://github.com/Abbysssal/RogueLibs/blob/master/Changelog.md)

## Creating Mutators ##
## Creating CustomMutators ##
```cs
public static Mutator SetMutator(string id, bool unlockedInitially, CustomNameInfo name, CustomNameInfo description);
public static CustomMutator SetMutator(string id, bool unlockedFromStart, CustomNameInfo name, CustomNameInfo description);
```
```cs
Mutator myMutator = RogueLibs.SetMutator("RocketBullets", true,
CustomMutator myMutator = RogueLibs.SetMutator("RocketBullets", true,
new CustomNameInfo("english name", "schinese", null, null, null, null, null, null),
new CustomNameInfo("description", null, null, null, null, null, null, null));

// null strings will default to english.
// After doing that your mutator will appear in Mutator Menu at Home Base.
```
## Deleting CustomMutators ##
You can delete your custom CustomMutators:
```cs
public static Mutator SetMutator(string id, bool unlockedInitially, MutatorInfo english, MutatorInfo schinese = null, MutatorInfo german = null, MutatorInfo spanish = null, MutatorInfo brazilian = null, MutatorInfo russian = null, MutatorInfo french = null, MutatorInfo koreana = null);
```
```cs
Mutator myMutator2 = RogueLibs.SetMutator("WaterBullets", false,
new MutatorInfo("english name", "english description"),
new MutatorInfo("schinese", null),
null,
null,
new MutatorInfo(),
null,
null,
null);

// null strings will default to english.
// After doing that your mutator will appear in Mutator Menu at Home Base.
```
## Deleting Mutators ##
You can delete your custom Mutators:
```cs
public static bool DeleteMutator(Mutator mutator);
public static bool DeleteMutator(CustomMutator mutator);
public static bool DeleteMutator(string id);
```
You can use these in case you rename your mutator:
```cs
Mutator newMutator = RogueLibs.CreateMutator(...);
Mutator oldMutator = RogueLibs.GetMutator("oldName");
CustomMutator newMutator = RogueLibs.CreateMutator(...);
CustomMutator oldMutator = RogueLibs.GetMutator("oldName");
if (oldMutator.Unlocked)
newMutator.Unlocked = true;
RogueLibs.DeleteMutator("oldName");
// This will delete oldMutator's state from RogueLibs config file.
```
## Using Mutators ##
You can get your Mutator's Id:
If the removal of a CustomMutator was successful, methods return true, otherwise - false.
## Using CustomMutators ##
You can get your CustomMutator's Id:
```cs
public string Id { get; }
```
```cs
string myId = myMutator.Id;
```
You can get/set IsActive property of the Mutator:
You can get/set IsActive property of the CustomMutator:
```cs
public bool IsActive { get; set; }
```
Expand All @@ -69,7 +54,7 @@ if (myMutator.IsActive)
myMutator.IsActive = true;
// This will add your mutator to the active mutators list.
```
You can get/set Unlocked property of the Mutator:
You can get/set Unlocked property of the CustomMutator:
```cs
public bool Unlocked { get; set; }
```
Expand All @@ -83,7 +68,7 @@ myMutator.Unlocked = true;
// so the next time the game is loaded, this mutator will be already unlocked.
Logger.LogInfo("Player unlocked the mutator!");
```
You can also get/set ShowInMenu property of the Mutator:
You can also get/set ShowInMenu property of the CustomMutator:
```cs
public bool ShowInMenu { get; set; }
```
Expand All @@ -94,12 +79,12 @@ myMutator.ShowInMenu = false;
if (!myMutator.ShowInMenu)
Logger.LogWarn("The mutator is not showing in the menu!");
```
## Cancellations ##
You can add Conflicting Mutators - Mutators, that when enabled will automatically disable your Mutator, and will be automatically disabled when your Mutator is enabled.
## Conflicting Mutators ##
You can add Conflicting mutators - mutators, that when enabled will automatically disable your mutator, and will be automatically disabled when your mutator is enabled.
<br/>Basically, you won't be able to enable both of them at the same time:
```cs
public void AddConflicting(params string[] conflictingMutators);
public void AddConflicting(params Mutator[] conflictingMutators);
public void AddConflicting(params CustomMutator[] conflictingMutators);
```
```cs
rocketBulletsMutator.AddConflicting(waterBulletsMutator, noBulletsMutator);
Expand All @@ -110,40 +95,9 @@ rocketBulletsMutator.AddConflicting("NoGuns", "GorillaTown");
And of course, you can remove these Conflicting Mutators:
```cs
public void RemoveConflicting(params string[] conflictingMutators);
public void RemoveConflicting(params Mutator[] conflictingMutators);
```
There are also Cancellations and CancelledBy Mutators:
```cs
public void AddCancellations(params string[] cancellations);
public void AddCancellations(params Mutator[] cancellations);
public void AddCancelledBy(params string[] cancellations);
public void AddCancelledBy(params Mutator[] cancellations);
```
```cs
mutatorOne.AddCancellations(mutatorTwo);
// If you enable mutatorOne, mutatorTwo will be automatically disabled.
// But if you enable mutatorTwo, mutatorOne WON'T be disabled.
mutatorTwo.AddCancelledBy(mutatorThree);
// if you enable mutatorTwo, mutatorThree WON'T be automatically disabled.
// But if you enabled mutatorThree, mutatorTwo will be disabled.
```
There are Remove methods for these too:
```cs
public void RemoveCancellations(params string[] cancellations);
public void RemoveCancellations(params Mutator[] cancellations);
public void RemoveCancelledBy(params string[] cancellations);
public void RemoveCancelledBy(params Mutator[] cancellations);
```
By the way, you can access Cancellations and CancelledBy arrays yourself:
```cs
public string[] Cancellations { get; set; }
public string[] CancelledBy { get; set; }
```
```cs
// Conflicting methods just add the mutators to both of these arrays.
public void RemoveConflicting(params CustomMutator[] conflictingMutators);
```
## Custom Names ##
## CustomNames ##
You can access your Mutator's CustomNames:
```cs
public CustomName Name { get; set; }
Expand Down
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
2. [RogueLibs](https://github.com/Abbysssal/RogueLibs/blob/master/RogueLibs.md)
3. [Mutators](https://github.com/Abbysssal/RogueLibs/blob/master/Mutators.md)
4. [CustomNames](https://github.com/Abbysssal/RogueLibs/blob/master/CustomNames.md)
5. [RogueLibs Changelog](https://github.com/Abbysssal/RogueLibs/blob/master/Changelog.md)
5. [Extras](https://github.com/Abbysssal/RogueLibs/blob/master/Extras.md)
6. [RogueLibs Changelog](https://github.com/Abbysssal/RogueLibs/blob/master/Changelog.md)

## Links ##
* [RogueLibs on GitHub](https://github.com/Abbysssal/RogueLibs)
Expand All @@ -14,7 +15,7 @@
* [ECTD (Edit Characters Through Description)](https://github.com/Abbysssal/ECTD)
* Custom Loader - you can find this mod in #modding-gallery at [official Streets of Rogue Discord server](https://discord.com/invite/streetsofrogue)

# RogueLibs v1.0.1 #
# RogueLibs v1.1 #
This modding library allows you to easily add custom mutators and localization lines, plus it has some extra functions that you might need.

## How to use RogueLibs in your mods ##
Expand All @@ -30,26 +31,26 @@ using RogueLibsCore;
namespace RocketBulletsMutator
{
[BepInPlugin(pluginGuid, pluginName, pluginVersion)]
[BepInDependency(RogueLibs.pluginGuid, "1.0")]
[BepInDependency(RogueLibs.pluginGuid, "1.1")]
public class RocketBulletsMutator : BaseUnityPlugin
{
public const string pluginGuid = "abbysssal.streetsofrogue.rocketbulletsmutator";
public const string pluginName = "Rocket Bullets Mutator";
public const string pluginName = "Rocket Bullets Mutators";
public const string pluginVersion = "1.0";

public static Mutator RocketBulletsCommon { get; set; }
public static CustomMutator RocketBulletsCommon { get; set; }

protected void Awake()
{
RocketBulletsCommon = RogueLibs.SetMutator("RocketBulletsCommon", true,
new MutatorInfo("Rocket Bullets (Common weapons)", "Replaces common bullets (Pistol, Shotgun, Machinegun, etc.) with rockets. Rate of fire is unchanged."),
null,
null,
null,
null,
new MutatorInfo("Ракетные пули (Простое оружие)", "Заменяет простые пули (Пистолет, Дробовик, Автомат и т.п.) на ракеты. Скорость стрельбы не изменена."),
null,
null);
new CustomNameInfo("Rocket Bullets (Common weapons)",
null, null, null, null,
"Ракетные пули (Простое оружие)",
null, null),
new CustomNameInfo("Replaces common bullets (Pistol, Shotgun, Machinegun, etc.) with rockets. Rate of fire is unchanged.",
null, null, null, null,
"Заменяет простые пули (Пистолет, Дробовик, Автомат и т.п.) на ракеты. Скорость стрельбы не изменена.",
null, null));
RocketBulletsCommon.AddConflicting("RocketLaunchers", "NoGuns");

this.PatchPrefix(typeof(Gun), "spawnBullet", GetType(), "Gun_spawnBullet", new Type[] { typeof(bulletStatus), typeof(InvItem), typeof(int), typeof(bool), typeof(string) });
Expand Down
3 changes: 2 additions & 1 deletion RogueLibs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
2. **RogueLibs**
3. [Mutators](https://github.com/Abbysssal/RogueLibs/blob/master/Mutators.md)
4. [CustomNames](https://github.com/Abbysssal/RogueLibs/blob/master/CustomNames.md)
5. [RogueLibs Changelog](https://github.com/Abbysssal/RogueLibs/blob/master/Changelog.md)
5. [Extras](https://github.com/Abbysssal/RogueLibs/blob/master/Extras.md)
6. [RogueLibs Changelog](https://github.com/Abbysssal/RogueLibs/blob/master/Changelog.md)

## Faster Patches ##
You can replace this part of your code:
Expand Down

0 comments on commit 972a562

Please sign in to comment.