完成基本代码迁移重构
This commit is contained in:
@@ -14,7 +14,10 @@ namespace NBF
|
||||
{
|
||||
private float _tension;
|
||||
|
||||
|
||||
public PlayerItem PlayerItem;
|
||||
|
||||
public override int ConfigId => PlayerItem?.ConfigID ?? 0;
|
||||
|
||||
/// <summary>
|
||||
/// 可用的
|
||||
/// </summary>
|
||||
@@ -126,123 +129,122 @@ namespace NBF
|
||||
|
||||
public async FTask InitRod(PlayerItem playerItem)
|
||||
{
|
||||
// ConfigId = itemBindInfo.Item;
|
||||
// // Player = player;
|
||||
//
|
||||
// var playerView = player.GetComponent<PlayerView>();
|
||||
//
|
||||
// var playerViewUnity = playerView.Unity;
|
||||
//
|
||||
// transform.localPosition = Vector3.zero;
|
||||
// transform.localRotation = Quaternion.identity;
|
||||
// transform.localScale = Vector3.one;
|
||||
// SceneSettings.Instance.GearNode.position = playerViewUnity.transform.position;
|
||||
// yield return 1;
|
||||
// var obj = new GameObject($"rod_{ConfigId}");
|
||||
// obj.transform.SetParent(SceneSettings.Instance.GearNode);
|
||||
// // obj.transform.SetParent(player.transform);
|
||||
// // obj.transform.localPosition = Vector3.zero;
|
||||
// obj.transform.position = playerViewUnity.transform.position;
|
||||
// obj.transform.rotation = playerViewUnity.transform.rotation;
|
||||
// obj.transform.localScale = Vector3.one;
|
||||
// GearRoot = obj.transform;
|
||||
//
|
||||
// var parent = GearRoot;
|
||||
//
|
||||
// // List<ItemInfo> children = RoleModel.Instance.GetBindItems(itemInfo.Id);
|
||||
//
|
||||
//
|
||||
// CreateFishingHandler();
|
||||
// yield return 1; //等待1帧
|
||||
// // children.Sort();
|
||||
// foreach (var childConfigId in itemBindInfo.BindItems)
|
||||
// {
|
||||
// var itemType = childConfigId.GetItemType();
|
||||
// var config = Game.Tables.TbItem.Get(childConfigId);
|
||||
// if (itemType == ItemType.Reel)
|
||||
// {
|
||||
// Reel = config.InstantiateAndComponent<FReel>(Asset.ReelConnector, Vector3.zero,
|
||||
// Quaternion.identity);
|
||||
// Reel.SetItemConfigId(childConfigId);
|
||||
// }
|
||||
// else if (itemType == ItemType.Bobber)
|
||||
// {
|
||||
// Bobber = config.InstantiateAndComponent<FBobber>(parent, Vector3.zero,
|
||||
// Quaternion.identity);
|
||||
// Bobber.SetItemConfigId(childConfigId);
|
||||
// }
|
||||
// else if (itemType == ItemType.Hook)
|
||||
// {
|
||||
// Hook = config.InstantiateAndComponent<FHook>(parent, Vector3.zero,
|
||||
// Quaternion.identity);
|
||||
// Hook.SetItemConfigId(childConfigId);
|
||||
// }
|
||||
// else if (itemType == ItemType.Bait)
|
||||
// {
|
||||
// Bait = config.InstantiateAndComponent<FBait>(parent, Vector3.zero,
|
||||
// Quaternion.identity);
|
||||
// Bait.SetItemConfigId(childConfigId);
|
||||
// }
|
||||
// else if (itemType == ItemType.Lure)
|
||||
// {
|
||||
// Lure = config.InstantiateAndComponent<FLure>(parent, Vector3.zero,
|
||||
// Quaternion.identity);
|
||||
// Lure.SetItemConfigId(childConfigId);
|
||||
// }
|
||||
// else if (itemType == ItemType.Weight)
|
||||
// {
|
||||
// Weight = config.InstantiateAndComponent<FWeight>(parent, Vector3.zero,
|
||||
// Quaternion.identity);
|
||||
// Weight.SetItemConfigId(childConfigId);
|
||||
// }
|
||||
// else if (itemType == ItemType.Line)
|
||||
// {
|
||||
// // lineItemInfo = child;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// yield return 1;
|
||||
// if (Reel)
|
||||
// {
|
||||
// Reel.reelingDrag = 0.699f;
|
||||
// Reel.transform.SetParent(Asset.ReelConnector);
|
||||
// Reel.transform.localPosition = Vector3.zero;
|
||||
// Reel.transform.localEulerAngles = Vector3.zero;
|
||||
// Reel.Init(this);
|
||||
// }
|
||||
//
|
||||
// if (Bobber)
|
||||
// {
|
||||
// Bobber.Init(this);
|
||||
// }
|
||||
//
|
||||
// if (Hook)
|
||||
// {
|
||||
// Hook.Init(this);
|
||||
// }
|
||||
//
|
||||
// if (Bait)
|
||||
// {
|
||||
// Bait.Init(this);
|
||||
// }
|
||||
//
|
||||
// if (Lure)
|
||||
// {
|
||||
// Lure.Init(this);
|
||||
// }
|
||||
//
|
||||
// if (Weight)
|
||||
// {
|
||||
// Weight.Init(this);
|
||||
// }
|
||||
//
|
||||
// yield return 1; //等待1帧
|
||||
//
|
||||
// transform.SetParent(playerViewUnity.ModelAsset.RodRoot);
|
||||
// transform.localPosition = Vector3.zero;
|
||||
// transform.rotation = playerViewUnity.ModelAsset.RodRoot.rotation;
|
||||
//
|
||||
// Usable = true;
|
||||
PlayerItem = playerItem;
|
||||
|
||||
var playerView = playerItem.Owner.GetComponent<PlayerView>();
|
||||
|
||||
var playerViewUnity = playerView.Unity;
|
||||
|
||||
transform.localPosition = Vector3.zero;
|
||||
transform.localRotation = Quaternion.identity;
|
||||
transform.localScale = Vector3.one;
|
||||
SceneSettings.Instance.GearNode.position = playerViewUnity.transform.position;
|
||||
await FTask.WaitFrame(playerView.Scene); //等待1帧
|
||||
|
||||
var obj = new GameObject($"rod_{ConfigId}");
|
||||
obj.transform.SetParent(SceneSettings.Instance.GearNode);
|
||||
// obj.transform.SetParent(player.transform);
|
||||
// obj.transform.localPosition = Vector3.zero;
|
||||
obj.transform.position = playerViewUnity.transform.position;
|
||||
obj.transform.rotation = playerViewUnity.transform.rotation;
|
||||
obj.transform.localScale = Vector3.one;
|
||||
GearRoot = obj.transform;
|
||||
|
||||
var parent = GearRoot;
|
||||
|
||||
// List<ItemInfo> children = RoleModel.Instance.GetBindItems(itemInfo.Id);
|
||||
|
||||
CreateFishingHandler();
|
||||
await FTask.WaitFrame(playerView.Scene); //等待1帧
|
||||
// children.Sort();
|
||||
foreach (var childConfigId in playerItem.BindItems)
|
||||
{
|
||||
var itemType = childConfigId.GetItemType();
|
||||
var config = Game.Tables.TbItem.Get(childConfigId);
|
||||
if (itemType == ItemType.Reel)
|
||||
{
|
||||
Reel = config.InstantiateAndComponent<FReel>(Asset.ReelConnector, Vector3.zero,
|
||||
Quaternion.identity);
|
||||
Reel.SetItemConfigId(childConfigId);
|
||||
}
|
||||
else if (itemType == ItemType.Bobber)
|
||||
{
|
||||
Bobber = config.InstantiateAndComponent<FBobber>(parent, Vector3.zero,
|
||||
Quaternion.identity);
|
||||
Bobber.SetItemConfigId(childConfigId);
|
||||
}
|
||||
else if (itemType == ItemType.Hook)
|
||||
{
|
||||
Hook = config.InstantiateAndComponent<FHook>(parent, Vector3.zero,
|
||||
Quaternion.identity);
|
||||
Hook.SetItemConfigId(childConfigId);
|
||||
}
|
||||
else if (itemType == ItemType.Bait)
|
||||
{
|
||||
Bait = config.InstantiateAndComponent<FBait>(parent, Vector3.zero,
|
||||
Quaternion.identity);
|
||||
Bait.SetItemConfigId(childConfigId);
|
||||
}
|
||||
else if (itemType == ItemType.Lure)
|
||||
{
|
||||
Lure = config.InstantiateAndComponent<FLure>(parent, Vector3.zero,
|
||||
Quaternion.identity);
|
||||
Lure.SetItemConfigId(childConfigId);
|
||||
}
|
||||
else if (itemType == ItemType.Weight)
|
||||
{
|
||||
Weight = config.InstantiateAndComponent<FWeight>(parent, Vector3.zero,
|
||||
Quaternion.identity);
|
||||
Weight.SetItemConfigId(childConfigId);
|
||||
}
|
||||
else if (itemType == ItemType.Line)
|
||||
{
|
||||
// lineItemInfo = child;
|
||||
}
|
||||
}
|
||||
|
||||
await FTask.WaitFrame(playerView.Scene); //等待1帧
|
||||
if (Reel)
|
||||
{
|
||||
Reel.reelingDrag = 0.699f;
|
||||
Reel.transform.SetParent(Asset.ReelConnector);
|
||||
Reel.transform.localPosition = Vector3.zero;
|
||||
Reel.transform.localEulerAngles = Vector3.zero;
|
||||
Reel.Init(this);
|
||||
}
|
||||
|
||||
if (Bobber)
|
||||
{
|
||||
Bobber.Init(this);
|
||||
}
|
||||
|
||||
if (Hook)
|
||||
{
|
||||
Hook.Init(this);
|
||||
}
|
||||
|
||||
if (Bait)
|
||||
{
|
||||
Bait.Init(this);
|
||||
}
|
||||
|
||||
if (Lure)
|
||||
{
|
||||
Lure.Init(this);
|
||||
}
|
||||
|
||||
if (Weight)
|
||||
{
|
||||
Weight.Init(this);
|
||||
}
|
||||
|
||||
await FTask.WaitFrame(playerView.Scene); //等待1帧
|
||||
|
||||
transform.SetParent(playerViewUnity.ModelAsset.RodRoot);
|
||||
transform.localPosition = Vector3.zero;
|
||||
transform.rotation = playerViewUnity.ModelAsset.RodRoot.rotation;
|
||||
|
||||
Usable = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -286,11 +288,6 @@ namespace NBF
|
||||
Line = obj.GetComponent<FLine>();
|
||||
Line.transform.position = Asset.lineConnector.position;
|
||||
Line.Init(this);
|
||||
|
||||
// var obiSolver = solver.GetComponent<ObiSolver>();
|
||||
// obiSolver.parameters.ambientWind = Vector3.zero;
|
||||
// obiSolver.wind.
|
||||
// obiSolver.simulateWhenInvisible
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user