mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-07 08:49:15 +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
|
@ -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,24 +25,38 @@ 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 (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;
|
||||
}
|
||||
|
||||
stickerData.Cleanup();
|
||||
_playerStickers.Remove(stickerData.PlayerId);
|
||||
|
||||
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