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);
|
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.");
|
Button identifyButton = category.AddButton("Identify Stickers", "Stickers-magnifying-glass", "Identify this players stickers by making them flash.");
|
||||||
//identifyButton.OnPress += OnPressIdentifyPlayerStickersButton;
|
identifyButton.OnPress += OnPressIdentifyPlayerStickersButton;
|
||||||
|
|
||||||
Button clearStickersButton = category.AddButton("Clear Stickers", "Stickers-eraser", "Clear this players stickers.");
|
Button clearStickersButton = category.AddButton("Clear Stickers", "Stickers-eraser", "Clear this players stickers.");
|
||||||
clearStickersButton.OnPress += OnPressClearSelectedPlayerStickersButton;
|
clearStickersButton.OnPress += OnPressClearSelectedPlayerStickersButton;
|
||||||
|
@ -30,11 +30,11 @@ public static partial class BTKUIAddon
|
||||||
|
|
||||||
#region Callbacks
|
#region Callbacks
|
||||||
|
|
||||||
// private static void OnPressIdentifyPlayerStickersButton()
|
private static void OnPressIdentifyPlayerStickersButton()
|
||||||
// {
|
{
|
||||||
// if (string.IsNullOrEmpty(QuickMenuAPI.SelectedPlayerID)) return;
|
if (string.IsNullOrEmpty(QuickMenuAPI.SelectedPlayerID)) return;
|
||||||
// StickerSystem.Instance.OnStickerIdentifyReceived(QuickMenuAPI.SelectedPlayerID);
|
StickerSystem.Instance.OnStickerIdentifyReceived(QuickMenuAPI.SelectedPlayerID);
|
||||||
// }
|
}
|
||||||
|
|
||||||
private static void OnPressClearSelectedPlayerStickersButton()
|
private static void OnPressClearSelectedPlayerStickersButton()
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,6 +12,7 @@ namespace NAK.Stickers
|
||||||
public readonly string PlayerId;
|
public readonly string PlayerId;
|
||||||
public float LastPlacedTime;
|
public float LastPlacedTime;
|
||||||
public float DeathTime = -1f;
|
public float DeathTime = -1f;
|
||||||
|
public float IdentifyTime = -1f;
|
||||||
|
|
||||||
private Vector3 _lastPlacedPosition = Vector3.zero;
|
private Vector3 _lastPlacedPosition = Vector3.zero;
|
||||||
|
|
||||||
|
@ -200,22 +201,5 @@ namespace NAK.Stickers
|
||||||
material.color = color;
|
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.OnJoinEntity.AddListener(Instance.OnPlayerJoined);
|
||||||
CVRGameEventSystem.Player.OnLeaveEntity.AddListener(Instance.OnPlayerLeft);
|
CVRGameEventSystem.Player.OnLeaveEntity.AddListener(Instance.OnPlayerLeft);
|
||||||
SchedulerSystem.AddJob(Instance.OnOccasionalUpdate, 10f, 1f);
|
SchedulerSystem.AddJob(Instance.OnUpdate, 10f, -1);
|
||||||
LoadAllImagesAtStartup();
|
LoadAllImagesAtStartup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,24 +25,38 @@ public partial class StickerSystem
|
||||||
stickerData.SetAlpha(1f);
|
stickerData.SetAlpha(1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnOccasionalUpdate()
|
private void OnUpdate()
|
||||||
{
|
{
|
||||||
float currentTime = Time.time;
|
float currentTime = Time.time;
|
||||||
for (int i = 0; i < _playerStickers.Values.Count; i++)
|
for (int i = 0; i < _playerStickers.Values.Count; i++)
|
||||||
{
|
{
|
||||||
StickerData stickerData = _playerStickers.Values.ElementAt(i);
|
StickerData stickerData = _playerStickers.Values.ElementAt(i);
|
||||||
|
|
||||||
if (stickerData.DeathTime < 0f)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (currentTime < stickerData.DeathTime)
|
if (stickerData.DeathTime > 0f)
|
||||||
{
|
{
|
||||||
stickerData.SetAlpha(Mathf.Lerp(0f, 1f, (stickerData.DeathTime - currentTime) / StickerKillTime));
|
if (currentTime < stickerData.DeathTime)
|
||||||
|
{
|
||||||
|
stickerData.SetAlpha(Mathf.Lerp(0f, 1f, (stickerData.DeathTime - currentTime) / StickerKillTime));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
stickerData.Cleanup();
|
||||||
|
_playerStickers.Remove(stickerData.PlayerId);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
stickerData.Cleanup();
|
if (stickerData.IdentifyTime > 0)
|
||||||
_playerStickers.Remove(stickerData.PlayerId);
|
{
|
||||||
|
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)
|
public void OnStickerClearAllReceived(string playerId)
|
||||||
=> ClearStickersForPlayer(playerId);
|
=> ClearStickersForPlayer(playerId);
|
||||||
|
|
||||||
// public void OnStickerIdentifyReceived(string playerId)
|
public void OnStickerIdentifyReceived(string playerId)
|
||||||
// {
|
{
|
||||||
// if (!_playerStickers.TryGetValue(playerId, out StickerData stickerData))
|
if (!_playerStickers.TryGetValue(playerId, out StickerData stickerData))
|
||||||
// return;
|
return;
|
||||||
//
|
|
||||||
// // todo: make prettier (idk shaders)
|
stickerData.IdentifyTime = Time.time + 3f;
|
||||||
// SchedulerSystem.AddJob(() => stickerData.Identify(), 0f, 0.1f, 30);
|
}
|
||||||
// SchedulerSystem.AddJob(() => stickerData.ResetIdentify(), 4f, 1f, 1);
|
|
||||||
// }
|
|
||||||
|
|
||||||
#endregion Player Callbacks
|
#endregion Player Callbacks
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue