Merge branch 'develop' into 6.14优化

This commit is contained in:
2025-06-14 21:13:41 +08:00
74 changed files with 10122 additions and 3192 deletions
@@ -1,14 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using AibisDream.Framework;
using AibisDream.Kit;
using AibisDream.Utility;
using DG.Tweening;
using JetBrains.Annotations;
using Newtonsoft.Json;
using UnityEngine;
using System.Collections;
using DG.Tweening;
namespace AibisDream.FixSystem
{
@@ -18,7 +13,10 @@ namespace AibisDream.FixSystem
private const string SocketObjName = "Socket";
public Transform socketPos;
private Transform _socketPos;
private Transform _socketLeft;
private Transform _socketRight;
private Tween _socketTween;
private BodyModuleSystem _bodyModuleSystem;
private Material _highlightMaterial;
@@ -44,6 +42,7 @@ namespace AibisDream.FixSystem
[SerializeField] public BodyModuleData data;
public bool available = true;
private bool _cutting;
private bool _isOpen;
private void Awake()
{
@@ -53,7 +52,10 @@ namespace AibisDream.FixSystem
private void InitReference()
{
socketPos = transform.Find(SocketObjName);
_socketPos = transform.Find(SocketObjName);
_socketLeft = _socketPos.Find("Left");
_socketRight = _socketPos.Find("Right");
_bodyModuleSystem = transform.parent.parent.GetComponent<BodyModuleSystem>();
_targetSpriteRenderer = transform.Find("Module Pic").GetComponent<SpriteRenderer>();
@@ -71,14 +73,6 @@ namespace AibisDream.FixSystem
_alarmMaterial = Resources.Load<Material>("Materials/AlarmMaterial");
}
private void Update()
{
if (_cutting && Input.GetMouseButton(0))
{
//OnCut();
}
}
#region
public bool IsAvailable()
@@ -104,7 +98,35 @@ namespace AibisDream.FixSystem
public Vector3 GetSocketPos()
{
return socketPos.position;
return _socketPos.position;
}
public void OpenPlugSlot()
{
if (!_socketLeft) return;
if (_isOpen) return;
_isOpen = true;
// 打开插槽
if (_socketTween is { active: true } && _socketTween.IsPlaying()) _socketTween.Kill(true);
var sequence = DOTween.Sequence();
sequence.Join(_socketLeft.DOScale(new Vector3(0, 1, 1), 0.1f).SetEase(Ease.InSine));
sequence.Join(_socketRight.DOScale(new Vector3(0, 1, 1), 0.1f).SetEase(Ease.InSine));
_socketTween = sequence;
}
public void ClosePlugSlot()
{
if (!_socketLeft) return;
if (!_isOpen) return;
_isOpen = false;
// 关闭插槽
if (_socketTween != null && _socketTween.IsPlaying()) _socketTween.Kill(true);
var sequence = DOTween.Sequence();
sequence.Join(_socketLeft.DOScale(new Vector3(1, 1, 1), 0.1f).SetEase(Ease.OutSine));
sequence.Join(_socketRight.DOScale(new Vector3(1, 1, 1), 0.1f).SetEase(Ease.OutSine));
_socketTween = sequence;
}
#endregion
@@ -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
}
}
@@ -26,12 +26,12 @@ namespace AibisDream.FixSystem
public bool isInDialog;
public bool isActive = true;
public bool isCableRetracted = true; // 线缆是否收起
public bool isCableRetracted = true; // 线缆是否收起
[SerializeField] private Transform retractedPos; // 收起位置
[SerializeField] private float dropDownDuration = 0.5f; // 放下动画时长
[SerializeField] private float swingDuration = 0.3f; // 摆动动画时长
[SerializeField] private float swingAngle = 15f; // 摆动角度
[SerializeField] private Transform retractedPos; // 收起位置
[SerializeField] private float dropDownDuration = 0.5f; // 放下动画时长
[SerializeField] private float swingDuration = 0.3f; // 摆动动画时长
[SerializeField] private float swingAngle = 15f; // 摆动角度
[HideInInspector] public ISocket curSocket;
[HideInInspector] public BodyModule curBodyModule;
@@ -108,7 +108,7 @@ namespace AibisDream.FixSystem
private void SaveCableState()
{
Debug.Log("Save cableRetractedstate"+isCableRetracted);
Debug.Log("Save cableRetractedstate" + isCableRetracted);
StorageSystem.Instance.SetValue(CABLE_RETRACTED_KEY, isCableRetracted);
}
@@ -123,7 +123,6 @@ namespace AibisDream.FixSystem
public void ResetPlug()
{
Debug.Log("ResetPlug");
// 不在初始插孔里,就从当前插孔拔出来,插回初始插孔
PlugRef.PullUpSocket();
PlugRef.ReturnToStartPosition();
@@ -180,7 +179,8 @@ namespace AibisDream.FixSystem
Disable_plugInput();
ResetPlug();
PlugRef.SetPhysicCableActive(false);
PlugRef.GetComponent<SpriteRenderer>().sortingLayerName = CableReelRef.GetComponent<SpriteRenderer>().sortingLayerName;
PlugRef.GetComponent<SpriteRenderer>().sortingLayerName =
CableReelRef.GetComponent<SpriteRenderer>().sortingLayerName;
PlugRef.GetComponent<SpriteRenderer>().sortingOrder = 41;
PlugRef.transform.DOMove(retractedPos.position, 0.1f).OnComplete(() =>
{
@@ -189,6 +189,7 @@ namespace AibisDream.FixSystem
SaveCableState();
});
}
public void DropDownCable()
{
if (!isCableRetracted) return;
@@ -217,7 +218,8 @@ namespace AibisDream.FixSystem
// 设置Plug位置和层级
PlugRef.transform.position = retractedPos.position;
PlugRef.transform.rotation = retractedPos.rotation;
PlugRef.GetComponent<SpriteRenderer>().sortingLayerName = CableReelRef.GetComponent<SpriteRenderer>().sortingLayerName;
PlugRef.GetComponent<SpriteRenderer>().sortingLayerName =
CableReelRef.GetComponent<SpriteRenderer>().sortingLayerName;
PlugRef.GetComponent<SpriteRenderer>().sortingOrder = 41;
isCableRetracted = true;
//SaveCableState();
+16 -15
View File
@@ -12,7 +12,7 @@ namespace AibisDream.FixSystem
public class Plug : MonoBehaviour, IInteraction
{
private static readonly int ShineFade = Shader.PropertyToID("_ShineFade");
#region
private Vector3 _startPos;
@@ -39,9 +39,10 @@ namespace AibisDream.FixSystem
private void Awake()
{
InitComponentRef();
EventRegister();
EventRegister();
_RetractedPos = transform.position;
_startPos = new Vector3(transform.position.x+0.3f, transform.position.y - 2f, transform.position.z); // 初始化时记录初始位置
_startPos = new Vector3(transform.position.x + 0.3f, transform.position.y - 2f,
transform.position.z); // 初始化时记录初始位置
}
private void InitComponentRef()
@@ -50,7 +51,7 @@ namespace AibisDream.FixSystem
_sprite = GetComponent<SpriteRenderer>();
_plugRootPos = transform.Find("Plug Root Pos");
_trigger = GetComponent<EventTriggerEx>();
// 处理插头高亮
_sprite.material.SetFloat(ShineFade, GlobalVariableKit.IsPlugHighLight ? 1 : 0);
}
@@ -62,7 +63,7 @@ namespace AibisDream.FixSystem
_trigger.Register(EventTriggerType.PointerUp, OnPointerUp);
}
/// <summary>
/// 插入某个socket
/// </summary>
@@ -138,8 +139,8 @@ namespace AibisDream.FixSystem
GetComponent<SpriteRenderer>().sortingOrder = 48;
// 系统被锁定就返回
if (!_cableSystem.IsPlugAvailable()) return;
// 首次拖拽后关闭高亮
if (GlobalVariableKit.IsPlugHighLight)
{
@@ -184,9 +185,10 @@ namespace AibisDream.FixSystem
public void ReturnToStartPosition()
{
PlugPosBack();
transform.DOMove(_startPos, 0.1f).OnComplete(() => {
transform.DOMove(_startPos, 0.1f).OnComplete(() =>
{
_cableSystem.CableReelRef.ResetRotation();
SwitchToPhysicCableState();
SwitchToPhysicCableState();
});
}
@@ -209,18 +211,21 @@ namespace AibisDream.FixSystem
_cableSystem.PhysicCableRef.GetComponent<LineRenderer>().enabled = true;
_isPhysicCableActive = true;
}
public void SetPhysicCableActive(bool active)
{
_isPhysicCableActive = active;
}
private void Update()
{
if (_isPhysicCableActive && !_cableSystem.isCableRetracted)
{
_cableSystem.PhysicCableRef.physicLine.UpdatePlug(this.transform);
_cableSystem.PhysicCableRef.physicLine.UpdatePlug(transform);
}
// 如果未锁定,就一直查询是否靠近最近的插孔
if (!_cableSystem.IsPlugAvailable()) return;
_cableSystem.TryFindClosestModule(transform.position, out _);
}
void OnDrawGizmosSelected()
@@ -238,10 +243,6 @@ namespace AibisDream.FixSystem
return gameObject;
}
public void SetStartPos(Vector3 pos)
{
_startPos = pos;
}
public Vector3 GetStartPos()
{
return _startPos;