public void SetSubgroup(IShipDockEntitas entitas, ICommonOverlayMapper commonCollider) { bool hasData = commonCollider.IsDataValid(ref entitas); if (hasData) { BehaviourIDs ids = commonCollider.GetEntitasData(ref entitas); SubgroupID = ids.gameItemID; mCommonColliderMapper = commonCollider; mCommonColliderMapper.PhysicsChecked(SubgroupID, true); mBridge = new ComponentBridge(OnInit); mBridge.Start(); } }
protected virtual void DropWorldItem(ref IShipDockEntitas target) { int worldItemID = mWorldItem.worldItemID; mWorldItemMapper.Remove(worldItemID); mGroupsMapper.Remove(mWorldItem.groupID); mAroundMapper.Remove(mWorldItem.aroundID); List <int> list = BehaviourIDsComp.GetAroundList(ref target); list?.Clear(); BehaviourIDs ids = BehaviourIDsComp.GetEntitasData(ref target); ids.willClear = true; BehaviourIDsComp.FillEntitasData(ref target, ids); mWorldItem.WorldItemDispose?.Invoke(); mWorldItem.WorldItemDispose = default; mWorldItem.isDroped = true; }
/// <summary> /// 检测物体四周目标 /// </summary> private void CheckAround(ref IShipDockEntitas target) { if (!mBehaviourIdsCompChecked) { mBehaviourIdsCompChecked = true; mHasBehaviourIDs = BehaviourIDsComp != default; } if (mHasBehaviourIDs && IsWorldItemValid(ref mWorldItem)) { BehaviourIDs ids = BehaviourIDsComp.GetEntitasData(ref target); int aroundID = ids.gameItemID; if (mAroundMapper.ContainsKey(aroundID)) { WalkEachAroundItem(ref target, ids); } else { mWorldItem.aroundID = aroundID; mAroundMapper[aroundID] = mMovement; } } }
private void WalkEachAroundItem(ref IShipDockEntitas target, BehaviourIDs ids) { bool flag; int id, aroundID = ids.gameItemID; float distance; AroundsCheckedInfo info; WorldMovement itemMovement; List <int> list = BehaviourIDsComp.GetAroundList(ref target); int max = (list != default) ? list.Count : 0; if (max > 0) { for (int i = 0; i < max; i++) { id = list[i]; itemMovement = GetAroundTargetMovement(id); if (itemMovement != default && !itemMovement.Invalid) { distance = mMovement.DistanceBetween(itemMovement.Position); info = new AroundsCheckedInfo { ids = ids, checkingAroundID = id, distanceBetween = distance, distanceCrowding = GetCrowdingDistance(), }; flag = CheckingAround(ref target, aroundID, info, ref itemMovement); if (!flag) { break; } } } BehaviourIDsComp.PhysicsCheckReset(aroundID); } AroundsChecked(ref target, aroundID); }