mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 06:19:22 +00:00
Stickers: Added back Identify button
This commit is contained in:
parent
2f65634031
commit
192ba3cceb
4 changed files with 39 additions and 43 deletions
|
@ -15,8 +15,8 @@ public static partial class BTKUIAddon
|
|||
{
|
||||
Category category = QuickMenuAPI.PlayerSelectPage.AddCategory(ModSettings.SM_SettingsCategory, ModSettings.ModName);
|
||||
|
||||
//Button identifyButton = category.AddButton("Identify Stickers", "Stickers-magnifying-glass", "Identify this players stickers by making them flash.");
|
||||
//identifyButton.OnPress += OnPressIdentifyPlayerStickersButton;
|
||||
Button identifyButton = category.AddButton("Identify Stickers", "Stickers-magnifying-glass", "Identify this players stickers by making them flash.");
|
||||
identifyButton.OnPress += OnPressIdentifyPlayerStickersButton;
|
||||
|
||||
Button clearStickersButton = category.AddButton("Clear Stickers", "Stickers-eraser", "Clear this players stickers.");
|
||||
clearStickersButton.OnPress += OnPressClearSelectedPlayerStickersButton;
|
||||
|
@ -30,11 +30,11 @@ public static partial class BTKUIAddon
|
|||
|
||||
#region Callbacks
|
||||
|
||||
// private static void OnPressIdentifyPlayerStickersButton()
|
||||
// {
|
||||
// if (string.IsNullOrEmpty(QuickMenuAPI.SelectedPlayerID)) return;
|
||||
// StickerSystem.Instance.OnStickerIdentifyReceived(QuickMenuAPI.SelectedPlayerID);
|
||||
// }
|
||||
private static void OnPressIdentifyPlayerStickersButton()
|
||||
{
|
||||
if (string.IsNullOrEmpty(QuickMenuAPI.SelectedPlayerID)) return;
|
||||
StickerSystem.Instance.OnStickerIdentifyReceived(QuickMenuAPI.SelectedPlayerID);
|
||||
}
|
||||
|
||||
private static void OnPressClearSelectedPlayerStickersButton()
|
||||
{
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace NAK.Stickers
|
|||
public readonly string PlayerId;
|
||||
public float LastPlacedTime;
|
||||
public float DeathTime = -1f;
|
||||
public float IdentifyTime = -1f;
|
||||
|
||||
private Vector3 _lastPlacedPosition = Vector3.zero;
|
||||
|
||||
|
@ -200,22 +201,5 @@ namespace NAK.Stickers
|
|||
material.color = color;
|
||||
}
|
||||
}
|
||||
|
||||
#region shitty identify
|
||||
|
||||
public void Identify()
|
||||
{
|
||||
Color color = Color.HSVToRGB(Time.time % 1f, 1f, 1f);
|
||||
foreach (Material material in _materials)
|
||||
material.color = color; // cycle rainbow
|
||||
}
|
||||
|
||||
public void ResetIdentify()
|
||||
{
|
||||
foreach (Material material in _materials)
|
||||
material.color = Color.white;
|
||||
}
|
||||
|
||||
#endregion shitty identify
|
||||
}
|
||||
}
|
|
@ -42,7 +42,7 @@ public partial class StickerSystem
|
|||
|
||||
CVRGameEventSystem.Player.OnJoinEntity.AddListener(Instance.OnPlayerJoined);
|
||||
CVRGameEventSystem.Player.OnLeaveEntity.AddListener(Instance.OnPlayerLeft);
|
||||
SchedulerSystem.AddJob(Instance.OnOccasionalUpdate, 10f, 1f);
|
||||
SchedulerSystem.AddJob(Instance.OnUpdate, 10f, -1);
|
||||
LoadAllImagesAtStartup();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,16 +25,15 @@ public partial class StickerSystem
|
|||
stickerData.SetAlpha(1f);
|
||||
}
|
||||
|
||||
private void OnOccasionalUpdate()
|
||||
private void OnUpdate()
|
||||
{
|
||||
float currentTime = Time.time;
|
||||
for (int i = 0; i < _playerStickers.Values.Count; i++)
|
||||
{
|
||||
StickerData stickerData = _playerStickers.Values.ElementAt(i);
|
||||
|
||||
if (stickerData.DeathTime < 0f)
|
||||
continue;
|
||||
|
||||
if (stickerData.DeathTime > 0f)
|
||||
{
|
||||
if (currentTime < stickerData.DeathTime)
|
||||
{
|
||||
stickerData.SetAlpha(Mathf.Lerp(0f, 1f, (stickerData.DeathTime - currentTime) / StickerKillTime));
|
||||
|
@ -43,6 +42,21 @@ public partial class StickerSystem
|
|||
|
||||
stickerData.Cleanup();
|
||||
_playerStickers.Remove(stickerData.PlayerId);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (stickerData.IdentifyTime > 0)
|
||||
{
|
||||
if (currentTime < stickerData.IdentifyTime)
|
||||
{
|
||||
// blink alpha 3 times but not completely off
|
||||
stickerData.SetAlpha(Mathf.Lerp(0.2f, 1f, Mathf.PingPong((stickerData.IdentifyTime - currentTime) * 2f, 1f)));
|
||||
continue;
|
||||
}
|
||||
|
||||
stickerData.SetAlpha(1f);
|
||||
stickerData.IdentifyTime = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,15 +73,13 @@ public partial class StickerSystem
|
|||
public void OnStickerClearAllReceived(string playerId)
|
||||
=> ClearStickersForPlayer(playerId);
|
||||
|
||||
// public void OnStickerIdentifyReceived(string playerId)
|
||||
// {
|
||||
// if (!_playerStickers.TryGetValue(playerId, out StickerData stickerData))
|
||||
// return;
|
||||
//
|
||||
// // todo: make prettier (idk shaders)
|
||||
// SchedulerSystem.AddJob(() => stickerData.Identify(), 0f, 0.1f, 30);
|
||||
// SchedulerSystem.AddJob(() => stickerData.ResetIdentify(), 4f, 1f, 1);
|
||||
// }
|
||||
public void OnStickerIdentifyReceived(string playerId)
|
||||
{
|
||||
if (!_playerStickers.TryGetValue(playerId, out StickerData stickerData))
|
||||
return;
|
||||
|
||||
stickerData.IdentifyTime = Time.time + 3f;
|
||||
}
|
||||
|
||||
#endregion Player Callbacks
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue