public class BombermanPlayerChannel : ScriptableObject {
public delegate void BombermanPlayerMovementAction(InputAction.CallbackContext context);
private BombermanPlayerMovementAction OnBombermanPlayerMovementRequested0; // <--- warning on this line saying "Is never assigned to"
private BombermanPlayerMovementAction OnBombermanPlayerMovementRequested1;
private BombermanPlayerMovementAction GetMovementActionForPlayer(int player_index) {
switch (player_index) {
case 0:
return OnBombermanPlayerMovementRequested0;
case 1:
return OnBombermanPlayerMovementRequested1;
}
throw new System.Exception("Unexpected player index!");
}
public void RegisterForMovementAction(int player_index, BombermanPlayerMovementAction callback) {
GetMovementActionForPlayer(player_index) += callback;
// Also tried this:
BombermanPlayerMovementAction action = GetMovementActionForPlayer(player_index);
action -= callback;
}
public void RaiseMovementEvent(int player_index, InputAction.CallbackContext context) {
BombermanPlayerMovementAction action = GetMovementActionForPlayer(player_index);
if (action != null) {
action.Invoke(context);
}
}
public class BombermanPlayerChannel : ScriptableObject {
public delegate void BombermanPlayerMovementAction(InputAction.CallbackContext context);
private BombermanPlayerMovementAction OnBombermanPlayerMovementRequested0; // <--- warning on this line saying "Is never assigned to"
private BombermanPlayerMovementAction OnBombermanPlayerMovementRequested1;
private BombermanPlayerMovementAction GetMovementActionForPlayer(int player_index) {
switch (player_index) {
case 0:
return OnBombermanPlayerMovementRequested0;
case 1:
return OnBombermanPlayerMovementRequested1;
}
throw new System.Exception("Unexpected player index!");
}
public void RegisterForMovementAction(int player_index, BombermanPlayerMovementAction callback) {
GetMovementActionForPlayer(player_index) += callback;
// Also tried this:
BombermanPlayerMovementAction action = GetMovementActionForPlayer(player_index);
action -= callback;
}
public void RaiseMovementEvent(int player_index, InputAction.CallbackContext context) {
BombermanPlayerMovementAction action = GetMovementActionForPlayer(player_index);
if (action != null) {
action.Invoke(context);
}
}