Ejemplo n.º 1
0
        bool IsValidInventory(IMyTerminalBlock Block)
        {
            if (Block == null)
            {
                return(false);
            }
            if (Block.IsOfType <IMyCargoContainer>() ||
                Block.IsOfType <IMyAssembler>() ||
                Block.IsOfType <IMyShipConnector>() ||
                Block.IsOfType <IMyCollector>())
            {
                if (!Block.IsFunctional)
                {
                    if (DebugEnabled)
                    {
                        InventoriesStatus.AppendLine($"{Block.CustomName} skipped: non-functional");
                    }
                    return(false);
                }

                if (string.IsNullOrWhiteSpace(Block.Name))
                {
                    Block.Name = $"Entity_{Block.EntityId}";
                    MyAPIGateway.Entities.SetEntityName(Block);
                }
                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        int PriorityIndex(IMyTerminalBlock Block)
        {
            IMyDecoy Decoy;

            if (Block.IsOfType(out Decoy))
            {
                // A turret doesn't know what kind of destructive device it can be
                return(5000);
            }

            IMySmallGatlingGun      Gun;
            IMySmallMissileLauncher Launcher;

            if (Block.IsOfType(out Launcher) || Block.IsOfType(out Gun))
            {
                Vector3D GunToMe    = Vector3D.Normalize(TurretPosition - Block.GetPosition());
                Vector3D GunForward = Vector3D.Normalize(Block.WorldMatrix.Forward);

                if (Vector3D.Dot(GunToMe, GunForward) >= 0.7f)
                {
                    return(1100);
                }
                else
                {
                    return(300);
                }
            }

            IMyLargeTurretBase Turret;

            if (Block.IsOfType(out Turret))
            {
                int TurretIndex = 100;
                if (Turret.HasComponent <AdvTurretMissile>())
                {
                    TurretIndex = 800;
                }
                if (Turret.HasComponent <AdvTurretGatling>())
                {
                    TurretIndex = 500;
                }
                if (Turret.HasComponent <AdvTurretInterior>())
                {
                    TurretIndex = 100;
                }
                if (Turret.Target.GetTopMostParent() != this.Turret.GetTopMostParent())
                {
                    TurretIndex /= 2;
                }
                return(TurretIndex);
            }

            IMyJumpDrive Drive;

            if (Block.IsOfType(out Drive))
            {
                if (Drive.Status == Ingame.MyJumpDriveStatus.Jumping)
                {
                    return(2000);
                }
                if (Drive.Status == Ingame.MyJumpDriveStatus.Ready)
                {
                    return(400);
                }
                return(200);
            }

            IMyWarhead Warhead;

            if (Block.IsOfType(out Warhead))
            {
                return(1800);
            }

            IMyShipController Controller;

            if (Block.IsOfType(out Controller))
            {
                if (Controller.IsUnderControl)
                {
                    return(480);
                }
                else
                {
                    return(100);
                }
            }

            return(10);
        }