//////////////// protected override void ReceiveOnClient() { var mymod = RewardsMod.Instance; var myworld = ModContent.GetInstance <RewardsWorld>(); KillData data = myworld.Logic.GetPlayerData(Main.LocalPlayer); if (data == null) { throw new ModHelpersException("No player data for " + Main.LocalPlayer.name); } NPC npc = new NPC(); npc.SetDefaults(this.NpcType); npc.boss = this.IsBoss; bool isGrind, isExpired; float reward = data.RecordKill(npc, out isGrind, out isExpired); if (mymod.SettingsConfig.DebugModeKillInfo) { int kills = data.KilledNpcs.ContainsKey(npc.type) ? data.KilledNpcs[npc.type] : -1; var npcDef = new NPCDefinition(npc.type); bool needsBoss = mymod.PointsConfig.NpcRewardRequiredAsBoss.Contains(npcDef); string msg = "ReceiveOnClient npc: " + npc.TypeName + " (" + npc.type + ")" + ", #: " + kills + ", isGrind: " + isGrind + ", isExpired: " + isExpired + ", reward: " + reward + ", needsBoss:" + needsBoss + " (is? " + npc.boss + ")"; Main.NewText(msg); LogHelpers.Log(" " + msg); } data.AddRewardForPlayer(Main.LocalPlayer, isGrind, isExpired, reward); }
public static void AddPoints(Player player, float points) { var mymod = RewardsMod.Instance; var myworld = ModContent.GetInstance <RewardsWorld>(); KillData data = myworld.Logic.GetPlayerData(player); if (data == null) { throw new ModHelpersException("No player data for " + player.name); } data.AddRewardForPlayer(player, false, false, points); }
//////////////// public override void Action(CommandCaller caller, string input, string[] args) { var mymod = (RewardsMod)this.mod; if (!mymod.SettingsConfig.DebugModeEnableCheats) { caller.Reply("Cheat mode not enabled.", Color.Yellow); return; } if (args.Length < 1) { caller.Reply("Insufficient arguments.", Color.Red); return; } float reward; if (!float.TryParse(args[0], out reward)) { caller.Reply("Invalid numeric parameter.", Color.Red); return; } var myworld = ModContent.GetInstance <RewardsWorld>(); KillData data = myworld.Logic.GetPlayerData(Main.LocalPlayer); if (data == null) { throw new ModHelpersException("Rewards - AddPointsCommand.Action() - No player data for " + Main.LocalPlayer.name); } data.AddRewardForPlayer(Main.LocalPlayer, false, false, reward); caller.Reply("+" + reward + " PP added. Cheater!", Color.LimeGreen); }