示例#1
0
        public void Union(InteractiveRange range, out ContainerModule nearestContainer)
        {
            Guid   mainId   = _selectedContainer?.Entity.Guid ?? Guid.Empty;
            Single distance = Single.MaxValue;

            nearestContainer = null;

            foreach (var container in range.EnumerateContainers())
            {
                if (container.Entity.Guid == mainId)
                {
                    continue;
                }

                if (container.Usefulness == ContainerUsefulness.Useful)
                {
                    if (container.Distance < distance)
                    {
                        distance         = container.Distance;
                        nearestContainer = container.Module;
                    }

                    Union(container.Module);
                }
            }
        }
        private IEnumerable <Entity> GetEntities()
        {
            Guid targetId = Guid.Empty;

            var entity = _actionData.TargetEntity;

            if (entity)
            {
                targetId = entity.Guid;
                yield return(entity);
            }

            if (!The.InputManager.IsPressed(KeyCode.LeftShift))
            {
                yield break;
            }

            var range = new InteractiveRange();

            foreach (var near in range.Entities)
            {
                if (near.Entity.Guid != targetId)
                {
                    yield return(near.Entity);
                }
            }
        }
示例#3
0
        public UnionContainer(InteractiveRange range, ContainerModule selectedContainer)
        {
            _selectedContainer = selectedContainer;
            MergedContainer    = new Entity().AddModule <ContainerModule>();

            Union(selectedContainer);
            Union(range, out _);
        }