private static void CCGiveLunar(ConCommandArgs args) { if (args.sender == null) { Log.Message("Can't modify Lunar coins of other users directly.", LogLevel.Error); return; } int amount = 1; if (args.Count > 0) { amount = args.GetArgInt(0); } string str = "Nothing happened. Big suprise."; NetworkUser target = RoR2.Util.LookUpBodyNetworkUser(args.senderBody); if (amount > 0) { target.AwardLunarCoins((uint)amount); str = string.Format(Lang.GIVELUNAR_2, "Gave", amount); } if (amount < 0) { amount *= -1; target.DeductLunarCoins((uint)(amount)); str = string.Format(Lang.GIVELUNAR_2, "Removed", amount); } Log.MessageNetworked(str, args); }
private static void CCGiveLunar(ConCommandArgs args) { int amount = 1; if (args.Count > 0) { amount = args.GetArgInt(0); } if (amount == 0) { Log.Message("Nothing happened. Big suprise."); return; } NetworkUser target = Util.LookUpBodyNetworkUser(args.senderBody); if (amount > 0) { target.AwardLunarCoins((uint)amount); } if (amount < 0) { amount *= -1; target.DeductLunarCoins((uint)(amount)); } Log.Message(string.Format(MagicVars.GIVELUNAR_2, (amount > 0) ? "Gave" : "Deducted", amount)); }
private void GenericPickupController_GrantLunarCoin(On.RoR2.GenericPickupController.orig_GrantLunarCoin orig, GenericPickupController self, CharacterBody body, uint count) { if (!NetworkServer.active) { Debug.LogWarning("[Server] function 'System.Void RoR2.GenericPickupController::GrantLunarCoin(RoR2.CharacterBody,System.UInt32)' called on client"); return; } CharacterMaster master = body.master; NetworkUser networkUser = Util.LookUpBodyNetworkUser(body); if (networkUser) { if (master) { GenericPickupController.SendPickupMessage(master, self.pickupIndex); } networkUser.AwardLunarCoins(count); UnityEngine.Object.Destroy(self.gameObject); } else { if (master && master.teamIndex != TeamIndex.Player) { var component = master.GetBodyObject().GetComponent <DropInventoryOnDeath>(); if (!component) { component = master.GetBodyObject().AddComponent <DropInventoryOnDeath>(); } component.incrementCoins(); GenericPickupController.SendPickupMessage(master, self.pickupIndex); UnityEngine.Object.Destroy(self.gameObject); } } }
public override void Set(NetworkUser user, string value) { var v = uint.Parse(value); var c = user.lunarCoins; if (c > v) { user.DeductLunarCoins(c - v); } else if (c < v) { user.AwardLunarCoins(v - c); } }
internal void LoadPlayer(NetworkUser player) { var master = player.master; foreach (var minion in minions) { minion.LoadMinion(master); } var bodyPrefab = BodyCatalog.FindBodyPrefab(characterBodyName); master.bodyPrefab = bodyPrefab; loadout.LoadData(master.loadout); inventory.LoadInventory(master.inventory); if (ModSupport.IsSSLoaded) { ProperSavePlugin.Instance.StartCoroutine(LoadShareSuiteMoney(money)); } player.master.money = money; player.masterController.lunarCoinChanceMultiplier = lunarCoinChanceMultiplier; var stats = player.masterController.GetComponent <PlayerStatsComponent>().currentStats; for (var i = 0; i < statsFields.Length; i++) { var fieldValue = statsFields[i]; stats.SetStatValueFromString(StatDef.allStatDefs[i], fieldValue); } for (var i = 0; i < statsUnlockables.Length; i++) { var unlockableIndex = statsUnlockables[i]; stats.AddUnlockable(new UnlockableIndex(unlockableIndex)); } if (ModSupport.IsTLCLoaded || ModSupport.IsBDTLCLoaded) { Stage.onStageStartGlobal += ResetLunarCoins; void ResetLunarCoins(Stage stage) { Stage.onStageStartGlobal -= ResetLunarCoins; player.DeductLunarCoins(player.lunarCoins); player.AwardLunarCoins(lunarCoins); } } }
public void LoadPlayer(NetworkUser player) { foreach (var minion in minions) { minion.LoadMinion(player.master); } var bodyPrefab = BodyCatalog.FindBodyPrefab(characterBodyName); player.master.bodyPrefab = bodyPrefab; loadout.LoadData(player.master); inventory.LoadInventory(player.master); player.master.money = money; player.masterController.SetFieldValue("lunarCoinChanceMultiplier", lunarCoinChanceMultiplier); var stats = player.masterController.GetComponent <PlayerStatsComponent>().currentStats; for (var i = 0; i < statsFields.Length; i++) { var fieldValue = statsFields[i]; stats.SetStatValueFromString(StatDef.allStatDefs[i], fieldValue); } for (var i = 0; i < statsUnlockables.Length; i++) { var unlockableIndex = statsUnlockables[i]; stats.AddUnlockable(new UnlockableIndex(unlockableIndex)); } if (ProperSave.IsTLCDefined) { Stage.onStageStartGlobal += ResetLunarCoins; void ResetLunarCoins(Stage stage) { Stage.onStageStartGlobal -= ResetLunarCoins; player.DeductLunarCoins(player.lunarCoins); player.AwardLunarCoins(lunarCoins); } } }
private void Run_OnServerGameOver(Run run, GameResultType gameResultType) { if (gameResultType == GameResultType.Unknown || gameResultType == GameResultType.Won) { float multiplier = difconfigs[(int)run.selectedDifficulty]; float lunarcoins = (run.stageClearCount * multiplier) - 5f; if (lunarcoins > 0) { uint totalcoins = Convert.ToUInt32(Math.Ceiling(lunarcoins)); for (int i = 0; i < NetworkUser.readOnlyInstancesList.Count; i++) { NetworkUser networkUser = NetworkUser.readOnlyInstancesList[i]; if (networkUser && networkUser.isParticipating) { networkUser.AwardLunarCoins(totalcoins); } } } } }
private static void CCGiveLunar(ConCommandArgs args) { int amount = 1; if (args.Count > 0) { amount = args.GetArgInt(0); } string str = "Nothing happened. Big suprise."; NetworkUser target = Util.LookUpBodyNetworkUser(args.senderBody); if (amount > 0) { target.AwardLunarCoins((uint)amount); str = string.Format(Lang.GIVELUNAR_2, "Gave", amount); } if (amount < 0) { amount *= -1; target.DeductLunarCoins((uint)(amount)); str = string.Format(Lang.GIVELUNAR_2, "Removed", amount); } Log.Message(str, args); }
//uh, duh. private static void GiveLunarCoins() { LocalNetworkUser.AwardLunarCoins(coinsToGive); }