public MySmallShipTemplate(int id, StringBuilder name, MyMwcObjectBuilder_SmallShip builder, bool isSavedOnServer)
 {
     ID = id;
     Name = name;
     Builder = builder;
     SavedToServer = isSavedOnServer;
 }
 public void ApplyToSmallShipBuilder(MyMwcObjectBuilder_SmallShip builder) 
 {
     var cloneBuilder = Builder.Clone() as MyMwcObjectBuilder_SmallShip;
     builder.Inventory = cloneBuilder.Inventory;
     builder.Weapons = cloneBuilder.Weapons;
     builder.Armor = cloneBuilder.Armor;
     builder.Engine = cloneBuilder.Engine;
     builder.Radar = cloneBuilder.Radar;
     builder.ShipType = cloneBuilder.ShipType;
 }
 public MyMwcObjectBuilder_Player(float health, float money, float withoutOxygen,
     MyMwcObjectBuilder_PlayerStatistics playerStatisticsObjectBuilder, MyMwcObjectBuilder_SmallShip shipObjectBuilder, MyMwcObjectBuilder_ShipConfig shipConfigObjectBuilder)
 {
     Health = health;
     Money = money;
     WithoutOxygen = withoutOxygen;
     PlayerStatisticsObjectBuilder = playerStatisticsObjectBuilder;
     ShipObjectBuilder = shipObjectBuilder;
     ShipConfigObjectBuilder = shipConfigObjectBuilder;
 }
示例#4
0
 public MyMwcObjectBuilder_SmallShip_Bot(MyMwcObjectBuilder_SmallShip smallShip,
                                         MyAITemplateEnum aiTemplate,
                                         float aggressivity,
                                         float seeDistance,
                                         float sleepDistance,
                                         MyPatrolMode patrolMode,
                                         int?shipTemplateId,
                                         uint?leader,
                                         BotBehaviorType idleBehavior,
                                         int aiPriority,
                                         bool leaderLostEnabled,
                                         bool activeAI)
     : this(smallShip.ShipType, smallShip.Inventory, smallShip.Weapons, smallShip.Engine, smallShip.AssignmentOfAmmo, smallShip.Armor, smallShip.Radar,
            smallShip.ShipMaxHealth, smallShip.ShipHealthRatio, smallShip.ArmorHealth, smallShip.Oxygen, smallShip.Fuel,
            smallShip.ReflectorLight, smallShip.ReflectorLongRange, smallShip.Faction, aiTemplate, aggressivity, seeDistance, sleepDistance, patrolMode, leader, idleBehavior, smallShip.ReflectorShadowDistance,
            aiPriority, leaderLostEnabled, activeAI)
 {
     ShipTemplateID = shipTemplateId;
 }
示例#5
0
        public virtual bool IsSameAs(MyMwcObjectBuilder_Ship e)
        {
            MyMwcObjectBuilder_SmallShip ent = e as MyMwcObjectBuilder_SmallShip;

            if (ShipType != ent.ShipType)
            {
                return(false);
            }
            if (Weapons != ent.Weapons)
            {
                return(false);
            }
            if (ShipMaxHealth != ent.ShipMaxHealth)
            {
                return(false);
            }
            if (ShipHealthRatio != ent.ShipHealthRatio)
            {
                return(false);
            }
            if (ArmorHealth != ent.ArmorHealth)
            {
                return(false);
            }
            if (Oxygen != ent.Oxygen)
            {
                return(false);
            }
            if (Fuel != ent.Fuel)
            {
                return(false);
            }
            if (ReflectorLight != ent.ReflectorLight)
            {
                return(false);
            }
            if (ReflectorLongRange != ent.ReflectorLongRange)
            {
                return(false);
            }
            return(true);
        }
 public MyMwcObjectBuilder_SmallShip_Player(MyMwcObjectBuilder_SmallShip ship)
     : this(ship.ShipType, ship.Inventory, ship.Weapons, ship.Engine, ship.AssignmentOfAmmo, ship.Armor, ship.Radar, ship.ShipMaxHealth, ship.ShipHealthRatio, ship.ArmorHealth,
     0, ship.Oxygen, ship.Fuel, ship.ReflectorLight, ship.ReflectorLongRange, ship.ReflectorShadowDistance, ship.AIPriority)
 {
 }
示例#7
0
 public MyMwcObjectBuilder_SmallShip_Player(MyMwcObjectBuilder_SmallShip ship)
     : this(ship.ShipType, ship.Inventory, ship.Weapons, ship.Engine, ship.AssignmentOfAmmo, ship.Armor, ship.Radar, ship.ShipMaxHealth, ship.ShipHealthRatio, ship.ArmorHealth,
            0, ship.Oxygen, ship.Fuel, ship.ReflectorLight, ship.ReflectorLongRange, ship.ReflectorShadowDistance, ship.AIPriority)
 {
 }
 public MyMwcObjectBuilder_SmallShip_Bot(MyMwcObjectBuilder_SmallShip smallShip,
     MyAITemplateEnum aiTemplate,
     float aggressivity,
     float seeDistance,
     float sleepDistance,
     MyPatrolMode patrolMode,
     int? shipTemplateId,
     uint? leader,
     BotBehaviorType idleBehavior,
     int aiPriority,
     bool leaderLostEnabled,
     bool activeAI)
     : this(smallShip.ShipType, smallShip.Inventory, smallShip.Weapons, smallShip.Engine, smallShip.AssignmentOfAmmo, smallShip.Armor, smallShip.Radar,
     smallShip.ShipMaxHealth, smallShip.ShipHealthRatio, smallShip.ArmorHealth, smallShip.Oxygen, smallShip.Fuel,
     smallShip.ReflectorLight, smallShip.ReflectorLongRange, smallShip.Faction, aiTemplate, aggressivity, seeDistance, sleepDistance, patrolMode, leader, idleBehavior, smallShip.ReflectorShadowDistance,
     aiPriority, leaderLostEnabled, activeAI) 
 {
     ShipTemplateID = shipTemplateId;
 }
 public MySmallShipBuilderWithName(StringBuilder name, MyMwcObjectBuilder_SmallShip builder)
     : this(name, builder, null)
 {
 }
        private void OnEditBot(MyMwcObjectBuilder_SmallShip bldr, MySmallShipTemplate smallShipTemplate)
        {
            BotTemplate newTemplate = new BotTemplate();
            MyMwcObjectBuilder_SmallShip_Bot botBuilder = bldr as MyMwcObjectBuilder_SmallShip_Bot;

            newTemplate.m_builder = new MyMwcObjectBuilder_SmallShip_Bot(
                smallShipTemplate.Builder.ShipType,
                null,
                null,
                null,
                smallShipTemplate.Builder.AssignmentOfAmmo,
                null,
                null,
                smallShipTemplate.Builder.ShipMaxHealth,
                smallShipTemplate.Builder.ShipHealthRatio,
                smallShipTemplate.Builder.ArmorHealth,
                smallShipTemplate.Builder.Oxygen,
                smallShipTemplate.Builder.Fuel,
                smallShipTemplate.Builder.ReflectorLight,
                smallShipTemplate.Builder.ReflectorLongRange,
                smallShipTemplate.Builder.Faction,
                botBuilder != null ? botBuilder.AITemplate : MyAITemplateEnum.DEFAULT,
                botBuilder != null ? botBuilder.Aggressivity : 0,
                botBuilder != null ? botBuilder.SeeDistance : 1000,
                botBuilder != null ? botBuilder.SleepDistance : 1000,
                MyPatrolMode.CYCLE,
                null,
                BotBehaviorType.IDLE,
                MyLightsConstants.MAX_SPOTLIGHT_SHADOW_RANGE, bldr.AIPriority, false, true); // faction will be assigned after spawnpoint genertation
            newTemplate.m_builder.ShipTemplateID = smallShipTemplate.ID;
            newTemplate.m_name = smallShipTemplate.Name.ToString();
            int key = m_selectShipsListbox.GetSelectedItem().Key;
            m_selectShipsListbox.RemoveItem(key);
            
            m_selectShipsListbox.AddItem(key, smallShipTemplate.Name);

            m_bots[key] = newTemplate;
        }
        private void AddBot(MyMwcObjectBuilder_SmallShip bldr, MySmallShipTemplate smallShipTemplate)
        {
            BotTemplate newTemplate = new BotTemplate();
            MyMwcObjectBuilder_SmallShip_Bot botBuilder = bldr as MyMwcObjectBuilder_SmallShip_Bot;            

            newTemplate.m_builder = new MyMwcObjectBuilder_SmallShip_Bot(
                smallShipTemplate.Builder.ShipType,
                null,
                null,
                null,
                smallShipTemplate.Builder.AssignmentOfAmmo,
                null,
                null,
                smallShipTemplate.Builder.ShipMaxHealth,
                smallShipTemplate.Builder.ShipHealthRatio,
                smallShipTemplate.Builder.ArmorHealth,
                smallShipTemplate.Builder.Oxygen,
                smallShipTemplate.Builder.Fuel,
                smallShipTemplate.Builder.ReflectorLight,
                smallShipTemplate.Builder.ReflectorLongRange,
                smallShipTemplate.Builder.Faction,
                botBuilder != null ? botBuilder.AITemplate : MyAITemplateEnum.DEFAULT,
                botBuilder != null ? botBuilder.Aggressivity : 0,
                botBuilder != null ? botBuilder.SeeDistance : 1000,
                botBuilder != null ? botBuilder.SleepDistance : 1000,
                MyPatrolMode.CYCLE,
                null,
                BotBehaviorType.IDLE,
                MyLightsConstants.MAX_SPOTLIGHT_SHADOW_RANGE, 0, false, true); // faction will be assigned after spawnpoint genertation
            newTemplate.m_builder.ShipTemplateID = smallShipTemplate.ID;            
            
            newTemplate.m_name = smallShipTemplate.Name.ToString();

            // find nearest new non template index
            int index = -1;
            foreach (int key in m_bots.Keys)
            {
                if (index < key && key < TEMPLATE_INDEX_OFFSET)
                {
                    index = key;
                }
            }
            index++;

            AddBot(index, newTemplate);

        }
示例#12
0
 public static MyMwcObjectBuilder_SmallShip CreateDefaultSmallShipObjectBuilder(Matrix matrix)
 {
     MyMwcObjectBuilder_SmallShip objectBuilder = new MyMwcObjectBuilder_SmallShip(
         MyMwcObjectBuilder_SmallShip_TypesEnum.GETTYSBURG,
         null,
         new List<MyMwcObjectBuilder_SmallShip_Weapon>(),
         new MyMwcObjectBuilder_SmallShip_Engine(MyMwcObjectBuilder_SmallShip_Engine_TypesEnum.PowerCells_1),
         new List<MyMwcObjectBuilder_AssignmentOfAmmo>(),
         new MyMwcObjectBuilder_SmallShip_Armor(MyMwcObjectBuilder_SmallShip_Armor_TypesEnum.Basic),
         new MyMwcObjectBuilder_SmallShip_Radar(MyMwcObjectBuilder_SmallShip_Radar_TypesEnum.Radar_1),
         MyGameplayConstants.MAXHEALTH_SMALLSHIP, MyGameplayConstants.HEALTH_RATIO_MAX, float.MaxValue, float.MaxValue, float.MaxValue, true, false, MyLightsConstants.MAX_SPOTLIGHT_SHADOW_RANGE, 0);
     objectBuilder.PositionAndOrientation = new MyMwcPositionAndOrientation(matrix);
     return objectBuilder;
 }
示例#13
0
        static void RemoveRedundantWeapons(MyMwcObjectBuilder_SmallShip shipBuilder, int maxWeapons)
        {
            int harvestersAndDrillCount = 0;
            foreach (var weaponBuilder in shipBuilder.Weapons)
            {
                if (weaponBuilder.IsHarvester || weaponBuilder.IsDrill)
                {
                    harvestersAndDrillCount++;
                }
            }

            int maxWeaponsWithHarvestersAndDrills = maxWeapons + harvestersAndDrillCount;

            int indexToRemove = shipBuilder.Weapons.Count - 1;
            while (shipBuilder.Weapons.Count > maxWeaponsWithHarvestersAndDrills)
            {
                var weapon = shipBuilder.Weapons[indexToRemove];
                if (weapon.IsNormalWeapon)
                {
                    shipBuilder.Weapons.Remove(weapon);
                }

                indexToRemove--;
            }
        }
示例#14
0
        /// <summary>
        /// This is the real initialization of the class. This separation lets us control when the heavy-lifting is
        /// done in regards to initialization.
        /// </summary>
        /// <param name="helperName">This objects name. For debugging only. Bot default: "Bot".</param>
        /// <param name="scale">Scale for bot model and JLX (only) collions. Not currently used for line-triangleVertexes intersections in octree. Bot default: null.</param>
        /// <param name="doInitInsertionTest">Test for intital intersection</param>
        void InitShip(StringBuilder displayName, /*Matrix matrix,*/MyMwcObjectBuilder_SmallShip objectBuilder, float? scale)
        {
            ShipType = objectBuilder.ShipType;

            m_subObjects.Clear();

            GetModelShipSubObject(ref m_subObjectPlayerHeadForCockpitInteriorTranslation, m_shipTypeProperties.Visual.ModelLod0Enum, "PLAYER_HEAD", false);

            //Will be removed
            if (m_subObjectPlayerHeadForCockpitInteriorTranslation == null)
            {
                GetModelShipSubObject(ref m_subObjectPlayerHeadForCockpitInteriorTranslation, m_shipTypeProperties.Visual.ModelLod0Enum, "COCKPIT", false);
            }

            System.Diagnostics.Debug.Assert(m_subObjectPlayerHeadForCockpitInteriorTranslation != null);

            GetModelShipSubObject(m_subObjectEngineThrustBackwardLeftside, m_shipTypeProperties.Visual.ModelLod0Enum, "ENGINE_THRUST_BACKWARD_LEFTSIDE", true);
            GetModelShipSubObject(m_subObjectEngineThrustBackwardRightside, m_shipTypeProperties.Visual.ModelLod0Enum, "ENGINE_THRUST_BACKWARD_RIGHTSIDE", true);
            GetModelShipSubObject(m_subObjectEngineThrustStrafeLeft, m_shipTypeProperties.Visual.ModelLod0Enum, "ENGINE_THRUST_STRAFE_LEFT", true);
            GetModelShipSubObject(m_subObjectEngineThrustStrafeRight, m_shipTypeProperties.Visual.ModelLod0Enum, "ENGINE_THRUST_STRAFE_RIGHT", true);
            GetModelShipSubObject(m_subObjectEngineThrustDownLeftside, m_shipTypeProperties.Visual.ModelLod0Enum, "ENGINE_THRUST_DOWN_LEFTSIDE", true);
            GetModelShipSubObject(m_subObjectEngineThrustDownRightside, m_shipTypeProperties.Visual.ModelLod0Enum, "ENGINE_THRUST_DOWN_RIGHTSIDE", true);
            GetModelShipSubObject(m_subObjectEngineThrustForwardLeftside, m_shipTypeProperties.Visual.ModelLod0Enum, "ENGINE_THRUST_FORWARD_LEFTSIDE", true);
            GetModelShipSubObject(m_subObjectEngineThrustForwardRightside, m_shipTypeProperties.Visual.ModelLod0Enum, "ENGINE_THRUST_FORWARD_RIGHTSIDE", true);
            GetModelShipSubObject(m_subObjectEngineThrustUpLeftside, m_shipTypeProperties.Visual.ModelLod0Enum, "ENGINE_THRUST_UP_LEFTSIDE", true);
            GetModelShipSubObject(m_subObjectEngineThrustUpRightside, m_shipTypeProperties.Visual.ModelLod0Enum, "ENGINE_THRUST_UP_RIGHTSIDE", true);
            GetModelShipSubObject(m_subObjectReflectorLeft, m_shipTypeProperties.Visual.ModelLod0Enum, "REFLECTOR_LEFT", false);
            GetModelShipSubObject(m_subObjectReflectorRight, m_shipTypeProperties.Visual.ModelLod0Enum, "REFLECTOR_RIGHT", false);
            GetModelShipSubObject(ref m_subObjectLight, m_shipTypeProperties.Visual.ModelLod0Enum, "LIGHT_01", false);
            GetModelShipSubObject(m_subObjectEngineThrustBackwardSmallLeftside, m_shipTypeProperties.Visual.ModelLod0Enum, "ENGINE_THRUST_BACKWARD_SMALL_LEFTSIDE", true);
            GetModelShipSubObject(m_subObjectEngineThrustBackwardSmallRightside, m_shipTypeProperties.Visual.ModelLod0Enum, "ENGINE_THRUST_BACKWARD_SMALL_RIGHTSIDE", true);
            GetModelShipSubObject(m_subObjectEngineThrustBackward2Leftside, m_shipTypeProperties.Visual.ModelLod0Enum, "ENGINE_THRUST_BACKWARD2_LEFTSIDE", true);
            GetModelShipSubObject(m_subObjectEngineThrustBackward2Rightside, m_shipTypeProperties.Visual.ModelLod0Enum, "ENGINE_THRUST_BACKWARD2_RIGHTSIDE", true);
            GetModelShipSubObject(m_subObjectEngineThrustBackward2Middle, m_shipTypeProperties.Visual.ModelLod0Enum, "ENGINE_THRUST_BACKWARD2_MIDDLE", true);

            base.Init(displayName, m_shipTypeProperties.Visual.ModelLod0Enum, m_shipTypeProperties.Visual.ModelLod1Enum, null, scale, objectBuilder);

            this.GlassDirtLevel = MIN_GLASS_DIRT_LEVEL;

            m_playerHeadLocal = Vector3.Zero;
            m_playerHeadExtraShake = Vector3.Zero;
            m_playerViewAngleLocal = Vector3.Zero;
            m_playerViewAngleExtraShake = Vector3.Zero;

            m_shaker = new MyCameraHeadShake();

            CockpitGlassModelEnum = m_shipTypeProperties.Visual.CockpitGlassModel;
            CockpitInteriorModelEnum = m_shipTypeProperties.Visual.CockpitInteriorModel;
            m_glassIdealPhysObject = null;

            // it can happen that too many weapons are in this object builder (old server data, etc.)
            // so we have to remove weapons that don't fit into this ship's slots
            RemoveRedundantWeapons(objectBuilder, m_shipTypeProperties.GamePlay.MaxWeapons);

            Weapons = new MySmallShipWeapons(this, m_shipTypeProperties, MAX_AVAILABLE_SLOTS);
            //Weapons = new MySmallShipWeapons(this, m_shipTypeProperties, m_shipTypeProperties.GamePlay.MaxWeapons);
            Weapons.Init(objectBuilder.Weapons, objectBuilder.AssignmentOfAmmo);

            CubeBuilder = new MyCubeBuilder();
            CubeBuilder.Init(null, null, null, this, null, null);

            ////This solves bad saved values in DB
            //if (objectBuilder.ShipMaxHealth == 0 || objectBuilder.ShipMaxHealth == MyGameplayConstants.MAX_HEALTH_MAX)
            //{
            //    objectBuilder.ShipMaxHealth = m_gameplayProperties.MaxHealth;
            //}

            ////This solves bad saved values in DB
            //if (objectBuilder.ShipHealthRatio == 0 || objectBuilder.ShipHealthRatio == MyGameplayConstants.HEALTH_MAX)
            //{
            //    objectBuilder.ShipHealthRatio = m_gameplayProperties.MaxHealth;
            //}

            //MaxHealth = objectBuilder.ShipMaxHealth;
            //Health = objectBuilder.ShipHealthRatio;

            // TODO: MartinBauer - Marcus is loaded from checkpoint and should be Indestructible
            //Debug.Assert(IsDestructible);
            //IsDestructible = true;
            SetMaxHealth(objectBuilder.ShipMaxHealth);
            HealthRatio = objectBuilder.ShipHealthRatio;
            ArmorHealth = objectBuilder.ArmorHealth;
            Oxygen = objectBuilder.Oxygen;
            Fuel = objectBuilder.Fuel;
            Engine = objectBuilder.Engine;
            Armor = objectBuilder.Armor;
            Config.ReflectorLight.SetValue(objectBuilder.ReflectorLight);
            Config.ReflectorLongRange.SetValue(objectBuilder.ReflectorLongRange);
            ReflectorShadowDistance = objectBuilder.ReflectorShadowDistance;

            // Clamp ArmorHealth values
            ArmorHealth = MathHelper.Clamp(ArmorHealth, 0, MaxArmorHealth);

            m_lockTargetCheckTime = 0;
            m_reflectorProperies = new MyReflectorConfig(this);

            SetWorldMatrix(objectBuilder.PositionAndOrientation.GetMatrix());

            //  Collision SPHERE - works best if miner ship is controled by human player (so we ignore high impulses after collision, good sliding along walls, etc)
            MyModel model = MyModels.GetModelOnlyData(m_shipTypeProperties.Visual.ModelLod0Enum);
            //InitSpherePhysics(objectBuilder is MyMwcObjectBuilder_SmallShip_Player ? MyMaterialType.PLAYERSHIP : m_shipTypeProperties.Visual.MaterialType, model, m_shipTypeProperties.Physics.Mass, 0, MyConstants.COLLISION_LAYER_ALL, RigidBodyFlag.RBF_DEFAULT);

            Weight = ShipTypeProperties.Physics.Mass;

            InitPhysics(1 / MySmallShipConstants.ALL_SMALL_SHIP_MODEL_SCALE, objectBuilder is MyMwcObjectBuilder_SmallShip_Player
                    ? MyMaterialType.PLAYERSHIP
                    : m_shipTypeProperties.Visual.MaterialType);

            m_cameraSpring = new MyCameraSpring(this);

            UpdateParked();
            UpdateLight();

            UpdatePlayerHeadForCockpitInteriorWorldMatrix();

            // if this is player's ship, i will register fuel, oxygen, electricity and damage warnings
            if (objectBuilder is MyMwcObjectBuilder_SmallShip_Player)
            {
                MySession.Static.Inventory.OnInventoryContentChange += CheckPointInventory_OnInventoryContentChange;
                LoadHackingTool();
                ToolKits = new MyToolKits(this, MySession.Static.Player);
                InitShipDetector();
                m_detectedObjects = new List<IMyObjectToDetect>();
                OnMarkForClose += new Action<MyEntity>(PlayerShip_OnMarkForClose);

                // sector boundaries
                m_sectorBoundariesWarning = new MyHudTextWarning(MyTextsWrapperEnum.Blank);
                MyHudWarnings.Add(
                    this,
                    new MyHudWarningGroup(
                        new List<MyHudWarning>()
                            {
                                new MyHudWarning(
                                    IsCloseToSectorBoundaries,
                                    null,
                                    m_sectorBoundariesWarning,
                                    0)
                            }, canBeTurnedOff: false
                        ));

                // fuel
                MyHudWarnings.Add(this, new MyHudWarningGroup(new List<MyHudWarning>()
                    { 
                        new MyHudWarning(HasNoFuelLevel, new MyHudSoundWarning(MySoundCuesEnum.HudFuelNoWarning, MySmallShipConstants.WARNING_FUEL_NO_INVERVAL), 
                            new MyHudTextWarning(MyTextsWrapperEnum.NotificationFuelNo), 0),
                        new MyHudWarning(HasCriticalFuelLevel, new MyHudSoundWarning(MySoundCuesEnum.HudFuelCriticalWarning, MySmallShipConstants.WARNING_FUEL_CRITICAL_INVERVAL), 
                            new MyHudTextWarning(MyTextsWrapperEnum.NotificationFuelCritical), 1),
                        new MyHudWarning(HasLowFuelLevel, new MyHudSoundWarning(MySoundCuesEnum.HudFuelLowWarning, MySmallShipConstants.WARNING_FUEL_LOW_INVERVAL), 
                            new MyHudTextWarning(MyTextsWrapperEnum.NotificationFuelLow), 2) 
                    }, canBeTurnedOff: true
                ));
                //// death breath
                //MyHudWarnings.Add(this, new MyHudWarningGroup(new List<MyHudWarning>()
                //    {
                //        new MyHudWarning(HasNoOxygen, new MyHudSoundWarning(MySoundCuesEnum.SfxPlayerDeathBreath, 0), null, 0)
                //    }, canBeTurnedOff:false
                //));
                // oxygen
                MyHudWarnings.Add(this, new MyHudWarningGroup(new List<MyHudWarning>()
                     {
                        // TODO simon when cue is prepared
                        new MyHudWarning(HasNoOxygen, new MyHudSoundWarning(MySoundCuesEnum.HudOxygenNoWarning, MySmallShipConstants.WARNING_NO_OXYGEN_INVERVAL), 
                            new MyHudTextWarning(MyTextsWrapperEnum.NotificationNoOxygen), 0),
                        new MyHudWarning(HasCriticalOxygenLevel, new MyHudSoundWarning(MySoundCuesEnum.HudOxygenCriticalWarning, MySmallShipConstants.WARNING_OXYGEN_CRITICAL_INVERVAL), 
                            new MyHudTextWarning(MyTextsWrapperEnum.NotificationOxygenCritical), 1),
                        new MyHudWarning(HasLowOxygenLevel, new MyHudSoundWarning(MySoundCuesEnum.HudOxygenLowWarning, MySmallShipConstants.WARNING_OXYGEN_LOW_INVERVAL), 
                            new MyHudTextWarning(MyTextsWrapperEnum.NotificationOxygenLow), 2) 
                     }, canBeTurnedOff: true
                ));
                // oxygen leaking
                MyHudWarnings.Add(this, new MyHudWarningGroup(new List<MyHudWarning>()
                    {
                        new MyHudWarning(IsOxygenLeaking, new MyHudSoundWarning(MySoundCuesEnum.HudOxygenLeakingWarning, MySmallShipConstants.WARNING_OXYGEN_LEAKING_INVERVAL), 
                            new MyHudTextWarning(MyTextsWrapperEnum.NotificationOxygenLeaking), 0)
                    }, canBeTurnedOff: true
                ));
                // damage
                MyHudWarnings.Add(this, new MyHudWarningGroup(new List<MyHudWarning>()
                    { 
                        new MyHudWarning(IsCriticalDamaged, new MyHudSoundWarning(MySoundCuesEnum.HudDamageCriticalWarning, MySmallShipConstants.WARNING_DAMAGE_CRITICAL_INVERVAL), 
                            new MyHudTextWarning(MyTextsWrapperEnum.NotificationDamageCritical), 0),
                        new MyHudWarning(IsDamagedForWarnignAlert, new MyHudSoundWarning(MySoundCuesEnum.HudDamageAlertWarning, MySmallShipConstants.WARNING_DAMAGE_ALERT_INVERVAL), 
                            new MyHudTextWarning(MyTextsWrapperEnum.NotificationDamageAlert), 1) 
                    }, canBeTurnedOff: true
                ));
                // ammo
                MyHudWarnings.Add(this, new MyHudWarningGroup(new List<MyHudWarning>()
                    { 
                        new MyHudWarning(HasNoAmmoLevel, new MyHudSoundWarning(MySoundCuesEnum.HudAmmoNoWarning, MySmallShipConstants.WARNING_AMMO_NO_INVERVAL), new MyHudTextWarning(MyTextsWrapperEnum.NotificationAmmoNo), 0),
                        new MyHudWarning(HasCriticalAmmoLevel, new MyHudSoundWarning(MySoundCuesEnum.HudAmmoCriticalWarning), null, 1),
                        new MyHudWarning(HasLowAmmoLevel, new MyHudSoundWarning(MySoundCuesEnum.HudAmmoLowWarning), null, 2) 
                    }, canBeTurnedOff: true
                ));
                // armor
                MyHudWarnings.Add(this, new MyHudWarningGroup(new List<MyHudWarning>()
                    { 
                        new MyHudWarning(HasNoArmorLevel, new MyHudSoundWarning(MySoundCuesEnum.HudArmorNoWarning, MySmallShipConstants.WARNING_ARMOR_NO_INVERVAL), 
                            new MyHudTextWarning(MyTextsWrapperEnum.NotificationArmorNo), 0),
                        new MyHudWarning(HasCriticalArmorLevel, new MyHudSoundWarning(MySoundCuesEnum.HudArmorCriticalWarning, MySmallShipConstants.WARNING_ARMOR_CRITICAL_INVERVAL), 
                            new MyHudTextWarning(MyTextsWrapperEnum.NotificationArmorCritical), 1),
                        new MyHudWarning(HasLowArmorLevel, new MyHudSoundWarning(MySoundCuesEnum.HudArmorLowWarning, MySmallShipConstants.WARNING_ARMOR_LOW_INVERVAL), 
                            new MyHudTextWarning(MyTextsWrapperEnum.NotificationArmorLow), 2) 
                    }, canBeTurnedOff: true
                ));
                // radar jammed
                MyHudWarnings.Add(this, new MyHudWarningGroup(new List<MyHudWarning>()
                    { 
                        new MyHudWarning(IsRadarJammed, new MyHudSoundWarning(MySoundCuesEnum.HudRadarJammedWarning, MySmallShipConstants.WARNING_RADAR_JAMMED_INVERVAL), new MyHudTextWarning(MyTextsWrapperEnum.RadarJammed), 0)
                    }, canBeTurnedOff: true
                ));
                // health
                MyHudWarnings.Add(this, new MyHudWarningGroup(new List<MyHudWarning>()
                    { 
                        new MyHudWarning(HasNoHealthLevel, null, new MyHudTextWarning(MyTextsWrapperEnum.SmallShipPilotDead), 0),
                        new MyHudWarning(HasCriticalHealthLevel, new MyHudSoundWarning(MySoundCuesEnum.HudHealthCriticalWarning, MySmallShipConstants.WARNING_HEALTH_CRITICAL_INVERVAL), 
                            new MyHudTextWarning(MyTextsWrapperEnum.NotificationHealthCritical), 1),
                        new MyHudWarning(HasLowHealthLevel, new MyHudSoundWarning(MySoundCuesEnum.HudHealthLowWarning, MySmallShipConstants.WARNING_HEALTH_LOW_INVERVAL), 
                            new MyHudTextWarning(MyTextsWrapperEnum.NotificationHealthLow), 2) 
                    }, canBeTurnedOff: true
                ));
                // radiation geiger
                MyHudWarnings.Add(this, new MyHudWarningGroup(new List<MyHudWarning>()
                    {
                        new MyHudWarning(IsRadiation, new MyHudSoundWarning(MySoundCuesEnum.SfxGeigerCounterHeavyLoop, MySmallShipConstants.GEIGER_BEEP_INTERVAL), null, 0)                            
                    }, canBeTurnedOff: false
                ));
                // radiation warning
                MyHudWarnings.Add(this, new MyHudWarningGroup(new List<MyHudWarning>()
                    {
                        new MyHudWarning(IsRadiationCritical, new MyHudSoundWarning(MySoundCuesEnum.HudRadiationWarning, MySmallShipConstants.WARNING_RADIATION_INTERVAL),                             
                            new MyHudTextWarning(MyTextsWrapperEnum.NotificationRadiationCritical), 0)                            
                    }, canBeTurnedOff: true
                ));
                // engine turn off
                MyHudWarnings.Add(this, new MyHudWarningGroup(new List<MyHudWarning>()
                    { 
                        new MyHudWarning(IsEngineTurnedOff, null, new MyHudTextWarning(MyTextsWrapperEnum.NotificationEngineOff, MyGuiManager.GetInput().GetGameControlTextEnum(MyGameControlEnums.WHEEL_CONTROL) ), 0),
                    }, canBeTurnedOff: true
                ));
                // movement slowdown
                MyHudWarnings.Add(this, new MyHudWarningGroup(new List<MyHudWarning>()
                    { 
                        new MyHudWarning(IsMovementSlowdownDisabled, null, new MyHudTextWarning(MyTextsWrapperEnum.NotificationMovementSlowdownEnabled, MyGuiManager.GetInput().GetGameControlTextEnum(MyGameControlEnums.MOVEMENT_SLOWDOWN)), 0),
                    }, canBeTurnedOff: true
                ));

                //// enemy alert
                //MyHudWarnings.Add(this, new MyHudWarningGroup()
                //    { 
                //        new MyHudWarning(IsEnemyDetected, new MyHudSoundWarning(MySoundCuesEnum.SfxEnemyAlertWarning, MySmallShipConstants.WARNING_ENEMY_ALERT_INVERVAL), null, 0)
                //    }, canBeTurnedOff:true
                //);
                // missile detected
                MyHudWarnings.Add(this, new MyHudWarningGroup(new List<MyHudWarning>()
                    { 
                        new MyHudWarning(IsMissileDetected, new MyHudSoundWarning(MySoundCuesEnum.SfxHudAlarmIncoming, MySmallShipConstants.WARNING_MISSILE_ALERT_INTERVAL), new MyHudTextWarning(MyTextsWrapperEnum.IncommingMissileAlarm), 1)
                    }, canBeTurnedOff: false
                ));
                // health low
                MyHudWarnings.Add(this, new MyHudWarningGroup(new List<MyHudWarning>()
                    { 
                        new MyHudWarning(IsShipDamage1Detected, new MyHudSoundWarning(MySoundCuesEnum.SfxHudAlarmDamageA, MySmallShipConstants.WARNING_HEALTH_CONSTANT1), null, 5),
                        new MyHudWarning(IsShipDamage2Detected, new MyHudSoundWarning(MySoundCuesEnum.SfxHudAlarmDamageB, MySmallShipConstants.WARNING_HEALTH_CONSTANT2), null, 4),
                        new MyHudWarning(IsShipDamage3Detected, new MyHudSoundWarning(MySoundCuesEnum.SfxHudAlarmDamageC, MySmallShipConstants.WARNING_HEALTH_CONSTANT3), null, 3),
                        new MyHudWarning(IsShipDamage4Detected, new MyHudSoundWarning(MySoundCuesEnum.SfxHudAlarmDamageD, MySmallShipConstants.WARNING_HEALTH_CONSTANT4), null, 2),
                        new MyHudWarning(IsShipDamage5Detected, new MyHudSoundWarning(MySoundCuesEnum.SfxHudAlarmDamageE, MySmallShipConstants.WARNING_HEALTH_CONSTANT5), null, 1),
                    }, canBeTurnedOff: false
                ));

                m_lowHealthAlertSounds.Add(MySoundCuesEnum.SfxHudAlarmDamageA);
                m_lowHealthAlertSounds.Add(MySoundCuesEnum.SfxHudAlarmDamageB);
                m_lowHealthAlertSounds.Add(MySoundCuesEnum.SfxHudAlarmDamageC);
                m_lowHealthAlertSounds.Add(MySoundCuesEnum.SfxHudAlarmDamageD);
                m_lowHealthAlertSounds.Add(MySoundCuesEnum.SfxHudAlarmDamageE);

                // Solar wind warning
                MyHudWarnings.Add(this, new MyHudWarningGroup(new List<MyHudWarning>()
                    {
                        new MyHudWarning(MySunWind.IsActiveForHudWarning, new MyHudSoundWarning(MySoundCuesEnum.HudSolarFlareWarning, MySmallShipConstants.WARNING_SOLAR_WIND_INTERVAL), new MyHudTextWarning(MyTextsWrapperEnum.NotificationSolarWindWarning, MyGuiManager.GetFontMinerWarsRed()), 0),
                    }, canBeTurnedOff: false
                ));

                // Explanation for players that stay in critical state for 30 seconds
                if (MyFakes.ENABLE_WARNING_EXPLANATION)
                {
                    MyHudWarnings.Add(this, new MyHudWarningGroup(new List<MyHudWarning>()
                        {
                            new MyHudWarning(DoesPlayerNeedExplanation, new MyHudSoundWarning(/*TODO:placeholder*/MySoundCuesEnum.SfxAlertVoc, MySmallShipConstants.WARNING_EXPLANATION_INTERVAL, MySmallShipConstants.WARNING_EXPLANATION_INITIAL_DELAY, false), null, 0),
                        }, canBeTurnedOff: true
                    ));
                }
            }

            //OnInventoryContentChange(Inventory);
        }
示例#15
0
 public MyMwcObjectBuilder_SmallShip_Bot(MyMwcObjectBuilder_SmallShip smallShip)
     : this(smallShip, MyAITemplateEnum.DEFAULT, 0, 1000, 1000, MyPatrolMode.CYCLE, null, null, BotBehaviorType.IDLE, smallShip.AIPriority, false, true)
 {
 }
        //  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;
        }
 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;
 }
        private void AddBot(MyMwcObjectBuilder_SmallShip bldr)
        {
            BotTemplate newTemplate = new BotTemplate();
            MyMwcObjectBuilder_SmallShip_Bot botBuilder = bldr as MyMwcObjectBuilder_SmallShip_Bot;
            System.Diagnostics.Debug.Assert(botBuilder != null);

            newTemplate.m_builder = new MyMwcObjectBuilder_SmallShip_Bot(
                bldr.ShipType,
                bldr.Inventory,
                bldr.Weapons,
                bldr.Engine,
                bldr.AssignmentOfAmmo,
                bldr.Armor,
                bldr.Radar,
                bldr.ShipMaxHealth,
                bldr.ShipHealthRatio,
                bldr.ArmorHealth,
                bldr.Oxygen,
                bldr.Fuel,
                bldr.ReflectorLight,
                bldr.ReflectorLongRange,
                bldr.Faction,
                botBuilder != null ? botBuilder.AITemplate : MyAITemplateEnum.DEFAULT,
                botBuilder != null ? botBuilder.Aggressivity : 0,
                botBuilder != null ? botBuilder.SeeDistance : 1000,
                botBuilder != null ? botBuilder.SleepDistance : 1000,
                MyPatrolMode.CYCLE,
                null,
                BotBehaviorType.IDLE,
                MyLightsConstants.MAX_SPOTLIGHT_SHADOW_RANGE, 0, false, true); // faction will be assigned after spawnpoint genertation
            MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip, (int)bldr.ShipType);
            //m_comboItems.AddItem(i, MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip, bldr.ShipType);

            //  MyMwcObjectBuilderTypeEnum.SmallShip, (int)m_inventory.SmallShips[i]).Description);

            newTemplate.m_name = ((MyGuiSmallShipHelperSmallShip)MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip, (int)bldr.ShipType)).Name.ToString();//bldr.ShipType.ToString();

            // find nearest new non template index
            int index = -1;
            foreach (int key in m_bots.Keys)
            {
                if (index < key && key < TEMPLATE_INDEX_OFFSET)
                {
                    index = key;
                }
            }
            index++;

            AddBot(index, newTemplate);

        }
        public void Respawn(MyMwcObjectBuilder_SmallShip shipBuilder, Matrix respawnPosition)
        {
            Log("Respawn faction: " + MyFactionConstants.GetFactionProperties(MySession.PlayerShip.Faction).Name);

            int oldPriority = 0;

            if (m_lastConfig == null && MySession.PlayerShip != null)
            {
                m_lastConfig = MySession.PlayerShip.Config.GetObjectBuilder();
            }

            if (MySession.PlayerShip != null)
            {
                oldPriority = MySession.PlayerShip.AIPriority;
                if (MySession.PlayerShip.IsDummy || MySession.PlayerShip.IsExploded())
                {
                    MySession.PlayerShip.Activate(false, false);
                    MySession.PlayerShip.MarkForClose();
                    MySession.PlayerShip = null;
                }
            }

            MySession.Static.Player.RestoreHealth();

            // To proper respawn
            shipBuilder.ShipHealthRatio = MathHelper.Clamp(shipBuilder.ShipHealthRatio, 0.2f, 1.0f);
            shipBuilder.Oxygen = MathHelper.Clamp(shipBuilder.Oxygen, 100.0f, float.MaxValue);

            //Debug.Assert(!shipBuilder.EntityId.HasValue);
            var playership = (MySmallShip)MyEntities.CreateFromObjectBuilderAndAdd(MyClientServer.LoggedPlayer.GetDisplayName().ToString(), shipBuilder, respawnPosition);
            playership.AIPriority = oldPriority; // Restore bot priority

            if (IsSandBox())
            {
                if (m_lastConfig != null)
                {
                    playership.Config.Init(m_lastConfig);
                }
            }
            else
            {
                if (MyGuiScreenGamePlay.Static.Checkpoint.PlayerObjectBuilder.ShipConfigObjectBuilder != null)
                {
                    playership.Config.Init(MyGuiScreenGamePlay.Static.Checkpoint.PlayerObjectBuilder.ShipConfigObjectBuilder);
                }
            }

            playership.ConfigChanged += m_onConfigChanged;
            playership.OnDie += m_onEntityDie;
            playership.Activate(true);
            MyCockpitGlassDecals.Clear();

            var respawnMsg = new MyEventRespawn();
            respawnMsg.EntityId = playership.EntityId.Value.NumericValue;
            respawnMsg.Position = new MyMwcPositionAndOrientation(playership.WorldMatrix);
            respawnMsg.Inventory = GetInventory(playership, true);
            respawnMsg.ShipType = playership.ShipType;
            respawnMsg.Faction = playership.Faction;

            float ratio = (IsStory() && StoredShip != null) ? 0.2f : 1.0f;
            playership.ArmorHealth = MathHelper.Clamp(playership.ArmorHealth, playership.MaxArmorHealth * ratio, playership.MaxArmorHealth);
            playership.Fuel = MathHelper.Clamp(playership.Fuel, playership.MaxFuel * ratio, playership.MaxFuel);
            playership.HealthRatio = MathHelper.Clamp(playership.HealthRatio, ratio, 1.0f);
            playership.Oxygen = MathHelper.Clamp(playership.Oxygen, playership.MaxOxygen * ratio, playership.MaxOxygen);

            MySession.Static.Player.RestoreHealth();
            playership.PilotHealth = MySession.Static.Player.MaxHealth;

            if (MyMultiplayerGameplay.IsSandBox())
            {
                MakeInventoryItemsNontradeable(playership);
            }

            if (m_lastAmmoAssignment != null)
            {
                playership.Weapons.AmmoAssignments.Init(m_lastAmmoAssignment);
            }

            // As last to prevent many changes when doing something
            playership.InventoryChanged += m_onInventoryChanged;

            LogDevelop("RESPAWN end");
            Peers.SendToAll(ref respawnMsg, NetDeliveryMethod.ReliableOrdered);
        }
        private void OnEditBot(MyMwcObjectBuilder_SmallShip bldr)
        {
            BotTemplate newTemplate = new BotTemplate();
            MyMwcObjectBuilder_SmallShip_Bot botBuilder = bldr as MyMwcObjectBuilder_SmallShip_Bot;
            System.Diagnostics.Debug.Assert(botBuilder != null);

            newTemplate.m_builder = new MyMwcObjectBuilder_SmallShip_Bot(
                bldr.ShipType,
                bldr.Inventory,
                bldr.Weapons,
                bldr.Engine,
                bldr.AssignmentOfAmmo,
                bldr.Armor,
                bldr.Radar,
                bldr.ShipMaxHealth,
                bldr.ShipHealthRatio,
                bldr.ArmorHealth,
                bldr.Oxygen,
                bldr.Fuel,
                bldr.ReflectorLight,
                bldr.ReflectorLongRange,
                bldr.Faction,
                botBuilder != null ? botBuilder.AITemplate : MyAITemplateEnum.DEFAULT,
                botBuilder != null ? botBuilder.Aggressivity : 0,
                botBuilder != null ? botBuilder.SeeDistance : 1000,
                botBuilder != null ? botBuilder.SleepDistance : 1000,
                MyPatrolMode.CYCLE,
                null,
                BotBehaviorType.IDLE,
                MyLightsConstants.MAX_SPOTLIGHT_SHADOW_RANGE, bldr.AIPriority, false, true); // faction will be assigned after spawnpoint genertation
            newTemplate.m_name = bldr.ShipType.ToString();
            int key = m_selectShipsListbox.GetSelectedItem().Key;
            m_selectShipsListbox.RemoveItem(key);

            var itemName = MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip, (int)newTemplate.m_builder.ShipType).Description;
            m_selectShipsListbox.AddItem(key, itemName);

            m_bots[key] = newTemplate;
        }
 public MySmallShipBuilderWithName(MyMwcObjectBuilder_SmallShip builder)
     : this(builder, null)
 {
 }
        private MySmallShipInventoryItemIDs GetInventoryItemIDsFromObjectBuilder(MyMwcObjectBuilder_SmallShip smallShipBuilder) 
        {
            MySmallShipInventoryItemIDs shipInventoryItemsIDs = new MySmallShipInventoryItemIDs();

            // inventory items
            if (smallShipBuilder.Inventory != null && smallShipBuilder.Inventory.InventoryItems != null)
            {
                foreach (MyMwcObjectBuilder_InventoryItem inventoryItem in smallShipBuilder.Inventory.InventoryItems)
                {
                    shipInventoryItemsIDs.Inventory.Add(CreateInventoryItemAddToRepository(inventoryItem, smallShipBuilder.Inventory));
                }
            }

            Debug.Assert(smallShipBuilder.Inventory != null, "smallShipBuilder.Inventory != null");

            // weapons
            if (smallShipBuilder.Weapons != null)
            {
                foreach (MyMwcObjectBuilder_SmallShip_Weapon weapon in smallShipBuilder.Weapons)
                {
                    if (weapon.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Crusher ||
                        weapon.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Laser ||
                        weapon.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Nuclear ||
                        weapon.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Pressure ||
                        weapon.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Saw ||
                        weapon.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Thermal)
                    {
                        shipInventoryItemsIDs.Drill = CreateInventoryItemAddToRepository(weapon, smallShipBuilder.Inventory);
                    }
                    else if (weapon.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Harvesting_Device)
                    {
                        shipInventoryItemsIDs.Harvester = CreateInventoryItemAddToRepository(weapon, smallShipBuilder.Inventory);
                    }
                    else if (weapon.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Universal_Launcher_Front)
                    {
                        shipInventoryItemsIDs.FrontLauncher = CreateInventoryItemAddToRepository(weapon, smallShipBuilder.Inventory);
                    }
                    else if (weapon.WeaponType == MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Universal_Launcher_Back)
                    {
                        shipInventoryItemsIDs.BackLauncher = CreateInventoryItemAddToRepository(weapon, smallShipBuilder.Inventory);
                    }
                    else
                    {
                        int maxLeftWeapons = MyShipTypeConstants.GetShipTypeProperties(smallShipBuilder.ShipType).GamePlay.MaxLeftWeapons;
                        int maxRightWeapons = MyShipTypeConstants.GetShipTypeProperties(smallShipBuilder.ShipType).GamePlay.MaxRightWeapons;

                        // first, try to fit left-mounted weapon in left slots
                        if (weapon.AutoMountLeft && shipInventoryItemsIDs.LeftWeapons.Count < maxLeftWeapons)
                        {
                            shipInventoryItemsIDs.LeftWeapons.Add(CreateInventoryItemAddToRepository(weapon, smallShipBuilder.Inventory));
                            continue;
                        }

                        // or right-mounted weapon in right
                        if (weapon.AutoMountRight && shipInventoryItemsIDs.RightWeapons.Count < maxRightWeapons)
                        {
                            shipInventoryItemsIDs.RightWeapons.Add(CreateInventoryItemAddToRepository(weapon, smallShipBuilder.Inventory));
                            continue;
                        }

                        // then, auto-mounted weapon in left slots
                        if (weapon.AutoMount && shipInventoryItemsIDs.LeftWeapons.Count < maxLeftWeapons)
                        {
                            shipInventoryItemsIDs.LeftWeapons.Add(CreateInventoryItemAddToRepository(weapon, smallShipBuilder.Inventory));
                            continue;
                        }

                        // then, auto-mounted weapon in right slots
                        if (weapon.AutoMount && shipInventoryItemsIDs.RightWeapons.Count < maxRightWeapons)
                        {
                            shipInventoryItemsIDs.RightWeapons.Add(CreateInventoryItemAddToRepository(weapon, smallShipBuilder.Inventory));
                            continue;
                        }

                        // put it in inventory if it doesn't fit anywhere else
                        if (shipInventoryItemsIDs.Inventory.Count < smallShipBuilder.Inventory.MaxItems)
                        {
                            shipInventoryItemsIDs.Inventory.Add(CreateInventoryItemAddToRepository(weapon, smallShipBuilder.Inventory));
                            continue;
                        }
                    }
                }
            }

            // armor
            if (smallShipBuilder.Armor != null)
            {
                shipInventoryItemsIDs.Armor = CreateInventoryItemAddToRepository(smallShipBuilder.Armor, smallShipBuilder.Inventory);
            }

            // engine
            if (smallShipBuilder.Engine != null)
            {
                shipInventoryItemsIDs.Engine = CreateInventoryItemAddToRepository(smallShipBuilder.Engine, smallShipBuilder.Inventory);
            }

            // radar
            if (smallShipBuilder.Radar != null)
            {
                shipInventoryItemsIDs.Radar = CreateInventoryItemAddToRepository(smallShipBuilder.Radar, smallShipBuilder.Inventory);
            }

            return shipInventoryItemsIDs;
        }
        internal override bool Read(BinaryReader binaryReader, EndPoint senderEndPoint, int gameVersion)
        {
            if (!base.Read(binaryReader, senderEndPoint, gameVersion)) return NetworkError();

            //  ID
            int? id = MyMwcMessageIn.ReadInt32Ex(binaryReader, senderEndPoint);
            if (id == null) return NetworkError();
            ID = id.Value;
            MyMwcLog.IfNetVerbose_AddToLog("ID: " + ID);

            //  Name
            bool? hasName = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (!hasName.HasValue) return NetworkError();
            if (hasName.Value)
            {
                string name = MyMwcMessageIn.ReadStringEx(binaryReader, senderEndPoint);
                if (name == null) return NetworkError();
                MyMwcLog.IfNetVerbose_AddToLog("Name: " + Name);
                Name = name;
            }
            else
            {
                MyMwcLog.IfNetVerbose_AddToLog("Name: " + "null");
                Name = null;
            }

            //  Builder
            bool? hasBuilder = MyMwcMessageIn.ReadBoolEx(binaryReader, senderEndPoint);
            if (hasBuilder == null) return NetworkError();
            if (hasBuilder.Value)
            {
                Builder = MyMwcObjectBuilder_Base.ReadAndCreateNewObject(binaryReader, senderEndPoint) as MyMwcObjectBuilder_SmallShip;
                if (Builder == null) return NetworkError();
                if (Builder.Read(binaryReader, senderEndPoint, gameVersion) == false) return NetworkError();
            }
            else
            {
                Builder = null;
            }

            return true;
        }
 public MySmallShipBuilderWithName(StringBuilder name, MyMwcObjectBuilder_SmallShip builder, object userData)
 {
     Name = name;
     Builder = builder;
     UserData = userData;
 }
 public MyMwcObjectBuilder_SmallShip_Bot(MyMwcObjectBuilder_SmallShip smallShip)
     : this(smallShip, MyAITemplateEnum.DEFAULT, 0, 1000, 1000, MyPatrolMode.CYCLE, null, null, BotBehaviorType.IDLE, smallShip.AIPriority, false, true)
 { 
 }
 public MySmallShipBuilderWithName(MyMwcObjectBuilder_SmallShip builder, object userData)
     : this(((MyGuiSmallShipHelperSmallShip)MyGuiObjectBuilderHelpers.GetGuiHelper(MyMwcObjectBuilderTypeEnum.SmallShip, (int)builder.ShipType)).Name, builder, userData)
 {
 }
 public MyMwcObjectBuilder_SmallShipTemplate(int id, string name, MyMwcObjectBuilder_SmallShip builder) 
 {
     ID = id;
     Name = name;
     Builder = builder;
 }