-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show ammo percentage of sentries #59
Comments
What do you specifically mean?
All should be possible, but not sure what exactly you are looking for. |
Ah I initially meant the third choice but any of these three are interesting options.... |
In the case of the third choice, I assume something like this can work (possibly wrapped under a Feature option or something): Just replace this area with something along the lines of: // Attach a behaviour to update marker name accordingly in real time
UpdateMarkerInfo info = navMarkerPlacer.gameObject.GetComponent<UpdateMarkerInfo>();
if (info == null)
{
info = navMarkerPlacer.gameObject.AddComponent<UpdateMarkerInfo>();
}
info.ammo = PlayerBackpackManager.GetBackpack(snetPlayer).AmmoStorage.GetInventorySlotAmmo(AmmoType.Class);
info.navMarkerPlacer = navMarkerPlacer;
info.sentry = __instance;
info.snetPlayer = snetPlayer; Then use a behaviour to update the marker: #if IL2CPP
public override void Init()
{
LoaderWrapper.ClassInjector.RegisterTypeInIl2Cpp<UpdateMarkerInfo>();
}
#endif
private class UpdateMarkerInfo : MonoBehaviour
{
public PlaceNavMarkerOnGO navMarkerPlacer;
public InventorySlotAmmo ammo;
public SentryGunInstance sentry;
public SNet_Player snetPlayer;
private void Update()
{
if (!navMarkerPlacer.m_marker.IsVisible) return;
var col = MARKER_GREEN;
var name = string.Empty;
if (Settings.DisplayPlayerNameAboveMarker)
{
name = $"<size={Settings.PlayerNameSize * 100f}%>{snetPlayer.NickName}</size>";
}
if (Settings.UsePlayerColorForMarkers)
{
col = snetPlayer.PlayerColor;
name = $"<#{ColorUtility.ToHtmlStringRGB(snetPlayer.PlayerColor)}>{name}</color>";
}
else
{
name = $"<color=white>{name}</color>";
}
var sentryArch = string.Empty;
if (Settings.ShowSentryArchetype)
{
int bulletsInPack = (int)(sentry.m_ammo / ammo.CostOfBullet);
int percentage = (int)(bulletsInPack * ammo.BulletsToRelConv * 100);
sentryArch = $"<color=white><size={Settings.PlayerNameSize * 100f}%>{sentry.ArchetypeName} [{percentage}%]</size></color>";
}
navMarkerPlacer.UpdateName(name, sentryArch);
navMarkerPlacer.UpdatePlayerColor(col);
}
} Ig for flavour you can alter this to change colour for different ammo states (green=full, yellow=medium/low, red=completely out) |
...is that possible?
The text was updated successfully, but these errors were encountered: