public MyMwcObjectBuilder_SmallShip(MyMwcObjectBuilder_SmallShip_TypesEnum shipType,
     MyMwcObjectBuilder_Inventory inventory,
     List<MyMwcObjectBuilder_SmallShip_Weapon> weapons,
     MyMwcObjectBuilder_SmallShip_Engine engine, 
     List<MyMwcObjectBuilder_AssignmentOfAmmo> assignmentOfAmmo,
     MyMwcObjectBuilder_SmallShip_Armor armor,
     MyMwcObjectBuilder_SmallShip_Radar radar,
     float? shipMaxHealth,
     float shipHealthRatio,
     float armorHealth,
     float oxygen,
     float fuel,
     bool reflectorLight,
     bool reflectorLongRange,
     float reflectorShadowDistance,
     int aiPriority)
         : base(inventory)
 {
     ShipType = shipType;
     Weapons = weapons;
     Engine = engine;                        
     AssignmentOfAmmo = assignmentOfAmmo;
     Armor = armor;
     Radar = radar;
     ShipMaxHealth = shipMaxHealth;
     ShipHealthRatio = shipHealthRatio;
     ArmorHealth = armorHealth;
     Oxygen = oxygen;
     Fuel = fuel;
     ReflectorLight = reflectorLight;
     ReflectorLongRange = reflectorLongRange;
     ReflectorShadowDistance = reflectorShadowDistance;
     AIPriority = aiPriority;
 }
Пример #2
0
 public MyMwcObjectBuilder_SmallShip(MyMwcObjectBuilder_SmallShip_TypesEnum shipType,
                                     MyMwcObjectBuilder_Inventory inventory,
                                     List <MyMwcObjectBuilder_SmallShip_Weapon> weapons,
                                     MyMwcObjectBuilder_SmallShip_Engine engine,
                                     List <MyMwcObjectBuilder_AssignmentOfAmmo> assignmentOfAmmo,
                                     MyMwcObjectBuilder_SmallShip_Armor armor,
                                     MyMwcObjectBuilder_SmallShip_Radar radar,
                                     float?shipMaxHealth,
                                     float shipHealthRatio,
                                     float armorHealth,
                                     float oxygen,
                                     float fuel,
                                     bool reflectorLight,
                                     bool reflectorLongRange,
                                     float reflectorShadowDistance,
                                     int aiPriority)
     : base(inventory)
 {
     ShipType                = shipType;
     Weapons                 = weapons;
     Engine                  = engine;
     AssignmentOfAmmo        = assignmentOfAmmo;
     Armor                   = armor;
     Radar                   = radar;
     ShipMaxHealth           = shipMaxHealth;
     ShipHealthRatio         = shipHealthRatio;
     ArmorHealth             = armorHealth;
     Oxygen                  = oxygen;
     Fuel                    = fuel;
     ReflectorLight          = reflectorLight;
     ReflectorLongRange      = reflectorLongRange;
     ReflectorShadowDistance = reflectorShadowDistance;
     AIPriority              = aiPriority;
 }
        private StringBuilder GetTemplatePrefix(MyMwcObjectBuilder_SmallShip_TypesEnum shipType)
        {
            StringBuilder prefix = new StringBuilder();

            MyMwcUtils.AppendStringBuilder(prefix, ((MyGuiSmallShipHelperSmallShip)MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip, (int)shipType)).Name);
            prefix.Append(" - ");
            return(prefix);
        }
Пример #4
0
        public static MyMwcObjectBuilder_SmallShip_Player CreateDefaultShip(MyMwcObjectBuilder_SmallShip_TypesEnum shipType, MyMwcObjectBuilder_FactionEnum faction, int maxItems)
        {
            var result = new MyMwcObjectBuilder_SmallShip_Player(shipType,
                                                                 new MyMwcObjectBuilder_Inventory(
                                                                     new List <MyMwcObjectBuilder_InventoryItem>()
            {
                new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic), 1000f),
                new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic), 1000f),
                new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic), 1000f),
                new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic), 1000f),
                new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic), 1000f),
                new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic), 1000f),
                new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Sniper_SAPHEI), 1000f),
                new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Sniper_SAPHEI), 1000f),
                new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Sniper_SAPHEI), 1000f),
            },
                                                                     maxItems),
                                                                 new List <MyMwcObjectBuilder_SmallShip_Weapon>()
            {
                new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon)
                {
                    MountedDescriptor = MyMwcObjectBuilder_SmallShip_Weapon.LEFT_SIDE_MOUNT_DESCRIPTOR
                },
                new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon)
                {
                    MountedDescriptor = MyMwcObjectBuilder_SmallShip_Weapon.RIGHT_SIDE_MOUNT_DESCRIPTOR
                },
                new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Sniper)
                {
                    MountedDescriptor = MyMwcObjectBuilder_SmallShip_Weapon.AUTO_MOUNT_DESCRIPTOR
                },
                new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Missile_Launcher)
                {
                    MountedDescriptor = MyMwcObjectBuilder_SmallShip_Weapon.AUTO_MOUNT_DESCRIPTOR
                },
            },
                                                                 new MyMwcObjectBuilder_SmallShip_Engine(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.PowerCells_3),
                                                                 new List <MyMwcObjectBuilder_AssignmentOfAmmo>()
            {
                new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic),
                new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Secondary, MyMwcObjectBuilder_AmmoGroupEnum.Missile, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic),
                new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Third, MyMwcObjectBuilder_AmmoGroupEnum.UniversalLauncherFront, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Basic),
                new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Fourth, MyMwcObjectBuilder_AmmoGroupEnum.UniversalLauncherBack, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Smart),
                new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Fifth, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic),
            },
                                                                 new MyMwcObjectBuilder_SmallShip_Armor(MyMwcObjectBuilder_SmallShip_Armor_TypesEnum.Advanced),
                                                                 new MyMwcObjectBuilder_SmallShip_Radar(MyMwcObjectBuilder_SmallShip_Radar_TypesEnum.Radar_1),
                                                                 null, 1f, float.MaxValue, float.MaxValue, float.MaxValue, float.MaxValue,
                                                                 true,
                                                                 false,
                                                                 200, 0);

            result.Faction = faction;
            result.PositionAndOrientation = new MyMwcPositionAndOrientation(Matrix.Identity);
            return(result);
        }
Пример #5
0
        private void FillListBox(MyMwcObjectBuilder_SmallShip_TypesEnum selectedType)
        {
            m_templatesListbox.RemoveAllItems();
            var templates = MySmallShipTemplates.GetTemplatesForType(selectedType);

            for (int i = 0; i < templates.Count; i++)
            {
                var template = templates[i];
                m_templatesListbox.AddItem(i, template.Name);
            }
        }
        public override void OnOkClick(MyGuiControlButton sender)
        {
            base.OnOkClick(sender);

            if (HasEntity())
            {
                if (m_changeMaterial.Checked)
                {
                    m_entity.VoxelMaterial = ((MyMwcVoxelMaterialsEnum)m_selectVoxelMapMaterialCombobox.GetSelectedKey());
                }

                float x, y, z;
                if (float.TryParse(m_positionX.Text, out x) && float.TryParse(m_positionY.Text, out y) && float.TryParse(m_positionZ.Text, out z))
                {
                    m_entity.SetPosition(new Vector3(x, y, z));
                }
            }
            else
            {
                if (GetAsteroidType() == MyGuiAsteroidTypesEnum.VOXEL)
                {
                    MyMwcObjectBuilder_SmallShip_TypesEnum shipType = (MyMwcObjectBuilder_SmallShip_TypesEnum)
                                                                      Enum.ToObject(typeof(MyMwcObjectBuilder_SmallShip_TypesEnum), m_selectVoxelMapCombobox.GetSelectedKey());
                    MyMwcVoxelFilesEnum voxelFileEnum = (MyMwcVoxelFilesEnum)
                                                        Enum.ToObject(typeof(MyMwcVoxelFilesEnum), m_selectVoxelMapCombobox.GetSelectedKey());
                    MyMwcVoxelMaterialsEnum materialEnum = (MyMwcVoxelMaterialsEnum)
                                                           Enum.ToObject(typeof(MyMwcVoxelMaterialsEnum), m_selectVoxelMapMaterialCombobox.GetSelectedKey());

                    MyMwcObjectBuilder_VoxelMap voxelMapBuilder = MyMwcObjectBuilder_Base.CreateNewObject(MyMwcObjectBuilderTypeEnum.VoxelMap, null) as MyMwcObjectBuilder_VoxelMap;
                    voxelMapBuilder.VoxelMaterial = materialEnum;
                    voxelMapBuilder.VoxelFile     = voxelFileEnum;
                    MyEditor.Static.CreateFromObjectBuilder(voxelMapBuilder, Matrix.CreateWorld(m_newObjectPosition, Vector3.Forward, Vector3.Up), m_screenPosition);
                }
                else if (GetAsteroidType() == MyGuiAsteroidTypesEnum.STATIC)
                {
                    MyMwcObjectBuilder_StaticAsteroid_TypesEnum staticAsteroidType = (MyMwcObjectBuilder_StaticAsteroid_TypesEnum)
                                                                                     Enum.ToObject(typeof(MyMwcObjectBuilder_StaticAsteroid_TypesEnum), m_selectVoxelMapCombobox.GetSelectedKey());

                    MyMwcVoxelMaterialsEnum?materialEnum = null;
                    int materialKey = m_selectVoxelMapMaterialCombobox.GetSelectedKey();
                    if (materialKey != -1)
                    {
                        materialEnum = (MyMwcVoxelMaterialsEnum)Enum.ToObject(typeof(MyMwcVoxelMaterialsEnum), materialKey);
                    }

                    MyMwcObjectBuilder_StaticAsteroid staticAsteroidBuilder = new MyMwcObjectBuilder_StaticAsteroid(staticAsteroidType, materialEnum);
                    MyEditor.Static.CreateFromObjectBuilder(staticAsteroidBuilder, Matrix.CreateWorld(m_newObjectPosition, Vector3.Forward, Vector3.Up), m_screenPosition);
                }
            }

            MyGuiManager.CloseAllScreensExcept(MyGuiScreenGamePlay.Static);
        }
        private List <MySmallShipBuilderWithName> GetTemplatesForCombobox(MyMwcObjectBuilder_SmallShip_Bot selectedBuilder, out int?selectedIndex)
        {
            int?foundedIndex = null;
            int currentIndex = 0;
            List <MySmallShipBuilderWithName> templatesForCombobox = new List <MySmallShipBuilderWithName>();

            for (int i = 0; i < MyGuiSmallShipHelpers.MyMwcObjectBuilder_SmallShip_TypesEnumValues.Length; i++)
            {
                MyMwcObjectBuilder_SmallShip_TypesEnum shipType = (MyMwcObjectBuilder_SmallShip_TypesEnum)MyGuiSmallShipHelpers.MyMwcObjectBuilder_SmallShip_TypesEnumValues.GetValue(i);
                StringBuilder templateName;
                // insert no teplate
                templateName = GetTemplatePrefix(shipType);
                templateName.Append("NO TEMPLATE");
                MyMwcObjectBuilder_SmallShip_Bot builderToAdd = null;
                if (selectedBuilder != null && selectedBuilder.ShipTemplateID == null && selectedBuilder.ShipType == shipType)
                {
                    builderToAdd = selectedBuilder;
                    foundedIndex = currentIndex;
                }
                else
                {
                    builderToAdd = MyMwcObjectBuilder_SmallShip_Bot.CreateObjectBuilderWithAllItems(shipType, MyShipTypeConstants.GetShipTypeProperties(shipType).GamePlay.CargoCapacity);
                    if (selectedBuilder != null)
                    {
                        builderToAdd.CopyBotParameters(selectedBuilder);
                    }
                }
                templatesForCombobox.Add(new MySmallShipBuilderWithName(templateName, builderToAdd));
                currentIndex++;

                // real templates
                foreach (MySmallShipTemplate template in MySmallShipTemplates.GetTemplatesForType(shipType))
                {
                    if (selectedBuilder != null && selectedBuilder.ShipTemplateID != null && selectedBuilder.ShipTemplateID.Value == template.ID)
                    {
                        foundedIndex = currentIndex;
                    }
                    builderToAdd = new MyMwcObjectBuilder_SmallShip_Bot(template.Builder);
                    if (selectedBuilder != null)
                    {
                        builderToAdd.CopyBotParameters(selectedBuilder);
                    }
                    templateName = GetTemplatePrefix(shipType);
                    MyMwcUtils.AppendStringBuilder(templateName, template.Name);
                    templatesForCombobox.Add(new MySmallShipBuilderWithName(templateName, builderToAdd, template));
                    currentIndex++;
                }
            }
            selectedIndex = foundedIndex;
            return(templatesForCombobox);
        }
 public static MyMwcObjectBuilder_SmallShip_Player CreateDefaultShip(MyMwcObjectBuilder_SmallShip_TypesEnum shipType, MyMwcObjectBuilder_FactionEnum faction, int maxItems)
 {
     var result = new MyMwcObjectBuilder_SmallShip_Player(shipType,
         new MyMwcObjectBuilder_Inventory(
             new List<MyMwcObjectBuilder_InventoryItem>()
             {
                 new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic), 1000f),
                 new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic), 1000f),
                 new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic), 1000f),
                 new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic), 1000f),
                 new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic), 1000f),
                 new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic), 1000f),
                 new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Sniper_SAPHEI), 1000f),
                 new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Sniper_SAPHEI), 1000f),
                 new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Sniper_SAPHEI), 1000f),
             },
             maxItems),
         new List<MyMwcObjectBuilder_SmallShip_Weapon>()
         {
             new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon) { MountedDescriptor = MyMwcObjectBuilder_SmallShip_Weapon.LEFT_SIDE_MOUNT_DESCRIPTOR },
             new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon) { MountedDescriptor = MyMwcObjectBuilder_SmallShip_Weapon.RIGHT_SIDE_MOUNT_DESCRIPTOR },
             new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Sniper) { MountedDescriptor = MyMwcObjectBuilder_SmallShip_Weapon.AUTO_MOUNT_DESCRIPTOR },
             new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Missile_Launcher) { MountedDescriptor = MyMwcObjectBuilder_SmallShip_Weapon.AUTO_MOUNT_DESCRIPTOR },
         },
         new MyMwcObjectBuilder_SmallShip_Engine(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.PowerCells_3),
         new List<MyMwcObjectBuilder_AssignmentOfAmmo>()
         {
             new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic),
             new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Secondary, MyMwcObjectBuilder_AmmoGroupEnum.Missile, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic),
             new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Third, MyMwcObjectBuilder_AmmoGroupEnum.UniversalLauncherFront, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Basic),
             new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Fourth, MyMwcObjectBuilder_AmmoGroupEnum.UniversalLauncherBack, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Smart),
             new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Fifth, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic),
         },
         new MyMwcObjectBuilder_SmallShip_Armor(MyMwcObjectBuilder_SmallShip_Armor_TypesEnum.Advanced),
         new MyMwcObjectBuilder_SmallShip_Radar(MyMwcObjectBuilder_SmallShip_Radar_TypesEnum.Radar_1),
         null, 1f, float.MaxValue, float.MaxValue, float.MaxValue, float.MaxValue,
         true,
         false,
         200, 0);
     result.Faction = faction;
     result.PositionAndOrientation = new MyMwcPositionAndOrientation(Matrix.Identity);
     return result;
 }
Пример #9
0
 public MyMwcObjectBuilder_SmallShip_Player(MyMwcObjectBuilder_SmallShip_TypesEnum shipType,
                                            MyMwcObjectBuilder_Inventory inventory,
                                            List <MyMwcObjectBuilder_SmallShip_Weapon> weapons,
                                            MyMwcObjectBuilder_SmallShip_Engine engine,
                                            List <MyMwcObjectBuilder_AssignmentOfAmmo> assignmentOfAmmo,
                                            MyMwcObjectBuilder_SmallShip_Armor armor,
                                            MyMwcObjectBuilder_SmallShip_Radar radar,
                                            float?shipMaxHealth,
                                            float shipHealthRatio,
                                            float armorHealth,
                                            float electricity,
                                            float oxygen,
                                            float fuel,
                                            bool reflectorLight,
                                            bool reflectorLongRange,
                                            float reflectorShadowDistance,
                                            int aiPriority)
     : base(shipType, inventory, weapons, engine, assignmentOfAmmo, armor, radar, shipMaxHealth, shipHealthRatio, armorHealth, oxygen, fuel, reflectorLight, reflectorLongRange, reflectorShadowDistance, aiPriority)
 {
     DisplayName = "Player";
 }
 public MyMwcObjectBuilder_SmallShip_Player(MyMwcObjectBuilder_SmallShip_TypesEnum shipType,
     MyMwcObjectBuilder_Inventory inventory,
     List<MyMwcObjectBuilder_SmallShip_Weapon> weapons,
     MyMwcObjectBuilder_SmallShip_Engine engine,
     List<MyMwcObjectBuilder_AssignmentOfAmmo> assignmentOfAmmo,
     MyMwcObjectBuilder_SmallShip_Armor armor,
     MyMwcObjectBuilder_SmallShip_Radar radar,
     float? shipMaxHealth,
     float shipHealthRatio,
     float armorHealth,
     float electricity,
     float oxygen,
     float fuel,
     bool reflectorLight,
     bool reflectorLongRange,
     float reflectorShadowDistance,
     int aiPriority)
     : base(shipType, inventory, weapons, engine, assignmentOfAmmo, armor, radar, shipMaxHealth, shipHealthRatio, armorHealth, oxygen, fuel, reflectorLight, reflectorLongRange, reflectorShadowDistance, aiPriority)
 {
     DisplayName = "Player";
 }
Пример #11
0
 public MyMwcObjectBuilder_SmallShip_Bot(MyMwcObjectBuilder_SmallShip_TypesEnum shipType,
                                         MyMwcObjectBuilder_Inventory inventory,
                                         List <MyMwcObjectBuilder_SmallShip_Weapon> weapons,
                                         MyMwcObjectBuilder_SmallShip_Engine engine,
                                         List <MyMwcObjectBuilder_AssignmentOfAmmo> assignmentOfAmmo,
                                         MyMwcObjectBuilder_SmallShip_Armor armor,
                                         MyMwcObjectBuilder_SmallShip_Radar radar,
                                         float?shipMaxHealth,
                                         float shipHealthRatio,
                                         float armorHealth,
                                         float oxygen,
                                         float fuel,
                                         bool reflectorLight,
                                         bool reflectorLongRange,
                                         MyMwcObjectBuilder_FactionEnum shipFaction,
                                         MyAITemplateEnum aiTemplate,
                                         float aggressivity,
                                         float seeDistance,
                                         float sleepDistance,
                                         MyPatrolMode patrolMode,
                                         uint?leader,
                                         BotBehaviorType idleBehavior,
                                         float reflectorShadowDistance,
                                         int aiPriority,
                                         bool leaderLostEnabled,
                                         bool activeAI)
     : base(shipType, inventory, weapons, engine, assignmentOfAmmo, armor, radar, shipMaxHealth, shipHealthRatio, armorHealth, oxygen, fuel, reflectorLight, reflectorLongRange, reflectorShadowDistance, aiPriority)
 {
     Faction           = shipFaction;
     AITemplate        = aiTemplate;
     Aggressivity      = aggressivity;
     SeeDistance       = seeDistance;
     SleepDistance     = sleepDistance;
     PatrolMode        = patrolMode;
     Leader            = leader;
     IdleBehavior      = idleBehavior;
     LeaderLostEnabled = leaderLostEnabled;
     ActiveAI          = activeAI;
     SlowDown          = 1;
 }
Пример #12
0
        private bool GetSafePositionForSpawn(MyMwcObjectBuilder_SmallShip_TypesEnum shipType, out Vector3?safePosition)
        {
            var shipRadius = MyModels.GetModelOnlyData(MyShipTypeConstants.GetShipTypeProperties(shipType).Visual.ModelLod0Enum).BoundingSphere.Radius;

            for (int c = MAX_SPAWN_ATTEMPTS; c-- != 0;)
            {
                Vector3 randomPointInSphere = MyMwcUtils.GetRandomVector3Normalized() * MyMwcUtils.GetRandomFloat(0, 1) * BoundingSphereRadius; // Random point in sphere
                Vector3 newTestPos          = GetPosition() + randomPointInSphere;

                BoundingSphere bsphere = new BoundingSphere(newTestPos, shipRadius);
                MyEntity       col     = MyEntities.GetIntersectionWithSphere(ref bsphere);

                if (col == null)
                {
                    safePosition = newTestPos;
                    return(true);
                }
            }

            safePosition = null;
            return(false);
        }
 public static List <MySmallShipTemplate> GetTemplatesForType(MyMwcObjectBuilder_SmallShip_TypesEnum type)
 {
     return(m_templates[(int)type]);
 }
Пример #14
0
        public static MyMwcObjectBuilder_SmallShip_Player CreateObjectBuilderWithAllItems(MyMwcObjectBuilder_SmallShip_TypesEnum shipType, MyMwcObjectBuilder_FactionEnum faction, int maxInventoryItems)
        {
            List <MyMwcObjectBuilder_SmallShip_Weapon> weapons        = new List <MyMwcObjectBuilder_SmallShip_Weapon>();
            List <MyMwcObjectBuilder_AssignmentOfAmmo> ammoAssignment = new List <MyMwcObjectBuilder_AssignmentOfAmmo>();
            List <MyMwcObjectBuilder_InventoryItem>    inventoryItems = new List <MyMwcObjectBuilder_InventoryItem>();

            // weapons
            foreach (MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum weapon in Enum.GetValues(typeof(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum)))
            {
                var weaponBuilder = new MyMwcObjectBuilder_SmallShip_Weapon(weapon);
                weaponBuilder.SetAutoMount();
                weapons.Add(weaponBuilder);
                // we want have 2x autocanon
                if (weapon == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon)
                {
                    var autocannonBuilder = new MyMwcObjectBuilder_SmallShip_Weapon(weapon);
                    autocannonBuilder.SetAutoMount();
                    weapons.Add(autocannonBuilder);
                }
            }

            // ammo assignment
            ammoAssignment.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic));
            ammoAssignment.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Secondary, MyMwcObjectBuilder_AmmoGroupEnum.Missile, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic));
            ammoAssignment.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Third, MyMwcObjectBuilder_AmmoGroupEnum.UniversalLauncherFront, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Basic));
            ammoAssignment.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Fourth, MyMwcObjectBuilder_AmmoGroupEnum.UniversalLauncherBack, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Smart));
            ammoAssignment.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Fifth, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic));

            // inventory items
            // ammo
            foreach (MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammo in Enum.GetValues(typeof(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum)))
            {
                inventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(ammo), 1000f));
            }

            // tools
            foreach (MyMwcObjectBuilder_SmallShip_Tool_TypesEnum tool in Enum.GetValues(typeof(MyMwcObjectBuilder_SmallShip_Tool_TypesEnum)))
            {
                inventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Tool(tool), 1f));
            }

            // radars
            foreach (MyMwcObjectBuilder_SmallShip_Radar_TypesEnum radar in Enum.GetValues(typeof(MyMwcObjectBuilder_SmallShip_Radar_TypesEnum)))
            {
                inventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Radar(radar), 1f));
            }

            // engines
            foreach (MyMwcObjectBuilder_SmallShip_Engine_TypesEnum engine in Enum.GetValues(typeof(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum)))
            {
                if (engine != MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.PowerCells_1)
                {
                    inventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Engine(engine), 1f));
                }
            }

            // armors
            foreach (MyMwcObjectBuilder_SmallShip_Armor_TypesEnum armor in Enum.GetValues(typeof(MyMwcObjectBuilder_SmallShip_Armor_TypesEnum)))
            {
                if (armor != MyMwcObjectBuilder_SmallShip_Armor_TypesEnum.Basic)
                {
                    inventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Armor(armor), 1f));
                }
            }

            // foundation factory
            var foundationFactory = new MyMwcObjectBuilder_PrefabFoundationFactory();

            foundationFactory.PrefabHealthRatio = 1f;
            foundationFactory.PrefabMaxHealth   = null;
            inventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(foundationFactory, 1f));
            inventoryItems.RemoveAll(x => MyMwcObjectBuilder_InventoryItem.IsDisabled(x));

            if (inventoryItems.Count > maxInventoryItems)
            {
                inventoryItems = inventoryItems.GetRange(0, maxInventoryItems);
            }

            MyMwcObjectBuilder_SmallShip_Player builder =
                new MyMwcObjectBuilder_SmallShip_Player(
                    shipType,
                    new MyMwcObjectBuilder_Inventory(inventoryItems, maxInventoryItems),
                    weapons,
                    new MyMwcObjectBuilder_SmallShip_Engine(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.PowerCells_1),
                    ammoAssignment,
                    new MyMwcObjectBuilder_SmallShip_Armor(MyMwcObjectBuilder_SmallShip_Armor_TypesEnum.Basic),
                    new MyMwcObjectBuilder_SmallShip_Radar(MyMwcObjectBuilder_SmallShip_Radar_TypesEnum.Radar_1),
                    null, 1f, float.MaxValue, float.MaxValue, float.MaxValue, float.MaxValue,
                    true, false, 200f, 0);

            builder.Faction = faction;

            return(builder);
        }
Пример #15
0
 public void WriteSmallShipType(MyMwcObjectBuilder_SmallShip_TypesEnum val)
 {
     m_binaryWriter.Write((byte)val);
 }
Пример #16
0
        public bool ReadSmallShipType(ref MyMwcObjectBuilder_SmallShip_TypesEnum val)
        {
            byte numericValue = 0;

            return(ReadByte(ref numericValue) && MyMwcUtils.GetEnumFromNumber <MyMwcObjectBuilder_SmallShip_TypesEnum, byte>(numericValue, ref val));
        }
        //  Create a bot ship, which is a special computer-controlled type of miner ship.
        public MySmallShipBot CreateFakeBot(string hudLabelText, MyMwcObjectBuilder_SmallShip_TypesEnum shipType, Vector3 position, float health, Vector3? diffuseColor, MyMwcObjectBuilder_FactionEnum faction)
        {
            List<MyMwcObjectBuilder_SmallShip_Weapon> weapons = new List<MyMwcObjectBuilder_SmallShip_Weapon>();
            List<MyMwcObjectBuilder_AssignmentOfAmmo> assignments = new List<MyMwcObjectBuilder_AssignmentOfAmmo>();

            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Cannon));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Cannon));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Shotgun));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Crusher));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Universal_Launcher_Front));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(10000, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(500, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_BioChem));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(1000, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Tunnel_Buster));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(10, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Automatic_Rifle_With_Silencer_High_Velocity));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(10000, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_High_Velocity));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(500000, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Basic));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(100000, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Tunnel_Buster));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(5, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Engine_Detection));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(5, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Visual_Detection));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(50, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Shotgun_Basic));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(5, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Hologram));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(15, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Basic));
            //ammo.Add(new MyMwcObjectBuilder_SmallShip_Ammo(15, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Smart));
            assignments.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, MyMwcObjectBuilder_AmmoGroupEnum.Cannon, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Basic));
            assignments.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Secondary, MyMwcObjectBuilder_AmmoGroupEnum.Cannon, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Basic));
            assignments.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Third, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic));
            assignments.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Fourth, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Automatic_Rifle_With_Silencer_BioChem));
            assignments.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Fifth, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic));

            List<MyMwcObjectBuilder_InventoryItem> inventoryItems = new List<MyMwcObjectBuilder_InventoryItem>();
            MyMwcObjectBuilder_Inventory inventory = new MyMwcObjectBuilder_Inventory(inventoryItems, 1024);

            inventory.InventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Automatic_Rifle_With_Silencer_High_Speed), 1000));
            inventory.InventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic), 1000));
            inventory.InventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Basic), 30));
            inventory.InventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Tunnel_Buster), 10));
            inventory.InventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Engine_Detection), 10));
            inventory.InventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Visual_Detection), 10));


            MySmallShipBot bot = (MySmallShipBot)MyEntities.CreateFromObjectBuilderAndAdd(hudLabelText,
                //new MyMwcObjectBuilder_SmallShip_Bot(shipType, 
                //    weapons,
                //    new MyMwcObjectBuilder_SmallShip_Engine(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.Chemical_1), 
                //    ammo, 
                //    assignments,
                //    null,
                //    faction
                //    ),
                new MyMwcObjectBuilder_SmallShip_Bot(shipType,
                    inventory,
                    weapons,
                    new MyMwcObjectBuilder_SmallShip_Engine(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.Chemical_1),
                    assignments,
                    null,
                    null,
                    null,
                    health,
                    1000f,
                    float.MaxValue,
                    float.MaxValue,
                    true,
                    false,
                    faction,
                    MyAITemplateEnum.AGGRESIVE,
                    0,
                    1000,
                    1000,
                    MyPatrolMode.CYCLE,
                    null,
                    BotBehaviorType.IDLE,
                    MyLightsConstants.MAX_SPOTLIGHT_SHADOW_RANGE,
                    0, false, true),
                    Matrix.CreateWorld(position, Vector3.Backward, Vector3.Up)
               );

            /*
            bot.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Remote_Camera), 50, true);
            bot.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Hologram), 50, true);
            bot.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Basic), 1500, true);
            bot.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Smart), 1500, true);
                */
            //MyEntities.TestEntityAfterInsertionForCollision(bot);

            //System.Diagnostics.Debug.Assert(bot.MaxHealth > health);
            //bot.DoDamage(0, bot.MaxHealth - health, 0, MyDamageType.Unknown, MyAmmoType.Unknown, null);
            bot.Faction = faction;

            return bot;
        }
Пример #18
0
 public static void WriteObjectBuilder3DSmallShipTypesEnum(MyMwcObjectBuilder_SmallShip_TypesEnum val, BinaryWriter binaryWriter)
 {
     binaryWriter.Write((byte)val);
 }
        public static MyMwcObjectBuilder_SmallShip_Player CreateObjectBuilderWithAllItems(MyMwcObjectBuilder_SmallShip_TypesEnum shipType, MyMwcObjectBuilder_FactionEnum faction, int maxInventoryItems)
        {
            List<MyMwcObjectBuilder_SmallShip_Weapon> weapons = new List<MyMwcObjectBuilder_SmallShip_Weapon>();
            List<MyMwcObjectBuilder_AssignmentOfAmmo> ammoAssignment = new List<MyMwcObjectBuilder_AssignmentOfAmmo>();
            List<MyMwcObjectBuilder_InventoryItem> inventoryItems = new List<MyMwcObjectBuilder_InventoryItem>();

            // weapons
            foreach (MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum weapon in Enum.GetValues(typeof(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum)))
            {
                var weaponBuilder = new MyMwcObjectBuilder_SmallShip_Weapon(weapon);
                weaponBuilder.SetAutoMount();
                weapons.Add(weaponBuilder);
                // we want have 2x autocanon
                if (weapon == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon)
                {
                    var autocannonBuilder = new MyMwcObjectBuilder_SmallShip_Weapon(weapon);
                    autocannonBuilder.SetAutoMount();
                    weapons.Add(autocannonBuilder);
                }
            }

            // ammo assignment
            ammoAssignment.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic));
            ammoAssignment.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Secondary, MyMwcObjectBuilder_AmmoGroupEnum.Missile, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic));
            ammoAssignment.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Third, MyMwcObjectBuilder_AmmoGroupEnum.UniversalLauncherFront, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Basic));
            ammoAssignment.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Fourth, MyMwcObjectBuilder_AmmoGroupEnum.UniversalLauncherBack, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Smart));
            ammoAssignment.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Fifth, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic));

            // inventory items
            // ammo
            foreach (MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammo in Enum.GetValues(typeof(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum)))
            {
                inventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(ammo), 1000f));
            }

            // tools
            foreach (MyMwcObjectBuilder_SmallShip_Tool_TypesEnum tool in Enum.GetValues(typeof(MyMwcObjectBuilder_SmallShip_Tool_TypesEnum)))
            {
                inventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Tool(tool), 1f));
            }

            // radars
            foreach (MyMwcObjectBuilder_SmallShip_Radar_TypesEnum radar in Enum.GetValues(typeof(MyMwcObjectBuilder_SmallShip_Radar_TypesEnum)))
            {
                inventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Radar(radar), 1f));
            }

            // engines
            foreach (MyMwcObjectBuilder_SmallShip_Engine_TypesEnum engine in Enum.GetValues(typeof(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum)))
            {
                if (engine != MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.PowerCells_1)
                {
                    inventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Engine(engine), 1f));
                }
            }

            // armors
            foreach (MyMwcObjectBuilder_SmallShip_Armor_TypesEnum armor in Enum.GetValues(typeof(MyMwcObjectBuilder_SmallShip_Armor_TypesEnum)))
            {
                if (armor != MyMwcObjectBuilder_SmallShip_Armor_TypesEnum.Basic)
                {
                    inventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Armor(armor), 1f));
                }
            }

            // foundation factory
            var foundationFactory = new MyMwcObjectBuilder_PrefabFoundationFactory();
            foundationFactory.PrefabHealthRatio = 1f;
            foundationFactory.PrefabMaxHealth = null;
            inventoryItems.Add(new MyMwcObjectBuilder_InventoryItem(foundationFactory, 1f));
            inventoryItems.RemoveAll(x => MyMwcObjectBuilder_InventoryItem.IsDisabled(x));

            if (inventoryItems.Count > maxInventoryItems)
            {
                inventoryItems = inventoryItems.GetRange(0, maxInventoryItems);
            }

            MyMwcObjectBuilder_SmallShip_Player builder =
                new MyMwcObjectBuilder_SmallShip_Player(
                    shipType,
                    new MyMwcObjectBuilder_Inventory(inventoryItems, maxInventoryItems),
                    weapons,
                    new MyMwcObjectBuilder_SmallShip_Engine(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.PowerCells_1),
                    ammoAssignment,
                    new MyMwcObjectBuilder_SmallShip_Armor(MyMwcObjectBuilder_SmallShip_Armor_TypesEnum.Basic),
                    new MyMwcObjectBuilder_SmallShip_Radar(MyMwcObjectBuilder_SmallShip_Radar_TypesEnum.Radar_1),
                    null, 1f, float.MaxValue, float.MaxValue, float.MaxValue, float.MaxValue,
                    true, false, 200f, 0);
            builder.Faction = faction;

            return builder;
        }
 public MyMwcObjectBuilder_SmallShip_Bot(MyMwcObjectBuilder_SmallShip_TypesEnum shipType,
     MyMwcObjectBuilder_Inventory inventory,
     List<MyMwcObjectBuilder_SmallShip_Weapon> weapons,
     MyMwcObjectBuilder_SmallShip_Engine engine, 
     List<MyMwcObjectBuilder_AssignmentOfAmmo> assignmentOfAmmo,
     MyMwcObjectBuilder_SmallShip_Armor armor,
     MyMwcObjectBuilder_SmallShip_Radar radar,            
     float? shipMaxHealth,
     float shipHealthRatio,
     float armorHealth,
     float oxygen,
     float fuel,
     bool reflectorLight,
     bool reflectorLongRange,
     MyMwcObjectBuilder_FactionEnum shipFaction,
     MyAITemplateEnum aiTemplate,
     float aggressivity,
     float seeDistance,
     float sleepDistance,
     MyPatrolMode patrolMode,
     uint? leader,
     BotBehaviorType idleBehavior,
     float reflectorShadowDistance,
     int aiPriority,
     bool leaderLostEnabled,
     bool activeAI)
     : base(shipType, inventory, weapons, engine, assignmentOfAmmo, armor, radar, shipMaxHealth, shipHealthRatio, armorHealth, oxygen, fuel, reflectorLight, reflectorLongRange, reflectorShadowDistance, aiPriority)
 {
     Faction = shipFaction;
     AITemplate = aiTemplate;
     Aggressivity = aggressivity;
     SeeDistance = seeDistance;
     SleepDistance = sleepDistance;
     PatrolMode = patrolMode;
     Leader = leader;
     IdleBehavior = idleBehavior;
     LeaderLostEnabled = leaderLostEnabled;
     ActiveAI = activeAI;
     SlowDown = 1;
 }
        public static MySmallShipTemplate GetTemplate(MyMwcObjectBuilder_SmallShip_TypesEnum type, StringBuilder name)
        {
            var templatesForType = m_templates[(int)type];

            return(GetTemplate(templatesForType, name));
        }
        //  Use only for quick test, random sandbox or trailer animations
        //  Never initialize as player ship! We can have only 1 player ship in the game
        public MySmallShip CreateFakeMinerShip(string hudLabelText, MyMwcObjectBuilder_SmallShip_TypesEnum shipType, Vector3 position, bool isPlayerShip, float health)
        {
            List<MyMwcObjectBuilder_SmallShip_Weapon> weapons = new List<MyMwcObjectBuilder_SmallShip_Weapon>();
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Missile_Launcher));
            //weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Missile_Launcher));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Harvesting_Device));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Crusher));
            weapons.Add(new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Universal_Launcher_Front));

            List<MyMwcObjectBuilder_AssignmentOfAmmo> assignmentOfAmmo = new List<MyMwcObjectBuilder_AssignmentOfAmmo>();
            assignmentOfAmmo.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic));
            assignmentOfAmmo.Add(new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Secondary, MyMwcObjectBuilder_AmmoGroupEnum.Missile, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic));

            var inventory = new MyMwcObjectBuilder_Inventory(new List<MyMwcObjectBuilder_InventoryItem>()
            {
                new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic), 10000),
                new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic), 10000),
            }, 1000);

            MySmallShip smallShipEntity;
            if (!isPlayerShip)
            {
                var shipBuilder = new MyMwcObjectBuilder_SmallShip(shipType,
                        inventory,
                        weapons,
                        new MyMwcObjectBuilder_SmallShip_Engine(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.PowerCells_1),
                        assignmentOfAmmo,
                        new MyMwcObjectBuilder_SmallShip_Armor(MyMwcObjectBuilder_SmallShip_Armor_TypesEnum.Basic),
                        null,
                        MyGameplayConstants.MAXHEALTH_SMALLSHIP,
                        1f,
                        100f,
                        float.MaxValue,
                        float.MaxValue,
                        true,
                        false,
                        MyLightsConstants.MAX_SPOTLIGHT_SHADOW_RANGE, 0);

                shipBuilder.Faction = MyMwcObjectBuilder_FactionEnum.Euroamerican;

                smallShipEntity = (MySmallShip)MyEntities.CreateFromObjectBuilderAndAdd(hudLabelText,
                    //new MyMwcObjectBuilder_SmallShip(shipType, 
                    //    weapons,
                    //    new MyMwcObjectBuilder_SmallShip_Engine(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.Chemical_1), 
                    //    ammo, 
                    //    assignmentOfAmmo,
                    //    null),
                    shipBuilder,
                    Matrix.CreateWorld(position, Vector3.Forward, Vector3.Up));
            }
            else
            {
                Vector3 forward = new Vector3(-0.664f, 0.556f, -0.499f);
                Vector3 up = new Vector3(0.437f, 0.856f, 0.340f);

                smallShipEntity = (MySmallShip)MyEntities.CreateFromObjectBuilderAndAdd(hudLabelText,
                    //new MyMwcObjectBuilder_SmallShip_Player(
                    //    shipType, 
                    //    weapons,
                    //    new MyMwcObjectBuilder_SmallShip_Engine(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.Chemical_1), 
                    //    ammo, 
                    //    null, 
                    //    assignmentOfAmmo),
                    new MyMwcObjectBuilder_SmallShip_Player(
                        shipType,
                        null,
                        weapons,
                        new MyMwcObjectBuilder_SmallShip_Engine(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.Chemical_1),
                        assignmentOfAmmo,
                        null,
                        null,
                        null,
                        MyGameplayConstants.HEALTH_RATIO_MAX,
                        100f,
                        float.MaxValue,
                        float.MaxValue,
                        float.MaxValue,
                        true, false, MyLightsConstants.MAX_SPOTLIGHT_SHADOW_RANGE, 0),
                    Matrix.CreateWorld(position, forward, up));
            }

            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Automatic_Rifle_With_Silencer_High_Speed), 10, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic), 10000, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Armor_Piercing_Incendiary), 10000, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Missile_Basic), 500, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Basic), 500, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Tunnel_Buster), 1000, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Engine_Detection), 5, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Visual_Detection), 5, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Remote_Camera), 5, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Hologram), 5, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Basic), 15, true);
            smallShipEntity.Inventory.AddInventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Universal_Launcher_Mine_Smart), 15, true);

            return smallShipEntity;
        }
Пример #23
0
        public static MySmallShipTemplate GetTemplate(MyMwcObjectBuilder_SmallShip_TypesEnum type, StringBuilder name)
        {
            var templatesForType = m_templates[(int)type];

            return GetTemplate(templatesForType, name);
        }
Пример #24
0
 public static List<MySmallShipTemplate> GetTemplatesForType(MyMwcObjectBuilder_SmallShip_TypesEnum type)
 {
     return m_templates[(int)type];
 }
 public MySmallShipBot CreateFakeBot(string hudLabelText, MyMwcObjectBuilder_SmallShip_TypesEnum shipType, Vector3 position, float health, MyMwcObjectBuilder_FactionEnum faction)
 {
     MySmallShipBot bot = CreateFakeBot(hudLabelText, shipType, position, health, null, faction);
     MyEntities.TestEntityAfterInsertionForCollision(bot);
     return bot;
 }
 private void FillListBox(MyMwcObjectBuilder_SmallShip_TypesEnum selectedType)
 {
     m_templatesListbox.RemoveAllItems();
     var templates = MySmallShipTemplates.GetTemplatesForType(selectedType);
     for (int i = 0; i < templates.Count; i++)
     {
         var template = templates[i];
         m_templatesListbox.AddItem(i, template.Name);
     }
 }
Пример #27
0
        private bool GetSafePositionForSpawn(MyMwcObjectBuilder_SmallShip_TypesEnum shipType, out Vector3? safePosition)
        {
            var shipRadius = MyModels.GetModelOnlyData(MyShipTypeConstants.GetShipTypeProperties(shipType).Visual.ModelLod0Enum).BoundingSphere.Radius;

            for (int c = MAX_SPAWN_ATTEMPTS; c-- != 0; )
            {
                Vector3 randomPointInSphere = MyMwcUtils.GetRandomVector3Normalized() * MyMwcUtils.GetRandomFloat(0, 1) * BoundingSphereRadius; // Random point in sphere
                Vector3 newTestPos = GetPosition() + randomPointInSphere;

                BoundingSphere bsphere = new BoundingSphere(newTestPos, shipRadius);
                MyEntity col = MyEntities.GetIntersectionWithSphere(ref bsphere);

                if (col == null)
                {
                    safePosition = newTestPos;
                    return true;
                }
            }

            safePosition = null;
            return false; 
        }
 private MyMwcObjectBuilder_SmallShip CreateShip(MyMwcObjectBuilder_SmallShip_TypesEnum shipType, MyMwcObjectBuilder_FactionEnum faction)
 {
     var ship = new MyMwcObjectBuilder_SmallShip(shipType, new MyMwcObjectBuilder_Inventory(new List<MyMwcObjectBuilder_InventoryItem>()
         {
             new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Armor_Piercing_Incendiary), 10000),
             new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic), 10000),
             new MyMwcObjectBuilder_InventoryItem(new MyMwcObjectBuilder_SmallShip_Ammo(MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Visual_Detection), 10000)
         }, 100),
         new List<MyMwcObjectBuilder_SmallShip_Weapon>()
         {
             new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon),
             new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Autocanon),
             new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Missile_Launcher),
         }
         , new CommonLIB.AppCode.ObjectBuilders.SubObjects.SmallShipTools.MyMwcObjectBuilder_SmallShip_Engine(CommonLIB.AppCode.ObjectBuilders.SubObjects.SmallShipTools.MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.PowerCells_1),
         new List<CommonLIB.AppCode.ObjectBuilders.SubObjects.SmallShipTools.MyMwcObjectBuilder_AssignmentOfAmmo>()
         {
             new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Primary, MyMwcObjectBuilder_AmmoGroupEnum.Bullet, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Autocannon_Basic),
             new MyMwcObjectBuilder_AssignmentOfAmmo(MyMwcObjectBuilder_FireKeyEnum.Secondary, MyMwcObjectBuilder_AmmoGroupEnum.Missile, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Guided_Missile_Visual_Detection),
         }
         , new CommonLIB.AppCode.ObjectBuilders.SubObjects.SmallShipTools.MyMwcObjectBuilder_SmallShip_Armor(CommonLIB.AppCode.ObjectBuilders.SubObjects.SmallShipTools.MyMwcObjectBuilder_SmallShip_Armor_TypesEnum.Basic),
         null, 1000, 1, 100, 100, 100, true, false, 50, 0);
     ship.Faction = faction;
     ship.IsDummy = true;
     return ship;
 }
        public override void OnOkClick(MyGuiControlButton sender)
        {
            base.OnOkClick(sender);

            if (m_botBuilder != null)
            {
                m_botBuilder.Faction      = (MyMwcObjectBuilder_FactionEnum)m_selectShipFactionCombobox.GetSelectedKey();
                m_botBuilder.AITemplate   = (MyAITemplateEnum)m_selectAITemplateCombobox.GetSelectedKey();
                m_botBuilder.Aggressivity = m_aggresivitySlider.GetValue();
                m_botBuilder.SeeDistance  = m_seeDistanceSlider.GetValue();
                var  templateBuilder = m_templatesBuilders[m_selectSmallShipCombobox.GetSelectedKey()];
                bool isTemplate      = templateBuilder.UserData != null;
                if (isTemplate)
                {
                    var template = templateBuilder.UserData as MySmallShipTemplate;
                    if (m_botBuilder.ShipTemplateID == null)
                    {
                        if (m_inventoryBuilder == null)
                        {
                            m_botBuilder.Inventory = null;
                            m_botBuilder.Weapons   = null;
                            m_botBuilder.Engine    = null;
                            m_botBuilder.Armor     = null;
                            m_botBuilder.Radar     = null;
                        }
                        else
                        {
                            m_botBuilder.Inventory = m_inventoryBuilder.Inventory;
                            m_botBuilder.Weapons   = m_inventoryBuilder.Weapons;
                            m_botBuilder.Engine    = m_inventoryBuilder.Engine;
                            m_botBuilder.Armor     = m_inventoryBuilder.Armor;
                            m_botBuilder.Radar     = m_inventoryBuilder.Radar;
                        }
                    }
                    m_botBuilder.ShipTemplateID = template.ID;
                }
                else
                {
                    var builderWithAllItems = MyMwcObjectBuilder_SmallShip_Bot.CreateObjectBuilderWithAllItems(templateBuilder.Builder.ShipType, MyShipTypeConstants.GetShipTypeProperties(templateBuilder.Builder.ShipType).GamePlay.CargoCapacity);
                    if (m_botBuilder.ShipTemplateID != null)
                    {
                        m_botBuilder.Inventory = builderWithAllItems.Inventory;
                        m_botBuilder.Weapons   = builderWithAllItems.Weapons;
                        m_botBuilder.Engine    = builderWithAllItems.Engine;
                        m_botBuilder.Armor     = builderWithAllItems.Armor;
                        m_botBuilder.Radar     = builderWithAllItems.Radar;
                    }
                    m_botBuilder.ShipTemplateID = null;
                }
                m_botBuilder.ShipType = templateBuilder.Builder.ShipType;
                CloseAndCallOnOk();
            }
            else if (m_bot != null) // edit SmallShip
            {
                Matrix matrix = m_bot.WorldMatrix;
                MyMwcObjectBuilder_SmallShip_Bot botBuilder = m_bot.GetObjectBuilder(true) as MyMwcObjectBuilder_SmallShip_Bot;
                System.Diagnostics.Debug.Assert(botBuilder != null);

                botBuilder.Faction      = (MyMwcObjectBuilder_FactionEnum)m_selectShipFactionCombobox.GetSelectedKey();
                botBuilder.AITemplate   = (MyAITemplateEnum)m_selectAITemplateCombobox.GetSelectedKey();
                botBuilder.Aggressivity = m_aggresivitySlider.GetValue();
                botBuilder.SeeDistance  = m_seeDistanceSlider.GetValue();
                botBuilder.ShipType     = (MyMwcObjectBuilder_SmallShip_TypesEnum)m_selectSmallShipCombobox.GetSelectedKey();

                if (m_inventoryBuilder != null)
                {
                    botBuilder.Inventory = m_inventoryBuilder.Inventory;
                    botBuilder.Weapons   = m_inventoryBuilder.Weapons;
                    botBuilder.Engine    = m_inventoryBuilder.Engine;
                    botBuilder.Armor     = m_inventoryBuilder.Armor;
                    botBuilder.Radar     = m_inventoryBuilder.Radar;
                }

                MyEditorGizmo.ClearSelection();
                m_newBotBuilderToInit     = botBuilder;
                m_newBotWorldMatrixToInit = matrix;
                m_bot.MarkForClose();
                m_bot.OnClose += OnOldBodClose;
            }
            else // create SmallShip
            {
                MyMwcObjectBuilder_SmallShip_TypesEnum shipType = (MyMwcObjectBuilder_SmallShip_TypesEnum)
                                                                  Enum.ToObject(typeof(MyMwcObjectBuilder_SmallShip_TypesEnum), m_selectSmallShipCombobox.GetSelectedKey());

                MyMwcObjectBuilder_FactionEnum shipFaction = (MyMwcObjectBuilder_FactionEnum)
                                                             Enum.ToObject(typeof(MyMwcObjectBuilder_FactionEnum), m_selectShipFactionCombobox.GetSelectedKey());

                MyMwcPositionAndOrientation      positionAndOrientation = new MyMwcPositionAndOrientation(m_newObjectPosition, Vector3.Forward, Vector3.Up);
                MyMwcObjectBuilder_SmallShip_Bot botBuilder             = MyEditor.CreateDefaultBotObjectBuilder(positionAndOrientation.Position, positionAndOrientation.Forward,
                                                                                                                 positionAndOrientation.Up, shipType, shipFaction);

                botBuilder.AITemplate   = (MyAITemplateEnum)m_selectAITemplateCombobox.GetSelectedKey();
                botBuilder.Aggressivity = m_aggresivitySlider.GetValue();
                botBuilder.SeeDistance  = m_seeDistanceSlider.GetValue();

                MyEditor.Static.CreateFromObjectBuilder(botBuilder, Matrix.CreateWorld(m_newObjectPosition, Vector3.Forward, Vector3.Up), m_screenPosition);
                CloseAndCallOnOk();
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns>Return false when all players are dead</returns>
        public bool GetSafeRespawnPositionNearPlayer(MyMwcObjectBuilder_SmallShip_TypesEnum shipType, out MyMwcPositionAndOrientation positionAndOrientation)
        {
            foreach (var player in Peers.Players)
            {
                if (player.Ship != null && !player.Ship.IsDead())
                {
                    Vector3 position;
                    if (GetSafeRespawnPositionNearEntity(shipType, player.Ship, out position))
                    {
                        positionAndOrientation = new MyMwcPositionAndOrientation(position, player.Ship.GetForward(), player.Ship.GetUp());
                        return true;
                    }
                    else
                    {
                        // Inside ship
                        positionAndOrientation = new MyMwcPositionAndOrientation(player.Ship.GetPosition(), player.Ship.GetForward(), player.Ship.GetUp());
                        return true;
                    }
                }
            }

            positionAndOrientation = default(MyMwcPositionAndOrientation);
            return false;
        }
        private bool GetSafeRespawnPositionNearEntity(MyMwcObjectBuilder_SmallShip_TypesEnum shipType, MyEntity entity, out Vector3 position)
        {
            float dist = entity.WorldVolume.Radius * 2;

            for (int c = 15; c-- != 0; )
            {
                Vector3 randomPointInSphere = MyMwcUtils.GetRandomVector3Normalized() * MyMwcUtils.GetRandomFloat(0, 1) * dist; // Random point in sphere
                Vector3 newTestPos = entity.GetPosition() + randomPointInSphere;

                var shipRadius = MinerWars.AppCode.Game.Models.MyModels.GetModelOnlyData(MyShipTypeConstants.GetShipTypeProperties(shipType).Visual.ModelLod0Enum).BoundingSphere.Radius;

                BoundingSphere bsphere = new BoundingSphere(newTestPos, shipRadius);
                MyEntity col = MyEntities.GetIntersectionWithSphere(ref bsphere);

                MyLine line = new MyLine(entity.GetPosition(), newTestPos);

                if (col == null && MyEntities.GetAnyIntersectionWithLine(ref line, entity, null, false, true, false, false) == null)
                {
                    position = newTestPos;
                    return true;
                }
            }
            position = default(Vector3);
            return false;
        }
        public MySmallShipBot CreateFriend(string name, float? maxHealth = null, float healthPercentage = 1.0f, MyMwcObjectBuilder_SmallShip_TypesEnum shipType = MyMwcObjectBuilder_SmallShip_TypesEnum.GETTYSBURG)
        {
            var bot = MyGuiScreenGamePlay.Static.CreateFakeBot(
               name,
               shipType,
               MySession.PlayerShip.GetFormationPosition(MySession.PlayerShip.Followers.Count),
               1f,
               MySession.PlayerShip.Faction);

            bot.MaxHealth = maxHealth.HasValue ? maxHealth.Value : bot.GetDefaultMaxHealth();
            bot.Health = bot.MaxHealth * healthPercentage;

            bot.Follow(MySession.PlayerShip);

            return bot;
        }
Пример #33
0
        public static MySmallShipBot InsertFriend(MyActorEnum actorEnum, MyMwcObjectBuilder_SmallShip_TypesEnum? shipType = null)
        {
            MyMwcObjectBuilder_SmallShip_TypesEnum selectedShipType;
            if (shipType.HasValue)
            {
                selectedShipType = shipType.Value;
            }
            else
            {
                switch (actorEnum)
                {
                    case MyActorEnum.TARJA:
                        selectedShipType = MyMwcObjectBuilder_SmallShip_TypesEnum.DOON;
                        break;
                    case MyActorEnum.VALENTIN:
                        selectedShipType = MyMwcObjectBuilder_SmallShip_TypesEnum.HAMMER;
                        break;
                    default:
                        selectedShipType = MyMwcObjectBuilder_SmallShip_TypesEnum.GETTYSBURG;
                        break;
                }
            }

            MySmallShipBot bot;

            string actorSystemName = MyActorConstants.GetActorName(actorEnum);

            if (!MyEntities.EntityExists(actorSystemName))
            {
                MyMwcLog.WriteLine("Insert " + actorSystemName + " - START");

                bot = MyGuiScreenGamePlay.Static.CreateFriend(MyTextsWrapper.Get(MyActorConstants.GetActorProperties(actorEnum).DisplayName).ToString(), 100000, 1, selectedShipType);
                bot.SetName(actorSystemName);
                bot.Save = true;
                bot.LeaderLostEnabled = true;
                bot.IsDestructible = false;
                bot.SetWorldMatrix(Matrix.CreateWorld(bot.GetPosition(), MySession.PlayerShip.WorldMatrix.Forward, MySession.PlayerShip.WorldMatrix.Up));
                bot.Faction = MyMwcObjectBuilder_FactionEnum.Rainiers;
                bot.AIPriority = -5;

                MyMwcLog.WriteLine("Insert " + actorSystemName + " - END");
            }
            else
            {
                bot = MyEntities.GetEntityByName(actorSystemName) as MySmallShipBot;
                bot.Save = true;
                bot.LeaderLostEnabled = true;     // Not persisted for now
                MyMwcLog.WriteLine("Insert " + actorSystemName + " - already loaded");
            }

            //Init smaller box physics because of following player problems
            bot.InitPhysics(1 / MySmallShipConstants.FRIEND_SMALL_SHIP_MODEL_SCALE, bot.ShipTypeProperties.Visual.MaterialType);
            bot.Follow(MySession.PlayerShip);

            if (!MySession.PlayerFriends.Contains(bot))
            {
                MySession.PlayerFriends.Add(bot);
            }

            Debug.Assert(bot.Save, "Bot must have save flag to work in coop");

            return bot;
        }
Пример #34
0
 public static MyShipTypeProperties GetShipTypeProperties(MyMwcObjectBuilder_SmallShip_TypesEnum shipType)
 {
     Debug.Assert(ShipTypeProperties.ContainsKey((int)shipType));
     return ShipTypeProperties[(int)shipType];
 }
 private StringBuilder GetTemplatePrefix(MyMwcObjectBuilder_SmallShip_TypesEnum shipType) 
 {
     StringBuilder prefix = new StringBuilder();
     MyMwcUtils.AppendStringBuilder(prefix, ((MyGuiSmallShipHelperSmallShip)MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip, (int)shipType)).Name);
     prefix.Append(" - ");
     return prefix;
 }
Пример #36
0
 public static MyShipTypeProperties GetShipTypeProperties(MyMwcObjectBuilder_SmallShip_TypesEnum shipType)
 {
     Debug.Assert(ShipTypeProperties.ContainsKey((int)shipType));
     return(ShipTypeProperties[(int)shipType]);
 }