mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-26 01:57:51 +03:00
# Description This is a port of https://github.com/WWhiteDreamProject/wwdpublic/pull/11 from White Dream. This feature selects random items in the traitor uplink each round to be discounted and moved to the Discount tab, which are the same for every traitor. This in theory helps encourage players to be spontaneous, and use items that they otherwise might not normally consider using, which helps mix things up from round to round. <details><summary><h1>Media</h1></summary> <p> > # Описание PR > Порт скидок в аплинке. > > # Изменения > 🆑 Spatison > > * add: Added discounts in uplink / Добавлены скидки в аплинк </p> </details> # Changelog 🆑 Spatison add: Added discounts in uplink / Добавлены скидки в аплинк --------- Signed-off-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: Spatison <137375981+Spatison@users.noreply.github.com> Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com>
46 lines
2.0 KiB
C#
46 lines
2.0 KiB
C#
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Shared.Store;
|
|
|
|
public static class ListingLocalisationHelpers
|
|
{
|
|
/// <summary>
|
|
/// ListingData's Name field can be either a localisation string or the actual entity's name.
|
|
/// This function gets a localised name from the localisation string if it exists, and if not, it gets the entity's name.
|
|
/// If neither a localised string exists, or an associated entity name, it will return the value of the "Name" field.
|
|
/// </summary>
|
|
public static string GetLocalisedNameOrEntityName(ListingData listingData, IPrototypeManager prototypeManager)
|
|
{
|
|
var name = string.Empty;
|
|
|
|
if (listingData.Name != null)
|
|
name = Loc.GetString(listingData.Name);
|
|
else if (listingData.ProductEntity != null)
|
|
name = prototypeManager.Index(listingData.ProductEntity.Value).Name;
|
|
|
|
if (listingData.DiscountValue > 0)
|
|
name += " " + Loc.GetString("store-sales-amount", ("amount", listingData.DiscountValue));
|
|
else if (listingData.OldCost.Count > 0)
|
|
name += " " + Loc.GetString("store-sales-over");
|
|
|
|
return name;
|
|
}
|
|
|
|
/// <summary>
|
|
/// ListingData's Description field can be either a localisation string or the actual entity's description.
|
|
/// This function gets a localised description from the localisation string if it exists, and if not, it gets the entity's description.
|
|
/// If neither a localised string exists, or an associated entity description, it will return the value of the "Description" field.
|
|
/// </summary>
|
|
public static string GetLocalisedDescriptionOrEntityDescription(ListingData listingData, IPrototypeManager prototypeManager)
|
|
{
|
|
var desc = string.Empty;
|
|
|
|
if (listingData.Description != null)
|
|
desc = Loc.GetString(listingData.Description);
|
|
else if (listingData.ProductEntity != null)
|
|
desc = prototypeManager.Index(listingData.ProductEntity.Value).Description;
|
|
|
|
return desc;
|
|
}
|
|
}
|