合并
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using AibisDream.Framework;
|
||||
using Cinemachine;
|
||||
using JetBrains.Annotations;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AibisDream.FixSystem
|
||||
@@ -104,6 +105,12 @@ namespace AibisDream.FixSystem
|
||||
var closestDistance = Mathf.Infinity;
|
||||
BodyModule closestModule = null;
|
||||
|
||||
if (BodyModules is not { Count: > 0 })
|
||||
{
|
||||
targetModule = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
// 寻找最接近的BodyModule
|
||||
foreach (var bodyModule in BodyModules)
|
||||
{
|
||||
@@ -121,16 +128,35 @@ namespace AibisDream.FixSystem
|
||||
}
|
||||
}
|
||||
|
||||
bool res;
|
||||
// 判断距离是否在目标范围内,在的话就返回,不在的话返回个空的
|
||||
if (closestDistance < plugSnappingRange && closestModule)
|
||||
{
|
||||
targetModule = closestModule;
|
||||
return true;
|
||||
res = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetModule = null;
|
||||
return false;
|
||||
res = false;
|
||||
}
|
||||
|
||||
HandleModuleSlotState(targetModule);
|
||||
return res;
|
||||
}
|
||||
|
||||
private void HandleModuleSlotState([CanBeNull]BodyModule closestModule)
|
||||
{
|
||||
foreach (var bodyModule in BodyModules)
|
||||
{
|
||||
if (closestModule && bodyModule == closestModule)
|
||||
{
|
||||
bodyModule.OpenPlugSlot();
|
||||
}
|
||||
else
|
||||
{
|
||||
bodyModule.ClosePlugSlot();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,6 +301,7 @@ namespace AibisDream.FixSystem
|
||||
_headModuleGroup.transform.localPosition = _headModuleOriginalPos + new Vector3(0, yOffset, 0);
|
||||
yield return null;
|
||||
}
|
||||
// ReSharper disable once IteratorNeverReturns
|
||||
}
|
||||
|
||||
public void TriggerPainShake()
|
||||
@@ -357,6 +384,7 @@ namespace AibisDream.FixSystem
|
||||
_headModuleGroup.transform.localPosition = originalPos;
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
}
|
||||
// ReSharper disable once IteratorNeverReturns
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user