138 lines
2.9 KiB
C#
138 lines
2.9 KiB
C#
using BitStrap;
|
|
using UnityEngine;
|
|
|
|
public class RodStandTrigger : vp_Interactable
|
|
{
|
|
public GameObject Target;
|
|
|
|
public string TargetMessage = string.Empty;
|
|
|
|
public RodStand rodStand;
|
|
|
|
public int rodPlaceId;
|
|
|
|
[ReadOnly]
|
|
public bool canInteract = true;
|
|
|
|
[HideInInspector]
|
|
public MeshRenderer meshRenderer;
|
|
|
|
protected override void Start()
|
|
{
|
|
m_InteractCrosshair = null;
|
|
meshRenderer = GetComponent<MeshRenderer>();
|
|
base.Start();
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
UpdateSeeing(false);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (!FisheryEditor.Instance && UtilitiesInput.GetButtonDown("ROD_STAND_TAKE_ROD"))
|
|
{
|
|
TryInteract(null);
|
|
}
|
|
}
|
|
|
|
public override void UpdateSeeing(bool isSeeing)
|
|
{
|
|
if (isSeeingMe == isSeeing)
|
|
{
|
|
return;
|
|
}
|
|
if (GameController.Instance.fishingPlayer.currentHands.baitWasThrown && !GameController.Instance.fishingPlayer.currentHands.fishingRod.isOnRodStand)
|
|
{
|
|
isSeeing = false;
|
|
}
|
|
if (isSeeing)
|
|
{
|
|
FishingHands.rodStand.FixIsSeeing(rodPlaceId);
|
|
}
|
|
FishingRod componentInChildren = GetComponentInChildren<FishingRod>();
|
|
if ((bool)componentInChildren)
|
|
{
|
|
Material material = componentInChildren.bendObjects[0].GetComponent<Renderer>().material;
|
|
if (material.HasProperty("_EmissionColor"))
|
|
{
|
|
material.EnableKeyword("_EMISSION");
|
|
material.SetColor("_EmissionColor", (!isSeeing) ? Color.black : new Color(0.3f, 0.26f, 0.13f));
|
|
}
|
|
}
|
|
if (VRManager.IsVROn())
|
|
{
|
|
VRControllersManager.Instance.UpdateButtonInfo(VRInputManager.Instance.FindAction("ROD_STAND_TAKE_ROD"), (!isSeeing) ? string.Empty : Utilities.GetTranslation("HUD/TAKE"));
|
|
}
|
|
else
|
|
{
|
|
GameController.Instance.hudManager.ShowRodStandCursor(isSeeing);
|
|
}
|
|
base.UpdateSeeing(isSeeing);
|
|
}
|
|
|
|
public override bool TryInteract(vp_PlayerEventHandler player)
|
|
{
|
|
FishingPlayer fishingPlayer = GameController.Instance.fishingPlayer;
|
|
if (fishingPlayer.currentHands.baitWasThrown && !fishingPlayer.currentHands.fishingRod.isOnRodStand)
|
|
{
|
|
return false;
|
|
}
|
|
if (player != null)
|
|
{
|
|
return false;
|
|
}
|
|
if (!isSeeingMe)
|
|
{
|
|
return false;
|
|
}
|
|
if (!canInteract)
|
|
{
|
|
return false;
|
|
}
|
|
if ((bool)BugReporter.Instance && BugReporter.Instance.isVisible)
|
|
{
|
|
return false;
|
|
}
|
|
if (GameController.Instance.IsQuickMenu())
|
|
{
|
|
return false;
|
|
}
|
|
if (HUDManager.Instance.hudMultiplayer.isInInputMode)
|
|
{
|
|
return false;
|
|
}
|
|
if (HUDManager.Instance.currentHudState == HUDManager.HUDState.PAUSE)
|
|
{
|
|
return false;
|
|
}
|
|
if (!UtilitiesInput.GetButtonDown("ROD_STAND_TAKE_ROD"))
|
|
{
|
|
return false;
|
|
}
|
|
if (m_Player == null && player != null)
|
|
{
|
|
m_Player = player;
|
|
}
|
|
UpdateSeeing(false);
|
|
rodStand.TakeRod(rodPlaceId);
|
|
return true;
|
|
}
|
|
|
|
public void ShowVisual(bool show)
|
|
{
|
|
if ((bool)meshRenderer)
|
|
{
|
|
meshRenderer.enabled = show;
|
|
}
|
|
}
|
|
|
|
protected override void OnTriggerEnter(Collider col)
|
|
{
|
|
if (InteractType == vp_InteractType.Trigger)
|
|
{
|
|
}
|
|
}
|
|
}
|