-
Notifications
You must be signed in to change notification settings - Fork 0
/
Assets__Scripts_Gameplay_MiniGames_CrabPotPulling_GrapplingHookSlot_GrapplingHookSlot.cs
99 lines (80 loc) · 2.86 KB
/
Assets__Scripts_Gameplay_MiniGames_CrabPotPulling_GrapplingHookSlot_GrapplingHookSlot.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
namespace Moonlit.DeadliestCatch.Gameplay.MiniGames.CrabPotPulling
{
using Interaction;
using Equipment;
using UnityEngine;
using GameEvents;
using System;
using Rewired;
// TODO: Would be nice to have more than one slot on the Ship. @karol
public sealed class GrapplingHookSlot
{
#region Public Types
public sealed class HookTakenArgs : GameEventArgs
{
public GrapplingHook Hook { get; }
public HookTakenArgs(GrapplingHook hook)
{
Hook = hook;
}
}
public sealed class HookPutAwayArgs : GameEventArgs
{
public GrapplingHook Hook { get; }
public HookPutAwayArgs(GrapplingHook hook)
{
Hook = hook;
}
}
public sealed class MiniGameStartedArgs : GameEventArgs
{
public Player Player;
public MiniGameStartedArgs(Player player)
{
Player = player;
}
}
#endregion Public Types
#region Public Variables
public bool ContainsGrapplingHook => _Hook != null;
public GrapplingHook Hook => _Hook;
public EventHandler<HookTakenArgs> HookTaken;
public EventHandler<HookPutAwayArgs> HookPutAway;
public EventHandler<MiniGameStartedArgs> MiniGameStarted;
#endregion Public Variables
#region Public Methods
public void AddGrapplingHook(IPickableItem item)
{
if (_Hook != null) { Debug.LogError("Trying to put away grappling hook, but the slot is already occupied"); return; }
var hook = (GrapplingHook)item;
if (hook == null) { Debug.LogError("Trying to put away an item that's not a grappling hook"); return; }
_Hook = hook;
HookPutAway?.Invoke(this, new HookPutAwayArgs(_Hook));
}
public IPickableItem RemoveGrapplingHook()
{
if (_Hook == null) { Debug.LogError("Trying to take null grappling hook"); return null; }
var hook = _Hook;
_Hook = null;
HookTaken?.Invoke(this, new HookTakenArgs(hook));
return hook;
}
public void TakeGrapplingHook(PlayerInteractionHand playerHand)
{
playerHand.Grab(RemoveGrapplingHook());
}
public void PutAwayGrapplingHook(PlayerInteractionHand playerHand)
{
AddGrapplingHook(playerHand.Drop());
}
public void StartMinigame(PlayerInteractionHand playerHand, Player player)
{
TakeGrapplingHook(playerHand);
MiniGameStarted?.Invoke(this, new MiniGameStartedArgs(player));
}
#endregion Public Methods
#region Private Variables
private GrapplingHook _Hook;
#endregion Private Variables
}
}