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 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; } }