public static void Add(MyEntity entity)
        {
            if (entity.GamePruningProxyId != MyConstants.PRUNING_PROXY_ID_UNITIALIZED)
            {
                return;                                                                         // already inserted
            }
            BoundingBoxD bbox = GetEntityAABB(entity);

            if (bbox.Size == Vector3D.Zero)
            {
                return;                              // don't add entities with zero bounding boxes
            }
            entity.GamePruningProxyId = m_aabbTree.AddProxy(ref bbox, entity, 0);

            bool isTarget = false;

            if (MyFakes.SHOW_FACTIONS_GUI)
            {
                var        moduleOwner = entity as IMyComponentOwner <MyIDModule>;
                MyIDModule module;
                if (moduleOwner != null && moduleOwner.GetComponent(out module))
                {
                    isTarget = true;
                }
            }
            foreach (var targetType in TargetTypes)
            {
                if (targetType == entity.GetType())
                {
                    isTarget = true;
                    break;
                }
            }

            if (isTarget)
            {
                entity.TargetPruningProxyId = m_targetsTree.AddProxy(ref bbox, entity, 0);
            }

            if (SensableTypes.Contains(entity.GetType()))
            {
                entity.SensablePruningProxyId = m_sensableTree.AddProxy(ref bbox, entity, 0);
            }

            var voxelMap = entity as MyVoxelMap;

            if (voxelMap != null)
            {
                voxelMap.VoxelMapPruningProxyId = m_voxelMapsTree.AddProxy(ref bbox, entity, 0);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Return top most parent of this entity
        /// </summary>
        /// <returns></returns>
        public MyEntity GetTopMostParent(Type type = null)
        {
            MyEntity parent = this;

            while (parent.Parent != null && (type == null || !parent.GetType().IsSubclassOf(type)))
            {
                parent = parent.Parent;
            }

            return(parent);
        }
Ejemplo n.º 3
0
        public static MyInventoryOwnerTypeEnum InventoryOwnerType(this MyEntity entity)
        {
            // TODO: This should be handled differently, probably as attribute on MyInventory..
            if (entity.GetType() == typeof(MySmallMissileLauncher))
            {
                return(MyInventoryOwnerTypeEnum.System);
            }
            else if (entity.GetType() == typeof(MyProductionBlock))
            {
                return(MyInventoryOwnerTypeEnum.System);
            }
            else if (entity.GetType() == typeof(MySmallGatlingGun))
            {
                return(MyInventoryOwnerTypeEnum.System);
            }
            else if (entity.GetType() == typeof(MyConveyorSorter))
            {
                return(MyInventoryOwnerTypeEnum.Storage);
            }
            else if (entity.GetType() == typeof(MyGasGenerator))
            {
                return(MyInventoryOwnerTypeEnum.System);
            }
            else if (entity.GetType() == typeof(MyShipToolBase))
            {
                return(MyInventoryOwnerTypeEnum.System);
            }
            else if (entity.GetType() == typeof(MyGasTank))
            {
                return(MyInventoryOwnerTypeEnum.System);
            }
            else if (entity.GetType() == typeof(MyReactor))
            {
                return(MyInventoryOwnerTypeEnum.Energy);
            }
            else if (entity.GetType() == typeof(MyCollector))
            {
                return(MyInventoryOwnerTypeEnum.Storage);
            }
            else if (entity.GetType() == typeof(MyCargoContainer))
            {
                return(MyInventoryOwnerTypeEnum.Storage);
            }
            else if (entity.GetType() == typeof(MyShipDrill))
            {
                return(MyInventoryOwnerTypeEnum.System);
            }
            else if (entity.GetType() == typeof(MyCharacter))
            {
                return(MyInventoryOwnerTypeEnum.Character);
            }

            return(MyInventoryOwnerTypeEnum.Storage);
        }
Ejemplo n.º 4
0
        public static MyInventoryOwnerTypeEnum InventoryOwnerType(this MyEntity entity)
        {
            // TODO: This should be handled differently, probably as attribute on MyInventory..
            if (IsSameOrSubclass(typeof(MyUserControllableGun), entity.GetType()))
            {
                return(MyInventoryOwnerTypeEnum.System);
            }
            else if (IsSameOrSubclass(typeof(MyProductionBlock), entity.GetType()))
            {
                return(MyInventoryOwnerTypeEnum.System);
            }
            else if (IsSameOrSubclass(typeof(MyConveyorSorter), entity.GetType()))
            {
                return(MyInventoryOwnerTypeEnum.Storage);
            }
            else if (IsSameOrSubclass(typeof(MyGasGenerator), entity.GetType()))
            {
                return(MyInventoryOwnerTypeEnum.System);
            }
            else if (IsSameOrSubclass(typeof(MyShipToolBase), entity.GetType()))
            {
                return(MyInventoryOwnerTypeEnum.System);
            }
            else if (IsSameOrSubclass(typeof(MyGasTank), entity.GetType()))
            {
                return(MyInventoryOwnerTypeEnum.System);
            }
            else if (IsSameOrSubclass(typeof(MyReactor), entity.GetType()))
            {
                return(MyInventoryOwnerTypeEnum.Energy);
            }
            else if (IsSameOrSubclass(typeof(MyCollector), entity.GetType()))
            {
                return(MyInventoryOwnerTypeEnum.Storage);
            }
            else if (IsSameOrSubclass(typeof(MyCargoContainer), entity.GetType()))
            {
                return(MyInventoryOwnerTypeEnum.Storage);
            }
            else if (IsSameOrSubclass(typeof(MyShipDrill), entity.GetType()))
            {
                return(MyInventoryOwnerTypeEnum.System);
            }
            else if (IsSameOrSubclass(typeof(MyCharacter), entity.GetType()))
            {
                return(MyInventoryOwnerTypeEnum.Character);
            }

            return(MyInventoryOwnerTypeEnum.Storage);
        }
Ejemplo n.º 5
0
        public static void Show(MyTerminalPageEnum page, MyCharacter user, MyEntity interactedEntity)
        {
            if (!MyPerGameSettings.TerminalEnabled)
                return;

            bool showProperties = MyInput.Static.IsAnyShiftKeyPressed();
            Debug.Assert(m_instance == null);

            m_instance = new MyGuiScreenTerminal();
            m_instance.m_user = user;

            m_openInventoryInteractedEntity = interactedEntity;

            if(MyFakes.ENABLE_TERMINAL_PROPERTIES)
                m_instance.m_initialPage = showProperties ? MyTerminalPageEnum.Properties : page;
            else
                m_instance.m_initialPage = page;

            InteractedEntity = interactedEntity;
            m_instance.RecreateControls(true);

            MyGuiSandbox.AddScreen(MyGuiScreenGamePlay.ActiveGameplayScreen = m_instance);
            m_screenOpen = true;

            string target = interactedEntity != null ? interactedEntity.GetType().Name : "";
            MyAnalyticsHelper.ReportActivityStart(user, "show_terminal", target, "gui", string.Empty);
        }