generated from Valheim-Modding/JotunnModStub
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2.5.0: Implement spawning of catapult; add console command to spawn m…
…ercenaries in with armor; begin preparation for Mac OS X
- Loading branch information
Showing
16 changed files
with
268 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
using ChebsMercenaries.Minions; | ||
using ChebsValheimLibrary.Minions; | ||
using Jotunn.Entities; | ||
using Jotunn.Managers; | ||
|
||
namespace ChebsMercenaries.Commands | ||
{ | ||
public class SpawnMerc : ConsoleCommand | ||
{ | ||
public override string Name => "chebgonaz_spawnmerc"; | ||
|
||
public override string Help => "Requires admin. Spawn a mercenary. Case insensitive.\n" + | ||
$"Usage: {Name} [TYPE={TypesAsString()}] [ARMOR={ArmorsAsString()}]\n" + | ||
$"eg. {Name} WarriorTier1 Bronze"; | ||
|
||
private static string TypesAsString() | ||
{ | ||
var values = Enum.GetValues(typeof(MercenaryMinion.MercenaryType)).Cast<MercenaryMinion.MercenaryType>(); | ||
return string.Join("|", values); | ||
} | ||
|
||
private static string ArmorsAsString() | ||
{ | ||
var values = Enum.GetValues(typeof(ChebGonazMinion.ArmorType)).Cast<ChebGonazMinion.ArmorType>(); | ||
return string.Join("|", values); | ||
} | ||
|
||
private static Dictionary<string, MercenaryMinion.MercenaryType> _mercTypeLookup; | ||
private static Dictionary<string, ChebGonazMinion.ArmorType> _armorTypeLookup; | ||
|
||
public override void Run(string[] args) | ||
{ | ||
if (!SynchronizationManager.Instance.PlayerIsAdmin) | ||
{ | ||
Console.instance.Print("Only admins can run this command."); | ||
return; | ||
} | ||
|
||
if (args.Length < 1) | ||
{ | ||
Console.instance.Print(Help); | ||
return; | ||
} | ||
|
||
if (_mercTypeLookup == null) | ||
{ | ||
_mercTypeLookup = new Dictionary<string, MercenaryMinion.MercenaryType>(); | ||
foreach (MercenaryMinion.MercenaryType mercType in Enum.GetValues(typeof(MercenaryMinion.MercenaryType))) | ||
{ | ||
var key = mercType.ToString().ToLower(); | ||
_mercTypeLookup.Add(key, mercType); | ||
} | ||
} | ||
|
||
if (_armorTypeLookup == null) | ||
{ | ||
_armorTypeLookup = new Dictionary<string, ChebGonazMinion.ArmorType>(); | ||
foreach (ChebGonazMinion.ArmorType armorType in Enum.GetValues(typeof(ChebGonazMinion.ArmorType))) | ||
{ | ||
var key = armorType.ToString().ToLower(); | ||
_armorTypeLookup.Add(key, armorType); | ||
} | ||
} | ||
|
||
var chosenMerc = MercenaryMinion.MercenaryType.None; | ||
if (!_mercTypeLookup.TryGetValue(args[0].ToLower(), out chosenMerc)) | ||
{ | ||
Console.instance.Print($"Invalid type: {args[0]}. Valid options: {TypesAsString()}"); | ||
return; | ||
} | ||
|
||
var chosenArmor = ChebGonazMinion.ArmorType.None; | ||
if (args.Length >= 2) | ||
{ | ||
if (!_armorTypeLookup.TryGetValue(args[1].ToLower(), out chosenArmor)) | ||
{ | ||
Console.instance.Print($"Invalid armor: {args[1]}. Valid options: {ArmorsAsString()}"); | ||
return; | ||
} | ||
} | ||
|
||
HumanMinion.Spawn(chosenMerc, chosenArmor, Player.m_localPlayer.transform); | ||
} | ||
|
||
public override List<string> CommandOptionList() | ||
{ | ||
return ZNetScene.instance?.GetPrefabNames(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.