mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-10 03:35:10 +00:00
move duplicate code to own method
This commit is contained in:
parent
9054015342
commit
379ad6163b
1 changed files with 35 additions and 57 deletions
|
@ -40,6 +40,50 @@ namespace HeavenStudio.Editor
|
|||
{
|
||||
InputController lastController = PlayerInput.GetInputController(1);
|
||||
InputController newController = PlayerInput.GetInputControllers()[controllersDropdown.value];
|
||||
|
||||
AssignController(newController, lastController);
|
||||
});
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
if (isAutoSearching) {
|
||||
var controllers = PlayerInput.GetInputControllers();
|
||||
foreach (var controller in controllers) {
|
||||
if (controller.GetLastButtonDown() > 0 || controller.GetLastKeyDown() > 0) {
|
||||
InputController lastController = PlayerInput.GetInputController(1);
|
||||
isAutoSearching = false;
|
||||
autoSearchLabel.SetActive(false);
|
||||
controllersDropdown.value = PlayerInput.GetInputControllerId(1);
|
||||
|
||||
AssignController(controller, lastController);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (isPairSearching) {
|
||||
var controllers = PlayerInput.GetInputControllers();
|
||||
InputController.InputFeatures lrFlag = pairSelectLR ? InputController.InputFeatures.Extra_SplitControllerLeft : InputController.InputFeatures.Extra_SplitControllerRight;
|
||||
foreach (var controller in controllers) {
|
||||
if (controller == PlayerInput.GetInputController(1)) continue;
|
||||
InputController.InputFeatures features = controller.GetFeatures();
|
||||
if (!features.HasFlag(lrFlag)) continue;
|
||||
if (controller.GetLastButtonDown() > 0 || controller.GetLastKeyDown() > 0) {
|
||||
InputJoyshock con = (InputJoyshock) PlayerInput.GetInputController(1);
|
||||
con.AssignOtherHalf((InputJoyshock) controller);
|
||||
isPairSearching = false;
|
||||
pairSearchLabel.SetActive(false);
|
||||
currentControllerLabel.text = "Current Controller: " + controller.GetDeviceName();
|
||||
pairingLabel.text = "Joy-Con (L / R) Selected\nPairing Successful!";
|
||||
ShowControllerIcon(controller);
|
||||
|
||||
StartCoroutine(SelectionVibrate(con));
|
||||
StartCoroutine(SelectionVibrate((InputJoyshock) controller));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AssignController(InputController newController, InputController lastController)
|
||||
{
|
||||
lastController.SetPlayer(-1);
|
||||
newController.SetPlayer(1);
|
||||
|
||||
|
@ -66,74 +110,8 @@ namespace HeavenStudio.Editor
|
|||
}
|
||||
else
|
||||
{
|
||||
pairSearchItem.SetActive(false);
|
||||
CancelPairSearch();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
if (isAutoSearching) {
|
||||
var controllers = PlayerInput.GetInputControllers();
|
||||
foreach (var controller in controllers) {
|
||||
if (controller.GetLastButtonDown() > 0 || controller.GetLastKeyDown() > 0) {
|
||||
InputController lastController = PlayerInput.GetInputController(1);
|
||||
lastController.SetPlayer(-1);
|
||||
controller.SetPlayer(1);
|
||||
isAutoSearching = false;
|
||||
autoSearchLabel.SetActive(false);
|
||||
controllersDropdown.value = PlayerInput.GetInputControllerId(1);
|
||||
|
||||
if (typeof(InputJoyshock) == lastController.GetType()) {
|
||||
((InputJoyshock)lastController).UnAssignOtherHalf();
|
||||
}
|
||||
|
||||
if (typeof(InputJoyshock) == controller.GetType()) {
|
||||
InputJoyshock con = (InputJoyshock) controller;
|
||||
StartCoroutine(SelectionVibrate(con));
|
||||
con.UnAssignOtherHalf();
|
||||
}
|
||||
|
||||
currentControllerLabel.text = "Current Controller: " + controller.GetDeviceName();
|
||||
ShowControllerIcon(controller);
|
||||
|
||||
InputController.InputFeatures features = controller.GetFeatures();
|
||||
if (features.HasFlag(InputController.InputFeatures.Extra_SplitControllerLeft) || features.HasFlag(InputController.InputFeatures.Extra_SplitControllerRight))
|
||||
{
|
||||
pairSelectLR = !features.HasFlag(InputController.InputFeatures.Extra_SplitControllerLeft);
|
||||
pairSearchItem.SetActive(true);
|
||||
StartPairSearch();
|
||||
}
|
||||
else
|
||||
{
|
||||
pairSearchItem.SetActive(false);
|
||||
CancelPairSearch();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (isPairSearching) {
|
||||
var controllers = PlayerInput.GetInputControllers();
|
||||
InputController.InputFeatures lrFlag = pairSelectLR ? InputController.InputFeatures.Extra_SplitControllerLeft : InputController.InputFeatures.Extra_SplitControllerRight;
|
||||
foreach (var controller in controllers) {
|
||||
if (controller == PlayerInput.GetInputController(1)) continue;
|
||||
InputController.InputFeatures features = controller.GetFeatures();
|
||||
if (!features.HasFlag(lrFlag)) continue;
|
||||
if (controller.GetLastButtonDown() > 0 || controller.GetLastKeyDown() > 0) {
|
||||
InputJoyshock con = (InputJoyshock) PlayerInput.GetInputController(1);
|
||||
con.AssignOtherHalf((InputJoyshock) controller);
|
||||
isPairSearching = false;
|
||||
pairSearchLabel.SetActive(false);
|
||||
currentControllerLabel.text = "Current Controller: " + controller.GetDeviceName();
|
||||
pairingLabel.text = "Joy-Con (L / R) Selected\nPairing Successful!";
|
||||
ShowControllerIcon(controller);
|
||||
|
||||
StartCoroutine(SelectionVibrate(con));
|
||||
StartCoroutine(SelectionVibrate((InputJoyshock) controller));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue