When registering a card you can set a custom two character abbreviation to be displayed in the card bar, simply do the following:
CustomCard.BuildCard<ExampleCard>(c => c.SetAbbreviation("Ex"));- An exception will be thrown if the string passed is null or only whitespace characters.
- If the abbreviation passed is longer than 2 characters it will be truncated.
Simply extend PlayerHook to define your custom behaviors then attach it to a player.
public class ExampleHooks : PlayerHook
{
override void OnJump()
{
UnityEngine.Debug.Log("Player jumped!");
}
public override IEnumerator OnBattleStart(IGameModeHandler gameModeHandler)
{
yield return new WaitForSeconds(5f);
UnityEngine.Debug.Log("The battle started 5 seconds ago!");
}
}Make a card with fewer lines by extending SimpleCard instead of CustomCard!
using UnityEngine;
using ModsPlus;
public class ExampleCard : SimpleCard
{
public override CardDetails Details => new CardDetails
{
Title = "Example Card",
Description = "Your first effect card",
ModName = "<Your Mod ID>",
Art = Assets.YourCoolArt,
Rarity = CardInfo.Rarity.Common,
Theme = CardThemeColor.CardThemeColorType.TechWhite
};
public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers, Block block)
{
statModifiers.health = 0.5f;
gun.damage = 2f;
}
protected override void Added(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
{
Debug.Log("Card added to the player!");
}
protected override void Removed(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
{
Debug.Log("Card removed from the player!");
}
}Do you find yourself writing the same boilerplate over and over when defining cards that attach a MonoBehaviour to the player?
Are you tired of writing the same code for registering and deregistering actions (such as Block::BlockAction or Gun::ShootProjectileAction) repeatedly?
If so, then this is the library for you.
All actions will be automatically registered and deregistered when the card is added or removed, so you can focus on your cool features!
using UnityEngine;
using ModsPlus;
public class ExampleCard : CustomEffectCard<ExampleEffect>
{
public override CardDetails Details => new CardDetails
{
Title = "Example Card",
Description = "Your first effect card",
ModName = "<Your Mod ID>",
Art = Assets.YourCoolArt,
Rarity = CardInfo.Rarity.Common,
Theme = CardThemeColor.CardThemeColorType.TechWhite
};
}
public class ExampleEffect : CardEffect
{
public override void OnBlock(BlockTrigger.BlockTriggerType trigger)
{
Debug.Log("[ExampleEffect] Player blocked!");
}
public override void OnShoot(GameObject projectile)
{
Debug.Log("[ExampleEffect] Player fired a shot!");
}
}Once defined you can register this card as you normally would:
CustomCard.BuildCard<ExampleCard>();For additional overrides check your IDE's auto-complete, or view the source code
This interface allows you to easily create selectors on players and react when the user clicks one (think Cards+ "Adware" or "Quickhack" abilities for reference)
/* make selectors on a specific player */
int playerID; // ID of any specific player
var targets = PlayerManager.instance.players.Where(p => p.playerID == playerID);
PlayerSelector.InstantiateOn(Assets.SingleTargetSelector, targets, selectedPlayer =>
{
Debug.Log($"Friendly with ID {selectedPlayer.playerID} selected!");
});
/* make selectors on friends */
PlayerSelector.InstantiateOnFriendlies(Assets.FriendlySelector, selectedPlayer =>
{
Debug.Log($"Friendly with ID {selectedPlayer.playerID} selected!");
});
/* make selectors on enemies */
PlayerSelector.InstantiateOnEnemies(Assets.EnemySelector, selectedPlayer =>
{
Debug.Log($"Enemy with ID {selectedPlayer.playerID} selected!");
});The GameObject provided to the utility will be instantiated as a child of each target. It can contain any effects (particles, etc.) you wish, but must have some type of Collider3D on it for clicks to be detected
This component provides a wrapper around the base game's HealthBar class, giving you full control of the values to display and when to update them.
GameObject target; // any GameObject you wish to add a health bar to
float startingHp = 100;
float startingMaxHp = 100;
// create the health bar
var healthBar = target.AddComponent<CustomHealthBar>();
// set initial values
healthBar.SetValues(startingHp, startingMaxHp);
// take 10 damage
healthBar.CurrentHealth -= 10;- Added an extension method to
CardInfofor setting a custom abbreviation to be displayed in theCardBarButton
- Added
VisibleFromextension methods toPlayer
- Made
Awakemethod inPlayerHookoverridable - Made
StatChangesserializable by the Unity inspector
- Added
PlayerHookclass
- Updated to incorporate changes in newest version of ModdingUtils
- Fixed
MaxHealthchanges usingStatManagernot properly scaling current health
- Added
OnBulletHitandOnBulletHitCoroutineevents toCardEffect
- Fixed the
StatManagerusing the wrong stat for jump count
- Added Jump hook to
CardEffect - Implemented the
StatManagerbeta for simple-inline declaration ofReversibleEffects
- Added Game Mode hooks
- Added
SimpleCard
- Initial release