Example #1
0
        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;
        }
Example #2
0
        /// <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;
                }
            }
        }
Example #3
0
        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);
        }