public override void Init(StringBuilder displayName, Models.MyModelsEnum? modelLod0Enum, Models.MyModelsEnum? modelLod1Enum, MyEntity parentObject, float? scale, CommonLIB.AppCode.ObjectBuilders.MyMwcObjectBuilder_Base objectBuilder, Models.MyModelsEnum? modelCollision = null, Models.MyModelsEnum? modelLod2Enum = null)
        {
            // Some fake builder
            var builder = new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Drilling_Device_Crusher);

            base.Init(displayName, modelLod0Enum, modelLod1Enum, parentObject, scale, builder, modelCollision, modelLod2Enum);
            SetModel(MyModelsEnum.MysteriousBox_matt_5m);
        }
 public virtual void Init(StringBuilder hudLabelText, MySmallShip parentObject,
     Vector3 position, Vector3 forwardVector, Vector3 upVector,
     MyMwcObjectBuilder_SmallShip_Weapon objectBuilder)
 {
     WeaponType = objectBuilder.WeaponType;
     //  Don't need to check frustum, because it's checked by this gun's parent
     m_frustumCheckBeforeDrawEnabled = false;
 }
Exemple #3
0
 protected override MyMwcObjectBuilder_Base GetObjectBuilderInternal(bool getExactCopy)
 {
     MyMwcObjectBuilder_Base objectBuilder = base.GetObjectBuilderInternal(getExactCopy);
     if (objectBuilder == null)
     {                
         objectBuilder = new MyMwcObjectBuilder_SmallShip_Weapon(MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum.Cannon);                
     }
     return objectBuilder;
 }
Exemple #4
0
        public override void Init(StringBuilder hudLabelText, MySmallShip parentObject,
            Vector3 position, Vector3 forwardVector, Vector3 upVector,
            MyMwcObjectBuilder_SmallShip_Weapon objectBuilder)
        {
            base.Init(hudLabelText, MyModelsEnum.MissileLauncher, MyMaterialType.METAL, parentObject,
                position, forwardVector, upVector, objectBuilder);

            m_lastTimeShoot = MyConstants.FAREST_TIME_IN_PAST;
        }
        public override void Init(StringBuilder hudLabelText, MySmallShip parentObject,
            Vector3 position, Vector3 forwardVector, Vector3 upVector,
            MyMwcObjectBuilder_SmallShip_Weapon objectBuilder)
        {
            base.Init(hudLabelText, parentObject,
                      position, forwardVector, upVector,
                      objectBuilder);

            m_rotatingSpeed = 0;
            m_ejectedDistance = 0;
        }
        /// <summary>
        /// Inits weapon and mount to this slot
        /// </summary>
        /// <param name="weapon">Weapon</param>
        /// <param name="objectBuilder">Weapon's objectbuilder</param>
        /// <param name="parentShip">Parent ship</param>
        public void InitAndMount(MySmallShipGunBase weapon, MyMwcObjectBuilder_SmallShip_Weapon objectBuilder, MySmallShip parentShip)
        {
            Debug.Assert(WeaponSubObject != null);
            weapon.Init(null, parentShip, GetPosition(), GetForwardVector(), GetUpVector(), objectBuilder);
            float? yOffset = GetOffsetFromWeaponSubObject(SUB_OBJECT_Y_OFFSET_KEY);
            if (yOffset != null)
            {
                weapon.YOffset = yOffset.Value;
            }

            float? zOffset = GetOffsetFromWeaponSubObject(SUB_OBJECT_Z_OFFSET_KEY);
            if (zOffset != null)
            {
                weapon.ZOffset = zOffset.Value;
            }
            Mount(weapon);
        }
        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;
        }