mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-07 00:39:17 +00:00
Stickers: added lazy placement preview
This commit is contained in:
parent
d409bf1743
commit
9433779641
6 changed files with 157 additions and 19 deletions
|
@ -20,7 +20,7 @@ public partial class StickerSystem
|
|||
return stickerData;
|
||||
}
|
||||
|
||||
public void PlaceStickerFromControllerRay(Transform transform, CVRHand hand = CVRHand.Left)
|
||||
public void PlaceStickerFromControllerRay(Transform transform, CVRHand hand = CVRHand.Left, bool isPreview = false)
|
||||
{
|
||||
Vector3 controllerForward = transform.forward;
|
||||
Vector3 controllerUp = transform.up;
|
||||
|
@ -37,6 +37,12 @@ public partial class StickerSystem
|
|||
? Vector3.Slerp(controllerUp, playerUp, 0.99f)
|
||||
: controllerUp;
|
||||
|
||||
if (isPreview)
|
||||
{
|
||||
PlaceStickerPreview(transform.position, controllerForward, targetUp);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PlaceStickerSelf(transform.position, transform.forward, targetUp))
|
||||
return;
|
||||
|
||||
|
@ -53,7 +59,7 @@ public partial class StickerSystem
|
|||
return true;
|
||||
}
|
||||
|
||||
private bool AttemptPlaceSticker(string playerId, Vector3 position, Vector3 forward, Vector3 up, bool alignWithNormal = true, int stickerSlot = 0)
|
||||
private bool AttemptPlaceSticker(string playerId, Vector3 position, Vector3 forward, Vector3 up, bool alignWithNormal = true, int stickerSlot = 0, bool isPreview = false)
|
||||
{
|
||||
StickerData stickerData = GetOrCreateStickerData(playerId);
|
||||
if (Time.time - stickerData.LastPlacedTime < StickerCooldown)
|
||||
|
@ -69,6 +75,12 @@ public partial class StickerSystem
|
|||
if (hit.transform.gameObject.name.StartsWith("[NoSticker]"))
|
||||
return false;
|
||||
|
||||
if (isPreview)
|
||||
{
|
||||
stickerData.PlacePreview(hit, alignWithNormal ? -hit.normal : forward, up, stickerSlot);
|
||||
return true;
|
||||
}
|
||||
|
||||
stickerData.Place(hit, alignWithNormal ? -hit.normal : forward, up, stickerSlot);
|
||||
stickerData.PlayAudio();
|
||||
return true;
|
||||
|
@ -154,6 +166,25 @@ public partial class StickerSystem
|
|||
_playerStickers.Clear();
|
||||
_playerStickers[PlayerLocalId] = localStickerData;
|
||||
}
|
||||
|
||||
public void PlaceStickerPreview(Vector3 position, Vector3 forward, Vector3 up)
|
||||
{
|
||||
AttemptPlaceSticker(PlayerLocalId, position, forward, up, true, SelectedStickerSlot, true);
|
||||
}
|
||||
|
||||
public void UpdateStickerPreview()
|
||||
{
|
||||
if (!IsInStickerMode) return;
|
||||
|
||||
StickerData localStickerData = GetOrCreateStickerData(PlayerLocalId);
|
||||
localStickerData.UpdatePreview(SelectedStickerSlot);
|
||||
}
|
||||
|
||||
public void ClearStickerPreview()
|
||||
{
|
||||
StickerData localStickerData = GetOrCreateStickerData(PlayerLocalId);
|
||||
localStickerData.ClearPreview();
|
||||
}
|
||||
|
||||
#endregion Sticker Lifecycle
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue