private void Gather(BasePlayer player, string command, string[] args) { var help = HelpTextPlayer; if (GatherResourceModifiers.Count == 0 && SurveyResourceModifiers.Count == 0 && PickupResourceModifiers.Count == 0 && QuarryResourceModifiers.Count == 0) { help += HelpTextPlayerDefault; } else { if (GatherResourceModifiers.Count > 0) { var dispensers = string.Format(HelpTextPlayerGains, Dispensers); dispensers = GatherResourceModifiers.Aggregate(dispensers, (current, entry) => current + ("\r\n " + entry.Key + ": x" + entry.Value)); help += "\r\n" + dispensers; } if (PickupResourceModifiers.Count > 0) { var pickups = string.Format(HelpTextPlayerGains, Pickups); pickups = PickupResourceModifiers.Aggregate(pickups, (current, entry) => current + ("\r\n " + entry.Key + ": x" + entry.Value)); help += "\r\n" + pickups; } if (QuarryResourceModifiers.Count > 0) { var quarries = string.Format(HelpTextPlayerGains, Quarries); quarries = QuarryResourceModifiers.Aggregate(quarries, (current, entry) => current + ("\r\n " + entry.Key + ": x" + entry.Value)); help += "\r\n" + quarries; } if (ExcavatorResourceModifiers.Count > 0) { var excavators = string.Format(HelpTextPlayerGains, Excavators); excavators = ExcavatorResourceModifiers.Aggregate(excavators, (current, entry) => current + ("\r\n " + entry.Key + ": x" + entry.Value)); help += "\r\n" + excavators; } if (SurveyResourceModifiers.Count > 0) { var charges = string.Format(HelpTextPlayerGains, Charges); charges = SurveyResourceModifiers.Aggregate(charges, (current, entry) => current + ("\r\n " + entry.Key + ": x" + entry.Value)); help += "\r\n" + charges; } } if (MiningQuarryResourceTickRate != DefaultMiningQuarryResourceTickRate) { help += "\r\n" + string.Format(HelpTextPlayerMiningQuarrySpeed, MiningQuarryResourceTickRate); } SendMessage(player, help); if (!player.IsAdmin) { return; } SendMessage(player, HelpTextAdmin); }
private void OnSurveyGather(SurveyCharge surveyCharge, Item item) { if (SurveyResourceModifiers.ContainsKey(item.info.displayName.english)) { item.amount = (int)(item.amount * SurveyResourceModifiers[item.info.displayName.english]); } else if (SurveyResourceModifiers.ContainsKey("*")) { item.amount = (int)(item.amount * SurveyResourceModifiers["*"]); } }
private void OnSurveyGather(SurveyCharge surveyCharge, Item item) { float modifier; if (SurveyResourceModifiers.TryGetValue(item.info.displayName.english, out modifier)) { item.amount = (int)(item.amount * modifier); } else if (SurveyResourceModifiers.TryGetValue("*", out modifier)) { item.amount = (int)(item.amount * modifier); } }
private void GatherRate(ConsoleSystem.Arg arg) { if (arg.Player() != null && !arg.Player().IsAdmin) { arg.ReplyWith(NotAllowed); return; } var subcommand = arg.GetString(0).ToLower(); if (!arg.HasArgs(3) || !subcommands.Contains(subcommand)) { arg.ReplyWith(InvalidArgumentsGather); return; } if (!validResources[arg.GetString(1).ToLower()] && arg.GetString(1) != "*") { arg.ReplyWith(string.Format(InvalidResource, arg.GetString(1))); return; } var resource = validResources[arg.GetString(1).ToLower()]?.displayName.english ?? "*"; var modifier = arg.GetFloat(2, -1); var remove = false; if (modifier < 0) { if (arg.GetString(2).ToLower() == "remove") { remove = true; } else { arg.ReplyWith(InvalidModifier); return; } } switch (subcommand) { case "dispenser": if (remove) { if (GatherResourceModifiers.ContainsKey(resource)) { GatherResourceModifiers.Remove(resource); } arg.ReplyWith(string.Format(ModifyResourceRemove, resource, Dispensers)); } else { if (GatherResourceModifiers.ContainsKey(resource)) { GatherResourceModifiers[resource] = modifier; } else { GatherResourceModifiers.Add(resource, modifier); } arg.ReplyWith(string.Format(ModifyResource, resource, modifier, Dispensers)); } SetConfigValue("Options", "GatherResourceModifiers", GatherResourceModifiers); break; case "pickup": if (remove) { if (PickupResourceModifiers.ContainsKey(resource)) { PickupResourceModifiers.Remove(resource); } arg.ReplyWith(string.Format(ModifyResourceRemove, resource, Pickups)); } else { if (PickupResourceModifiers.ContainsKey(resource)) { PickupResourceModifiers[resource] = modifier; } else { PickupResourceModifiers.Add(resource, modifier); } arg.ReplyWith(string.Format(ModifyResource, resource, modifier, Pickups)); } SetConfigValue("Options", "PickupResourceModifiers", PickupResourceModifiers); break; case "quarry": if (remove) { if (QuarryResourceModifiers.ContainsKey(resource)) { QuarryResourceModifiers.Remove(resource); } arg.ReplyWith(string.Format(ModifyResourceRemove, resource, Quarries)); } else { if (QuarryResourceModifiers.ContainsKey(resource)) { QuarryResourceModifiers[resource] = modifier; } else { QuarryResourceModifiers.Add(resource, modifier); } arg.ReplyWith(string.Format(ModifyResource, resource, modifier, Quarries)); } SetConfigValue("Options", "QuarryResourceModifiers", QuarryResourceModifiers); break; case "excavator": if (remove) { if (ExcavatorResourceModifiers.ContainsKey(resource)) { ExcavatorResourceModifiers.Remove(resource); } arg.ReplyWith(string.Format(ModifyResourceRemove, resource, Excavators)); } else { if (ExcavatorResourceModifiers.ContainsKey(resource)) { ExcavatorResourceModifiers[resource] = modifier; } else { ExcavatorResourceModifiers.Add(resource, modifier); } arg.ReplyWith(string.Format(ModifyResource, resource, modifier, Excavators)); } SetConfigValue("Options", "ExcavatorResourceModifiers", ExcavatorResourceModifiers); break; case "survey": if (remove) { if (SurveyResourceModifiers.ContainsKey(resource)) { SurveyResourceModifiers.Remove(resource); } arg.ReplyWith(string.Format(ModifyResourceRemove, resource, Charges)); } else { if (SurveyResourceModifiers.ContainsKey(resource)) { SurveyResourceModifiers[resource] = modifier; } else { SurveyResourceModifiers.Add(resource, modifier); } arg.ReplyWith(string.Format(ModifyResource, resource, modifier, Charges)); } SetConfigValue("Options", "SurveyResourceModifiers", SurveyResourceModifiers); break; } }