83 lines
2.2 KiB
C#
Raw Normal View History

2022-01-30 09:43:20 +00:00
using Cysharp.Threading.Tasks;
2022-01-21 21:54:58 +00:00
using QSB.Utility;
using QSB.WorldSync;
2022-01-30 09:43:20 +00:00
using System.Threading;
2022-01-21 21:54:58 +00:00
namespace QSB.EchoesOfTheEye.SlideProjectors.WorldObjects
2022-01-21 21:54:58 +00:00
{
public class QSBSlideProjector : WorldObject<SlideProjector>
{
public uint ControllingPlayer;
2022-01-21 21:54:58 +00:00
public override async UniTask Init(CancellationToken ct)
{
DebugLog.DebugWrite($"Init {this}");
}
2022-01-21 21:54:58 +00:00
public override void SendInitialState(uint to)
{
// todo SendInitialState
}
2022-01-30 09:43:20 +00:00
public void OnChangeAuthority(uint newOwner)
{
DebugLog.DebugWrite($"{this} change ControllingPlayer to {newOwner}");
}
public void NextSlide()
2022-01-30 09:43:20 +00:00
{
var hasChangedSlide = false;
if (AttachedObject._slideItem != null && AttachedObject._slideItem.slidesContainer.NextSlideAvailable())
2022-02-01 10:44:41 +00:00
{
hasChangedSlide = AttachedObject._slideItem.slidesContainer.IncreaseSlideIndex();
if (hasChangedSlide)
2022-02-01 10:44:41 +00:00
{
if (AttachedObject._oneShotSource != null)
{
AttachedObject._oneShotSource.PlayOneShot(AudioType.Projector_Next);
}
2022-02-01 10:44:41 +00:00
if (AttachedObject.IsProjectorFullyLit())
{
AttachedObject._slideItem.slidesContainer.SetCurrentRead();
AttachedObject._slideItem.slidesContainer.TryPlayMusicForCurrentSlideTransition(true);
}
2022-02-01 10:44:41 +00:00
}
}
if (AttachedObject._gearInterface != null)
{
var audioVolume = hasChangedSlide ? 0f : 0.5f;
AttachedObject._gearInterface.AddRotation(45f, audioVolume);
}
2022-02-01 10:44:41 +00:00
}
public void PreviousSlide()
2022-02-01 10:44:41 +00:00
{
var hasChangedSlide = false;
if (AttachedObject._slideItem != null && AttachedObject._slideItem.slidesContainer.PrevSlideAvailable())
2022-02-01 10:44:41 +00:00
{
hasChangedSlide = AttachedObject._slideItem.slidesContainer.DecreaseSlideIndex();
if (hasChangedSlide)
2022-02-01 10:44:41 +00:00
{
if (AttachedObject._oneShotSource != null)
{
AttachedObject._oneShotSource.PlayOneShot(AudioType.Projector_Prev);
}
2022-02-01 10:44:41 +00:00
if (AttachedObject.IsProjectorFullyLit())
{
AttachedObject._slideItem.slidesContainer.SetCurrentRead();
AttachedObject._slideItem.slidesContainer.TryPlayMusicForCurrentSlideTransition(false);
}
2022-02-01 10:44:41 +00:00
}
}
if (AttachedObject._gearInterface != null)
{
var audioVolume = hasChangedSlide ? 0f : 0.5f;
AttachedObject._gearInterface.AddRotation(-45f, audioVolume);
}
2022-01-21 21:54:58 +00:00
}
}
}