コード例 #1
0
        private void UpdateJoinPoints(Entity thisJoinEntity, JoinState joinState, Line otherLine)
        {
            var otherLineNonMergedJointPoint = LineJoinPoints[joinState == JoinState.AtoA ||
                                                              joinState == JoinState.BtoA
                                                                  ? otherLine.JoinPointB
                                                                  : otherLine.JoinPointA];

            // Un-join other line (it will be destroyed)
            // TODO Check back here as this may be done on destroy other line
            LineJoinPoint.UnJoinIfJoined(Ecb, index, LineJoinPoints, otherLine.JoinPointA);
            LineJoinPoint.UnJoinIfJoined(Ecb, index, LineJoinPoints, otherLine.JoinPointB);

            // Mirror other join
            var thisJoin = otherLineNonMergedJointPoint;

            // Except parent entity
            thisJoin.ParentEntity = lineEntity;
            if (thisJoin.IsJoined)
            {
                LineJoinPoint.Join(Ecb, index, LineJoinPoints,
                                   thisJoinEntity,
                                   thisJoin.JoinToPointEntity,
                                   true, thisJoin);
            }
            else
            {
                Ecb.SetComponent(index, thisJoinEntity, thisJoin);
            }
        }
コード例 #2
0
ファイル: NewLineCreateJob.cs プロジェクト: Sibz/Lines
        private void CreateLineJoinPoints(LineToolData data)
        {
            var lineObject    = EntityManager.GetComponentObject <EcsLineBehaviour>(data.LineEntity);
            var lineComponent = EntityManager.GetComponentData <Line>(data.LineEntity);

            lineObject.LineEntity = data.LineEntity;

            var direction = float3.zero;

            if (EntityManager.Exists(NewLineCreateEvent.FromJoinPointEntity))
            {
                direction = -EntityManager.GetComponentData <LineJoinPoint>(NewLineCreateEvent.FromJoinPointEntity)
                            .Direction;
            }

            lineComponent.JoinPointA = lineObject.EndNode1.JoinPoint =
                LineJoinPoint.New(data.LineEntity, NewLineCreateEvent.StartingPosition,
                                  direction);
            lineComponent.JoinPointB = lineObject.EndNode2.JoinPoint =
                LineJoinPoint.New(data.LineEntity, NewLineCreateEvent.StartingPosition,
                                  direction);

            EntityManager.SetComponentData(data.LineEntity, lineComponent);

            if (EntityManager.Exists(NewLineCreateEvent.FromJoinPointEntity))
            {
                LineJoinPoint.Join(NewLineCreateEvent.FromJoinPointEntity, lineObject.EndNode1.JoinPoint);
            }
        }