コード例 #1
0
        static void PreallocateObjects()
        {
            if (m_objectPool == null)
            {
                m_objectPool = new MyObjectsPool <MyExplosionDebrisModel>(MyExplosionsConstants.MAX_EXPLOSION_DEBRIS_OBJECTS);
            }
            m_objectPool.DeallocateAll();

            List <MyRBElementDesc> collisionPrimitives = new List <MyRBElementDesc>();

            MyPhysicsObjects      physobj    = MyPhysics.physicsSystem.GetPhysicsObjects();
            MyRBSphereElementDesc sphereDesc = physobj.GetRBSphereElementDesc();

            sphereDesc.SetToDefault();
            sphereDesc.m_RBMaterial = MyMaterialsConstants.GetMaterialProperties(MODEL_DEBRIS_MATERIAL_TYPE).PhysicsMaterial;

            collisionPrimitives.Add(sphereDesc);

            int counter = 0;

            foreach (var item in m_objectPool.GetPreallocatedItemsArray())
            {
                MyModelsEnum   modelEnum      = (MyModelsEnum)((int)MyModelsEnum.Debris1 + counter % 31);
                MyModel        model          = MyModels.GetModelOnlyData(modelEnum);
                BoundingSphere boundingSphere = model.BoundingSphere;

                sphereDesc.m_Radius             = boundingSphere.Radius;
                sphereDesc.m_Matrix.Translation = boundingSphere.Center;

                item.Value.Init(collisionPrimitives, modelEnum);
                counter++;
            }
        }
コード例 #2
0
 public MyPrefabConfigurationAlarm(MyModelsEnum modelLod0Enum, MyModelsEnum? modelLod1Enum, MyModelsEnum modelLod0EnumOn, MyModelsEnum? modelLod1EnumOn, BuildTypesEnum buildType, CategoryTypesEnum categoryType,
     SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType, PrefabTypesFlagEnum prefabTypeFlag)
     : base(modelLod0Enum, modelLod1Enum, buildType, categoryType, subCategoryType, materialType, prefabTypeFlag, needsUpdate: true, requiresEnergy: false)
 {
     ModelLod0EnumOn = modelLod0EnumOn;
     ModelLod1EnumOn = modelLod1EnumOn;
 }    
コード例 #3
0
        public void Init(StringBuilder hudLabelText, MyModelsEnum? modelLod0Enum, MyModelsEnum? modelLod1Enum,
            Matrix localMatrix, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammoType, MyLargeShipGunBase parentObject)
        {
            base.Init(hudLabelText, modelLod0Enum, modelLod1Enum, parentObject, null, null);

            LocalMatrix = localMatrix;
            ((MyLargeShipGunBase)parentObject).InitializationBarrelMatrix = LocalMatrix;

            // Check for the dummy cubes for the muzzle flash positions:
            if (ModelLod0 != null)
            {
                // test for one value:
                StringBuilder sb = new StringBuilder();
                sb.Append(MyLargeShipWeaponsConstants.MUZZLE_FLASH_NAME_ONE);
                if (ModelLod0.Dummies.Count > 0)
                {
                    if (ModelLod0.Dummies.ContainsKey(sb.ToString()))
                    { // one muzzle flash value:
                        m_muzzleDummies.Add(ModelLod0.Dummies[sb.ToString()]);
                    }
                    else
                    {
                        // more muzzle flashes values:
                        int num = 0;
                        for (int i = 0; i < ModelLod0.Dummies.Count; ++i)
                        {
                            sb.Clear();
                            sb.Append(MyLargeShipWeaponsConstants.MUZZLE_FLASH_NAME_MODE);
                            sb.Append(i.ToString());

                            if (ModelLod0.Dummies.ContainsKey(sb.ToString()))
                            {
                                ++num;
                            }
                        }
                        for (int i = 0; i < ModelLod0.Dummies.Count; ++i)
                        {
                            sb.Clear();
                            sb.Append(MyLargeShipWeaponsConstants.MUZZLE_FLASH_NAME_MODE);
                            sb.Append(i.ToString());
                            if (ModelLod0.Dummies.ContainsKey(sb.ToString()))
                            {
                                m_muzzleDummies.Add(ModelLod0.Dummies[sb.ToString()]);
                            }
                        }
                    }
                }
            }

            //base.InitSpherePhysics(MyMaterialType.METAL, ModelLod0, 9999999.0f, 1.0f, MyConstants.COLLISION_LAYER_ALL, RigidBodyFlag.RBF_RBO_STATIC);
            if (this.Physics != null)
            {
                //this.Physics.Enabled = true;
                this.Physics.Update();
            }

            m_ammoType = ammoType;                        
            Save = false;
            //NeedsUpdate = true; //No, barrel is updated from parent
        }
コード例 #4
0
 public MyPrefabConfigurationAlarm(MyModelsEnum modelLod0Enum, MyModelsEnum?modelLod1Enum, MyModelsEnum modelLod0EnumOn, MyModelsEnum?modelLod1EnumOn, BuildTypesEnum buildType, CategoryTypesEnum categoryType,
                                   SubCategoryTypesEnum?subCategoryType, MyMaterialType materialType, PrefabTypesFlagEnum prefabTypeFlag)
     : base(modelLod0Enum, modelLod1Enum, buildType, categoryType, subCategoryType, materialType, prefabTypeFlag, needsUpdate: true, requiresEnergy: false)
 {
     ModelLod0EnumOn = modelLod0EnumOn;
     ModelLod1EnumOn = modelLod1EnumOn;
 }
コード例 #5
0
ファイル: MyDrillHead.cs プロジェクト: Bunni/Miner-Wars-2081
 public virtual void Init(Vector3 offset, MyEntity parentObject, MyModelsEnum model)
 {
     base.Init(null, model, null, parentObject, null, null);
     LocalMatrix = Matrix.CreateTranslation(offset);
     RotationSpeed = 0;
     Save = false;
 }
コード例 #6
0
 public MyPrefabConfigurationGenerator(MyModelsEnum modelLod0Enum, MyModelsEnum?modelLod1Enum, BuildTypesEnum buildType, CategoryTypesEnum categoryType,
                                       SubCategoryTypesEnum?subCategoryType, MyMaterialType materialType, float range, float rotatingVelocity = DEFAULT_ROTATING_VELOCITY, MyModelsEnum?modelCol = null,
                                       float explosionParticleEffectScale = 1)
     : this(modelLod0Enum, modelLod1Enum, buildType, categoryType, subCategoryType, materialType, PrefabTypesFlagEnum.Generator, range, rotatingVelocity,
            MySoundCuesEnum.Amb3D_GenXstart, MySoundCuesEnum.Amb3D_GenXloop, MySoundCuesEnum.Amb3D_GenXend, modelCol, explosionParticleEffectScale : explosionParticleEffectScale)
 {
 }
コード例 #7
0
        public static MyModel GetModelOnlyModelInfo(MyModelsEnum modelEnum)
        {
            int modelInt = (int)modelEnum;

            m_models[modelInt].LoadOnlyModelInfo();
            return(m_models[modelInt]);
        }
コード例 #8
0
        public virtual void Init(MyModelsEnum modelEnum, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammoEnum, bool spherePhysics = true)
        {
            base.Init(null, modelEnum, null, null, null, null);

            AmmoType             = ammoEnum;
            m_gameplayProperties = MyGameplayConstants.GetGameplayProperties(MyMwcObjectBuilderTypeEnum.SmallShip_Ammo, (int)ammoEnum, Faction);
            m_ammoProperties     = MyAmmoConstants.GetAmmoProperties(ammoEnum);

            //  Collision skin
            if (spherePhysics)
            {
                InitSpherePhysics(MyMaterialType.AMMO, ModelLod0, m_gameplayProperties.WeightPerUnit,
                                  MyPhysicsConfig.DefaultAngularDamping, MyConstants.COLLISION_LAYER_DEFAULT,
                                  RigidBodyFlag.RBF_DEFAULT);
            }
            else
            {
                InitBoxPhysics(MyMaterialType.AMMO, ModelLod0, m_gameplayProperties.WeightPerUnit,
                               MyPhysicsConfig.DefaultAngularDamping, MyConstants.COLLISION_LAYER_DEFAULT,
                               RigidBodyFlag.RBF_DEFAULT);
            }

            Physics.GetRBElementList()[0].Flags |= MyElementFlag.EF_MODEL_PREFER_LOD0;

            NeedsUpdate = true;
            RenderObjects[0].SkipIfTooSmall = false;
            CastShadows = false;
            Closed      = true; //Because ammobase instance is going to pool. It is started by Start()

            IsDestructible = true;

            PreloadTextures();
        }
コード例 #9
0
        public static List <MyModelSubObject> GetModelSubObjects(MyModelsEnum modelEnum)
        {
            List <MyModelSubObject> subObjectList;

            m_subObjectsMap.TryGetValue((int)modelEnum, out subObjectList);
            return(subObjectList);
        }
コード例 #10
0
ファイル: MyAmmoBase.cs プロジェクト: Bunni/Miner-Wars-2081
        public virtual void Init(MyModelsEnum modelEnum, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammoEnum, bool spherePhysics = true)
        {
            base.Init(null, modelEnum, null, null, null, null);

            AmmoType = ammoEnum;
            m_gameplayProperties = MyGameplayConstants.GetGameplayProperties(MyMwcObjectBuilderTypeEnum.SmallShip_Ammo, (int)ammoEnum, Faction);
            m_ammoProperties = MyAmmoConstants.GetAmmoProperties(ammoEnum);

            //  Collision skin
            if (spherePhysics)
            {
                InitSpherePhysics(MyMaterialType.AMMO, ModelLod0, m_gameplayProperties.WeightPerUnit,
                                  MyPhysicsConfig.DefaultAngularDamping, MyConstants.COLLISION_LAYER_DEFAULT,
                                  RigidBodyFlag.RBF_DEFAULT);
            }
            else
            {
                InitBoxPhysics(MyMaterialType.AMMO, ModelLod0, m_gameplayProperties.WeightPerUnit,
                               MyPhysicsConfig.DefaultAngularDamping, MyConstants.COLLISION_LAYER_DEFAULT,
                               RigidBodyFlag.RBF_DEFAULT);
            }

            Physics.GetRBElementList()[0].Flags |= MyElementFlag.EF_MODEL_PREFER_LOD0;

            NeedsUpdate = true;
            RenderObjects[0].SkipIfTooSmall = false;
            CastShadows = false;
            Closed = true; //Because ammobase instance is going to pool. It is started by Start()

            IsDestructible = true;

            PreloadTextures();
        }
コード例 #11
0
 public virtual void Init(Vector3 offset, MyEntity parentObject, MyModelsEnum model)
 {
     base.Init(null, model, null, parentObject, null, null);
     LocalMatrix   = Matrix.CreateTranslation(offset);
     RotationSpeed = 0;
     Save          = false;
 }
コード例 #12
0
ファイル: MyShip.cs プロジェクト: Bunni/Miner-Wars-2081
        /// <summary>
        /// Inits the specified hud label text.
        /// </summary>
        /// <param name="hudLabelText">The hud label text.</param>
        /// <param name="modelLod0Enum">The model lod0 enum.</param>
        /// <param name="modelLod1Enum">The model lod1 enum.</param>
        /// <param name="parentObject">The parent object.</param>
        /// <param name="scale">The scale.</param>
        /// <param name="objectBuilder">The object builder.</param>
        public override void Init(StringBuilder hudLabelText, MyModelsEnum? modelLod0Enum, MyModelsEnum? modelLod1Enum, MyEntity parentObject, float? scale, MyMwcObjectBuilder_Base objectBuilder, MyModelsEnum? modelCollision = null, Models.MyModelsEnum? modelLod2 = null)
        {
            Flags |= EntityFlags.EditableInEditor;
            NeedsUpdate = true;

            base.Init(hudLabelText, modelLod0Enum, modelLod1Enum, null, scale, objectBuilder, modelCollision, modelLod2);
        }
コード例 #13
0
        public void Init(MyPrefabBase kinematicPartOwner, MyMwcObjectBuilderTypeEnum prefabKinematicPartBuilderType, int? prefabKinematicPartBuilderId, MyModelsEnum modelEnum, MyMaterialType materialType, Matrix kinematicLocalMatrix, float kinematicVelocityMax, MySoundCuesEnum? loopSound, MySoundCuesEnum? loopDamagedSound, MySoundCuesEnum? startSound, MySoundCuesEnum? endSound, float kinematicStart, float kinematicEnd) 
        {
            m_needsUpdate = true;
            m_kinematicPartOwner = kinematicPartOwner;                        
            m_kinematicLocalMatrix = kinematicLocalMatrix;
            m_kinematicVelocityMax = kinematicVelocityMax;            
            m_kinematicStart = kinematicStart;
            m_kinematicEnd = kinematicEnd;

            m_loopSoundCue = loopSound;
            m_loopDamagedSoundCue = loopDamagedSound;
            m_startSoundCue = startSound;
            m_endSoundCue = endSound;

            MyMwcObjectBuilder_Base objbuilder = MyMwcObjectBuilder_Base.CreateNewObject(prefabKinematicPartBuilderType, prefabKinematicPartBuilderId);

            m_config = m_kinematicPartOwner.GetConfiguration();
            base.Init(null, modelEnum, null, kinematicPartOwner, null, objbuilder);            
            LocalMatrix = Matrix.Identity;

            MaterialIndex = m_kinematicPartOwner.MaterialIndex;

            
            //InitTrianglePhysics(materialType, 1.0f, ModelLod0, null, MyConstants.COLLISION_LAYER_PREFAB_KINEMATIC_PART);
            InitBoxPhysics(materialType, ModelLod0, 100, 0, MyConstants.COLLISION_LAYER_PREFAB_KINEMATIC_PART, RigidBodyFlag.RBF_RBO_STATIC);
            Physics.Enabled = true;
            
            m_kinematicPartOwner.OnPositionChanged += OwnerPositionChanged;
        }
コード例 #14
0
 public virtual void Init(StringBuilder hudLabelText, Matrix localMatrix, Vector3 offset, float rotateSpeed, MyCrusherDrill parentObject, MyModelsEnum model)
 {
     base.Init(hudLabelText, model, null, parentObject, null, null);
     m_rotateSpeed = rotateSpeed;
     this.LocalMatrix = Matrix.CreateTranslation(offset) * localMatrix;
     Save = false;
 }
コード例 #15
0
 public MyPrefabConfigurationKinematicRotating(MyModelsEnum modelBaseLod0Enum, MyModelsEnum?modelBaseLod1Enum,
                                               MySoundCuesEnum?soundOpening, MySoundCuesEnum?soundLooping,
                                               MySoundCuesEnum?soundClosing, float rotatingVelocity, BuildTypesEnum buildType, CategoryTypesEnum categoryType,
                                               SubCategoryTypesEnum?subCategoryType, MyMaterialType materialType)
     : this(modelBaseLod0Enum, modelBaseLod1Enum, soundOpening, soundLooping, soundClosing, rotatingVelocity,
            buildType, categoryType, subCategoryType, materialType, PrefabTypesFlagEnum.Default)
 {
 }
コード例 #16
0
 public MyPrefabConfigurationKinematic(MyModelsEnum modelBaseLod0Enum, MyModelsEnum?modelBaseLod1Enum,
                                       List <MyPrefabConfigurationKinematicPart> kinematicParts, MySoundCuesEnum?soundOpening, MySoundCuesEnum?soundLooping,
                                       MySoundCuesEnum?soundClosing, float openTime, float closeTime, BuildTypesEnum buildType, CategoryTypesEnum categoryType,
                                       SubCategoryTypesEnum?subCategoryType, MyMaterialType materialType, MyModelsEnum?collisionModelEnum = null)
     : this(modelBaseLod0Enum, modelBaseLod1Enum, kinematicParts, soundOpening, soundLooping, soundClosing, openTime, closeTime,
            buildType, categoryType, subCategoryType, materialType, PrefabTypesFlagEnum.Default, collisionModelEnum)
 {
 }
コード例 #17
0
 public MyPrefabConfigurationKinematicRotating(MyModelsEnum modelBaseLod0Enum, MyModelsEnum? modelBaseLod1Enum,
         MySoundCuesEnum? soundOpening, MySoundCuesEnum? soundLooping, 
         MySoundCuesEnum? soundClosing, float rotatingVelocity, BuildTypesEnum buildType, CategoryTypesEnum categoryType,
         SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType)
     : this(modelBaseLod0Enum, modelBaseLod1Enum, soundOpening, soundLooping, soundClosing, rotatingVelocity, 
            buildType, categoryType, subCategoryType, materialType, PrefabTypesFlagEnum.Default)
 {
 }    
コード例 #18
0
 public MyPrefabConfigurationKinematic(MyModelsEnum modelBaseLod0Enum, MyModelsEnum? modelBaseLod1Enum,
         List<MyPrefabConfigurationKinematicPart> kinematicParts, MySoundCuesEnum? soundOpening, MySoundCuesEnum? soundLooping, 
         MySoundCuesEnum? soundClosing, float openTime, float closeTime, BuildTypesEnum buildType, CategoryTypesEnum categoryType,
         SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType, MyModelsEnum? collisionModelEnum = null)
     : this(modelBaseLod0Enum, modelBaseLod1Enum, kinematicParts, soundOpening, soundLooping, soundClosing, openTime, closeTime,
            buildType, categoryType, subCategoryType, materialType, PrefabTypesFlagEnum.Default, collisionModelEnum)
 {
 }
コード例 #19
0
        public MyPrefabConfigurationGenerator(MyModelsEnum modelLod0Enum, MyModelsEnum? modelLod1Enum, BuildTypesEnum buildType, CategoryTypesEnum categoryType,
            SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType, float range, float rotatingVelocity = DEFAULT_ROTATING_VELOCITY, MyModelsEnum? modelCol = null,
            float explosionParticleEffectScale = 1)
            : this(modelLod0Enum, modelLod1Enum, buildType, categoryType, subCategoryType, materialType, PrefabTypesFlagEnum.Generator, range, rotatingVelocity,
            MySoundCuesEnum.Amb3D_GenXstart, MySoundCuesEnum.Amb3D_GenXloop, MySoundCuesEnum.Amb3D_GenXend, modelCol, explosionParticleEffectScale:explosionParticleEffectScale)
        {

        }
コード例 #20
0
ファイル: MyMeteorWind.cs プロジェクト: Bunni/Miner-Wars-2081
        private static void PreloadModel(MyModelsEnum? myModelsEnum)
        {
            if (myModelsEnum == null)
                return;

            MyModel model = MyModels.GetModelOnlyData(myModelsEnum.Value);
            model.LoadInDraw();
            model.PreloadTextures(Managers.LoadingMode.Immediate);
        }
コード例 #21
0
 public MyPrefabConfigurationGenerator(MyModelsEnum modelLod0Enum, MyModelsEnum?modelLod1Enum, BuildTypesEnum buildType, CategoryTypesEnum categoryType,
                                       SubCategoryTypesEnum?subCategoryType, MyMaterialType materialType, PrefabTypesFlagEnum prefabTypeFlag, float range, float rotatingVelocity = DEFAULT_ROTATING_VELOCITY,
                                       MySoundCuesEnum?startRotatingCue   = MySoundCuesEnum.Amb3D_GenXstart, MySoundCuesEnum?looptRotatingCue = MySoundCuesEnum.Amb3D_GenXloop, MySoundCuesEnum?endRotatingCue = MySoundCuesEnum.Amb3D_GenXend, MyModelsEnum?modelCol = null,
                                       float explosionParticleEffectScale = 1)
     : base(modelLod0Enum, modelLod1Enum, buildType, categoryType, subCategoryType, materialType, prefabTypeFlag, minElectricCapacity : MyGameplayConstants.DEFAULT_MAX_ELECTRIC_CAPACITY, rotatingVelocity : rotatingVelocity, collisionModelEnum : modelCol,
            startRotatingCue : startRotatingCue, loopRotatingCue : looptRotatingCue, endRotatingCue : endRotatingCue, displayHud : true, explosionParticleEffectScale : explosionParticleEffectScale)
 {
     Range = range;
 }
コード例 #22
0
 public MyPrefabConfigurationGenerator(MyModelsEnum modelLod0Enum, MyModelsEnum? modelLod1Enum, BuildTypesEnum buildType, CategoryTypesEnum categoryType,
     SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType, PrefabTypesFlagEnum prefabTypeFlag, float range, float rotatingVelocity = DEFAULT_ROTATING_VELOCITY,
     MySoundCuesEnum? startRotatingCue = MySoundCuesEnum.Amb3D_GenXstart, MySoundCuesEnum? looptRotatingCue = MySoundCuesEnum.Amb3D_GenXloop, MySoundCuesEnum? endRotatingCue = MySoundCuesEnum.Amb3D_GenXend, MyModelsEnum? modelCol = null,
     float explosionParticleEffectScale = 1)
     : base(modelLod0Enum, modelLod1Enum, buildType, categoryType, subCategoryType, materialType, prefabTypeFlag, minElectricCapacity: MyGameplayConstants.DEFAULT_MAX_ELECTRIC_CAPACITY, rotatingVelocity: rotatingVelocity, collisionModelEnum: modelCol,
     startRotatingCue: startRotatingCue, loopRotatingCue: looptRotatingCue, endRotatingCue: endRotatingCue, displayHud: true, explosionParticleEffectScale:explosionParticleEffectScale)
 {
     Range = range;
 }
コード例 #23
0
        void InitDebris(string hudLabelText, MyModelsEnum modelLod0Enum, MyModelsEnum? modelLod1Enum, MyMaterialType materialType, MyMwcObjectBuilder_LargeDebrisField objectBuilder, Matrix matrix)
        {
            StringBuilder hudLabelTextSb = (hudLabelText == null) ? null : new StringBuilder(hudLabelText);
            base.Init(hudLabelTextSb, modelLod0Enum, modelLod1Enum, null, null, objectBuilder);

            MyModel model = MyModels.GetModelOnlyData(modelLod0Enum);

            InitTrianglePhysics(materialType, 1.0f, model, null, enable: false);
			SetWorldMatrix(matrix);            
        }
コード例 #24
0
        void InitDebris(string hudLabelText, MyModelsEnum modelLod0Enum, MyModelsEnum?modelLod1Enum, MyMaterialType materialType, MyMwcObjectBuilder_LargeDebrisField objectBuilder, Matrix matrix)
        {
            StringBuilder hudLabelTextSb = (hudLabelText == null) ? null : new StringBuilder(hudLabelText);

            base.Init(hudLabelTextSb, modelLod0Enum, modelLod1Enum, null, null, objectBuilder);

            MyModel model = MyModels.GetModelOnlyData(modelLod0Enum);

            InitTrianglePhysics(materialType, 1.0f, model, null, enable: false);
            SetWorldMatrix(matrix);
        }
コード例 #25
0
 public MyPrefabConfigurationKinematicRotating(MyModelsEnum modelBaseLod0Enum, MyModelsEnum?modelBaseLod1Enum,
                                               MySoundCuesEnum?soundOpening, MySoundCuesEnum?soundLooping,
                                               MySoundCuesEnum?soundClosing, float rotatingVelocity, BuildTypesEnum buildType, CategoryTypesEnum categoryType,
                                               SubCategoryTypesEnum?subCategoryType, MyMaterialType materialType, PrefabTypesFlagEnum prefabTypeFlag)
     : base(modelBaseLod0Enum, modelBaseLod1Enum, buildType, categoryType, subCategoryType, materialType, prefabTypeFlag)
 {
     SoundOpening     = soundOpening;
     SoundLooping     = soundLooping;
     SoundClosing     = soundClosing;
     RotatingVelocity = rotatingVelocity;
 }
コード例 #26
0
        public float ZOffset;       // z-offset from ship's dummy

        public void Init(StringBuilder hudLabelText, MyModelsEnum? modelEnum, MyMaterialType materialType,
            MySmallShip parent, Vector3 position, Vector3 forwardVector, Vector3 upVector,
            MyMwcObjectBuilder_Base objectBuilder)
        {
            base.Init(hudLabelText, modelEnum, materialType, parent, position, forwardVector, upVector, objectBuilder);

            Debug.Assert(objectBuilder is MyMwcObjectBuilder_SmallShip_Weapon);
            WeaponType = ((MyMwcObjectBuilder_SmallShip_Weapon)objectBuilder).WeaponType;
            //  Don't need to check frustum, because it's checked by this gun's parent
            m_frustumCheckBeforeDrawEnabled = false;
        }
コード例 #27
0
 public MyPrefabConfigurationKinematicRotating(MyModelsEnum modelBaseLod0Enum, MyModelsEnum? modelBaseLod1Enum, 
         MySoundCuesEnum? soundOpening, MySoundCuesEnum? soundLooping, 
         MySoundCuesEnum? soundClosing, float rotatingVelocity, BuildTypesEnum buildType, CategoryTypesEnum categoryType,
         SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType, PrefabTypesFlagEnum prefabTypeFlag)
     : base(modelBaseLod0Enum, modelBaseLod1Enum, buildType, categoryType, subCategoryType, materialType, prefabTypeFlag)
 {
     SoundOpening = soundOpening;
     SoundLooping = soundLooping;
     SoundClosing = soundClosing;
     RotatingVelocity = rotatingVelocity;
 }
コード例 #28
0
ファイル: MyGunBase.cs プロジェクト: Bunni/Miner-Wars-2081
        public virtual void Init(StringBuilder hudLabelText, MyModelsEnum? modelEnum, MyMaterialType materialType,
            MyEntity parentObject, Vector3 position, Vector3 forwardVector, Vector3 upVector,
            MyMwcObjectBuilder_Base objectBuilder, MyModelsEnum? collisionModelEnum = null)            
        {
            base.Init(hudLabelText, modelEnum, null, parentObject, null, objectBuilder, modelCollision: collisionModelEnum);
            this.LocalMatrix = Matrix.CreateWorld(position, forwardVector, upVector);
            //NeedsUpdate = true; //Smallship updates weapons manually
            CastShadows = false;

            PreloadTextures();
        }
コード例 #29
0
        public static MyModelSubObject GetModelSubObject(MyModelsEnum modelEnum, string subObjectName)
        {
            List <MyModelSubObject> subObjectList;

            m_subObjectsMap.TryGetValue((int)modelEnum, out subObjectList);
            if (subObjectList == null)
            {
                return(null);
            }

            return(subObjectList.Find(x => x.Name == subObjectName));
        }
コード例 #30
0
        public virtual void Init(List <MyRBElementDesc> collisionPrimitives, MyModelsEnum modelEnum)
        {
            float randomSize = MyMwcUtils.GetRandomFloat(0, 1);
            float mass       = MathHelper.Lerp(2500, 5000, randomSize); //  The mass can't be too low, because then debris objects are too fast. This values aren't real, but works.

            base.Init(modelEnum, null, MODEL_DEBRIS_MATERIAL_TYPE, 1.0f, collisionPrimitives, mass);
            Physics.MaxLinearVelocity = 200.0f;

            Physics.CollisionLayer = MyConstants.COLLISION_LAYER_MODEL_DEBRIS;

            MyModels.OnContentLoaded += InitDrawTechniques;
        }
コード例 #31
0
 public MyPrefabConfigurationKinematicPart(int prefabId, MyModelsEnum modelMovingEnum, string open, string close, BuildTypesEnum buildType,
                                           CategoryTypesEnum categoryType, SubCategoryTypesEnum?subCategoryType, MyMaterialType materialType, DamageTypesEnum damageType, MyModelsEnum?modelLod1 = null, MyModelsEnum?collisionModelEnum = null)
     : base(modelMovingEnum, modelLod1, buildType, categoryType, subCategoryType, materialType,
            //0.5 because of door parts, to not take also second part
            PrefabTypesFlagEnum.Default, needsUpdate: true, explosionRadiusMultiplier: 0.5f, explosionDamage: 0.33f, collisionModelEnum: collisionModelEnum, explosionParticleEffectScale: 2.0f)
 {
     m_modelMovingEnum = modelMovingEnum;
     m_open            = open;
     m_close           = close;
     m_damageType      = damageType;
     PrefabId          = prefabId;
 }
コード例 #32
0
 public MyPrefabConfigurationKinematicPart(int prefabId, MyModelsEnum modelMovingEnum, string open, string close, BuildTypesEnum buildType,
     CategoryTypesEnum categoryType, SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType, DamageTypesEnum damageType, MyModelsEnum? modelLod1 = null, MyModelsEnum? collisionModelEnum = null)
     : base(modelMovingEnum, modelLod1, buildType, categoryType, subCategoryType, materialType,
                                                            //0.5 because of door parts, to not take also second part
            PrefabTypesFlagEnum.Default, needsUpdate: true, explosionRadiusMultiplier: 0.5f, explosionDamage: 0.33f, collisionModelEnum: collisionModelEnum, explosionParticleEffectScale: 2.0f)
 {
     m_modelMovingEnum = modelMovingEnum;
     m_open = open;
     m_close = close;
     m_damageType = damageType;
     PrefabId = prefabId;
 }
コード例 #33
0
 public MyPrefabConfigurationKinematic(MyModelsEnum modelBaseLod0Enum, MyModelsEnum? modelBaseLod1Enum, 
         List<MyPrefabConfigurationKinematicPart> kinematicParts, MySoundCuesEnum? soundOpening, MySoundCuesEnum? soundLooping, 
         MySoundCuesEnum? soundClosing, float openTime, float closeTime, BuildTypesEnum buildType, CategoryTypesEnum categoryType,
         SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType, PrefabTypesFlagEnum prefabTypeFlag, MyModelsEnum? collisionModelEnum = null)
     : base(modelBaseLod0Enum, modelBaseLod1Enum, buildType, categoryType, subCategoryType, materialType, prefabTypeFlag, collisionModelEnum: collisionModelEnum, displayHud: true)
 {
     m_openTime = openTime;
     m_closeTime = closeTime;
     KinematicParts = kinematicParts;
     m_soundOpening = soundOpening;
     m_soundLooping = soundLooping;
     m_soundClosing = soundClosing;
 }
コード例 #34
0
 public MyPrefabConfigurationKinematic(MyModelsEnum modelBaseLod0Enum, MyModelsEnum?modelBaseLod1Enum,
                                       List <MyPrefabConfigurationKinematicPart> kinematicParts, MySoundCuesEnum?soundOpening, MySoundCuesEnum?soundLooping,
                                       MySoundCuesEnum?soundClosing, float openTime, float closeTime, BuildTypesEnum buildType, CategoryTypesEnum categoryType,
                                       SubCategoryTypesEnum?subCategoryType, MyMaterialType materialType, PrefabTypesFlagEnum prefabTypeFlag, MyModelsEnum?collisionModelEnum = null)
     : base(modelBaseLod0Enum, modelBaseLod1Enum, buildType, categoryType, subCategoryType, materialType, prefabTypeFlag, collisionModelEnum: collisionModelEnum, displayHud: true)
 {
     m_openTime     = openTime;
     m_closeTime    = closeTime;
     KinematicParts = kinematicParts;
     m_soundOpening = soundOpening;
     m_soundLooping = soundLooping;
     m_soundClosing = soundClosing;
 }
コード例 #35
0
        public override void Init(string displayName, Microsoft.Xna.Framework.Vector3 relativePosition, Microsoft.Xna.Framework.Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
        {
            m_config = prefabConfig;
            MyPrefabConfigurationKinematicRotating config = (MyPrefabConfigurationKinematicRotating)prefabConfig;

            base.Init(displayName, relativePosition, localOrientation, objectBuilder, prefabConfig);
            Physics.RemoveAllElements();

            // create the box
            MyPhysicsObjects            physobj          = MyPhysics.physicsSystem.GetPhysicsObjects();
            MyRBTriangleMeshElementDesc trianglemeshDesc = physobj.GetRBTriangleMeshElementDesc();

            trianglemeshDesc.SetToDefault();
            trianglemeshDesc.m_Model      = ModelLod0;
            trianglemeshDesc.m_RBMaterial = MyMaterialsConstants.GetMaterialProperties(config.MaterialType).PhysicsMaterial;;


            MyRBTriangleMeshElement trEl = (MyRBTriangleMeshElement)physobj.CreateRBElement(trianglemeshDesc);

            this.Physics = new MyPhysicsBody(this, 1.0f, RigidBodyFlag.RBF_RBO_STATIC)
            {
                MaterialType = config.MaterialType
            };
            this.Physics.Enabled        = true;
            this.Physics.CollisionLayer = MyConstants.COLLISION_LAYER_PREFAB_KINEMATIC;
            this.Physics.AddElement(trEl, true);

            MyModel model = MyModels.GetModelOnlyDummies(m_config.ModelLod0Enum);

            foreach (var dummyKVP in model.Dummies)
            {
                if (dummyKVP.Key.StartsWith("Dummy"))
                {
                    MyModelDummy dummy                         = dummyKVP.Value;
                    MyModelsEnum rotatingPartModel             = MyModels.GetModelEnumByAssetName(dummy.CustomData["LINKEDMODEL"].ToString());
                    MyPrefabKinematicRotatingPart rotatingPart = new MyPrefabKinematicRotatingPart(this.GetOwner());
                    rotatingPart.Init(this, rotatingPartModel, config.MaterialType, dummy.Matrix, config.RotatingVelocity, true, config.SoundLooping, config.SoundOpening, config.SoundClosing);
                    m_parts.Add(rotatingPart);
                }
            }

            AppCode.Physics.MyPhysics.physicsSystem.GetRigidBodyModule().EnableCollisionInLayers(MyConstants.COLLISION_LAYER_PREFAB_KINEMATIC, MyConstants.COLLISION_LAYER_MISSILE, true);
            AppCode.Physics.MyPhysics.physicsSystem.GetRigidBodyModule().EnableCollisionInLayers(MyConstants.COLLISION_LAYER_PREFAB_KINEMATIC, MyConstants.COLLISION_LAYER_ALL, true);
            AppCode.Physics.MyPhysics.physicsSystem.GetRigidBodyModule().EnableCollisionInLayers(MyConstants.COLLISION_LAYER_PREFAB_KINEMATIC, MyConstants.COLLISION_LAYER_MODEL_DEBRIS, true);
            AppCode.Physics.MyPhysics.physicsSystem.GetRigidBodyModule().EnableCollisionInLayers(MyConstants.COLLISION_LAYER_PREFAB_KINEMATIC, MyConstants.COLLISION_LAYER_VOXEL_DEBRIS, true);
            AppCode.Physics.MyPhysics.physicsSystem.GetRigidBodyModule().EnableCollisionInLayers(MyConstants.COLLISION_LAYER_PREFAB_KINEMATIC, MyConstants.COLLISION_LAYER_PREFAB_KINEMATIC_PART, false);

            NeedsUpdate = false;
            EnabledChanged();
            //Enabled = true;
        }
コード例 #36
0
 public void Init(MyPrefabBase rotatingOwner, MyModelsEnum modelEnum, MyMaterialType matType, Matrix rotatingLocal, float rotatingVelocityMax, MySoundCuesEnum?loopSound, MySoundCuesEnum?loopDamagedSound, MySoundCuesEnum?startSound, MySoundCuesEnum?endSound, Vector3 rotationVector, bool activated)
 {
     m_rotationVector = rotationVector;
     base.Init(rotatingOwner, MyMwcObjectBuilderTypeEnum.PrefabKinematicRotatingPart, (int)MyMwcObjectBuilder_PrefabKinematicRotatingPart_TypesEnum.DEFAULT,
               modelEnum, matType, rotatingLocal, rotatingVelocityMax, loopSound, loopDamagedSound, startSound, endSound, 1f, 1f);
     if (activated)
     {
         PersistentFlags &= ~MyPersistentEntityFlags.Deactivated;
     }
     else
     {
         PersistentFlags |= MyPersistentEntityFlags.Deactivated;
     }
 }
コード例 #37
0
 public void Init(MyPrefabBase rotatingOwner, MyModelsEnum modelEnum, MyMaterialType matType, Matrix rotatingLocal, float rotatingVelocityMax, MySoundCuesEnum? loopSound, MySoundCuesEnum? loopDamagedSound, MySoundCuesEnum? startSound, MySoundCuesEnum? endSound, Vector3 rotationVector, bool activated) 
 {
     m_rotationVector = rotationVector;
     base.Init(rotatingOwner, MyMwcObjectBuilderTypeEnum.PrefabKinematicRotatingPart, (int)MyMwcObjectBuilder_PrefabKinematicRotatingPart_TypesEnum.DEFAULT,
         modelEnum, matType, rotatingLocal, rotatingVelocityMax, loopSound, loopDamagedSound, startSound, endSound, 1f, 1f);
     if (activated)
     {
         PersistentFlags &= ~MyPersistentEntityFlags.Deactivated;
     }
     else 
     {
         PersistentFlags |= MyPersistentEntityFlags.Deactivated;
     }
 }
コード例 #38
0
        public void Init(StringBuilder hudLabelText, MyModelsEnum modelEnum, int burstFireCount, Matrix localMatrix, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammoType, MyLargeShipGunBase parentObject)
        {
            base.Init(hudLabelText, modelEnum, null, localMatrix, ammoType, parentObject);

            m_burstFireCount = burstFireCount;
            m_burstToFire = m_burstFireCount;
            m_burstFireTime_ms = MyMinerGame.TotalGamePlayTimeInMilliseconds;

            // User settings:            
            m_burstFireTimeLoadingIntervalConst_ms = 2000;

            // This is imoprtant for missile launchers (they are not able to lauchching rackets on safe trajectory)
            //BarrelElevationMin = 0.1571f;
            BarrelElevationMin = -0.6f;
        }
コード例 #39
0
        public void Init(StringBuilder hudLabelText, MyModelsEnum modelEnum, int burstFireCount, Matrix localMatrix, MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum ammoType, MyLargeShipGunBase parentObject)
        {
            base.Init(hudLabelText, modelEnum, null, localMatrix, ammoType, parentObject);

            m_burstFireCount   = burstFireCount;
            m_burstToFire      = m_burstFireCount;
            m_burstFireTime_ms = MyMinerGame.TotalGamePlayTimeInMilliseconds;

            // User settings:
            m_burstFireTimeLoadingIntervalConst_ms = 2000;

            // This is imoprtant for missile launchers (they are not able to lauchching rackets on safe trajectory)
            //BarrelElevationMin = 0.1571f;
            BarrelElevationMin = -0.6f;
        }
コード例 #40
0
        public MyPrefabConfigurationLargeShip(
            MyModelsEnum modelLod0Enum,
            MyModelsEnum? modelLod1Enum,
            BuildTypesEnum buildType,
            CategoryTypesEnum categoryType,
            SubCategoryTypesEnum? subCategoryType,
            MyMaterialType materialType,
            MyMwcObjectBuilder_Prefab_AppearanceEnum? factionSpecific = null,
            MyModelsEnum? collisionModelEnum = null,
            MyExplosionTypeEnum explosionType = MyExplosionTypeEnum.BOMB_EXPLOSION,
            float particleScale = 1)

            : base(modelLod0Enum, modelLod1Enum, buildType, categoryType, subCategoryType, materialType, PrefabTypesFlagEnum.LargeShip, factionSpecific: factionSpecific, needsUpdate: true, collisionModelEnum: collisionModelEnum, explosionType: explosionType, explosionParticleEffectScale: particleScale)
        {
        }
コード例 #41
0
        public MyPrefabConfigurationLargeShip(
            MyModelsEnum modelLod0Enum,
            MyModelsEnum?modelLod1Enum,
            BuildTypesEnum buildType,
            CategoryTypesEnum categoryType,
            SubCategoryTypesEnum?subCategoryType,
            MyMaterialType materialType,
            MyMwcObjectBuilder_Prefab_AppearanceEnum?factionSpecific = null,
            MyModelsEnum?collisionModelEnum   = null,
            MyExplosionTypeEnum explosionType = MyExplosionTypeEnum.BOMB_EXPLOSION,
            float particleScale = 1)

            : base(modelLod0Enum, modelLod1Enum, buildType, categoryType, subCategoryType, materialType, PrefabTypesFlagEnum.LargeShip, factionSpecific: factionSpecific, needsUpdate: true, collisionModelEnum: collisionModelEnum, explosionType: explosionType, explosionParticleEffectScale: particleScale)
        {
        }
コード例 #42
0
        //  Lazy-loading and then returning reference to model
        //  IMPORTANT: Loads data into GPU, should be called only from Draw method on main thread
        //	Special method that loads data into GPU, and can be called only from Draw method, never from LoadContent or from background thread.
        //	Because that would lead to empty vertex/index buffers if they are filled/created while game is minimized (remember the issue - alt-tab during loading screen)
        public static MyModel GetModelForDraw(MyModelsEnum modelEnum)
        {       /*
                 * System.Collections.Generic.List<MyModel> mds = new System.Collections.Generic.List<MyModel>();
                 * foreach (MyModel model in m_models)
                 * {
                 * if (model.Vertexes != null)
                 * mds.Add(model);
                 * }
                 */
            int modelInt = (int)modelEnum;

            m_models[modelInt].LoadData();
            m_models[modelInt].LoadInDraw();
            return(m_models[modelInt]);
        }
コード例 #43
0
        void InitDebris(string hudLabelText, MyModelsEnum modelLod0Enum, MyModelsEnum?modelLod1Enum, MyMaterialType materialType,
                        MyMwcObjectBuilder_SmallDebris objectBuilder, Matrix matrix, float mass)
        {
            StringBuilder hudLabelTextSb = (hudLabelText == null) ? null : new StringBuilder(hudLabelText);

            base.Init(hudLabelTextSb, modelLod0Enum, modelLod1Enum, null, null, objectBuilder);

            if (objectBuilder != null)
            {
                SetWorldMatrix(matrix);
            }

            if (mass > 0)
            {
                base.InitBoxPhysics(materialType, this.ModelLod0, mass, 0, MyConstants.COLLISION_LAYER_DEFAULT, RigidBodyFlag.RBF_DEFAULT);
                this.Physics.PlayCollisionCueEnabled = true;
            }
        }
コード例 #44
0
        /// <summary>
        /// Creates gun's positions from ship's model. If find preferred position, then mark it as preffered.
        /// </summary>
        /// <param name="modelEnum">Ship's model</param>
        /// <param name="maxSlots">Weapons maximum on ship</param>
        /// <param name="maxWeapons"> </param>
        private void AddGunsPositionsFromShipModel(MyModelsEnum modelEnum, int maxSlots)
        {
            List <MyModelSubObject> shipsSubObjects = MyModelSubObjects.GetModelSubObjects(modelEnum);

            if (shipsSubObjects != null)
            {
                for (int i = 0; i < maxSlots; i++)
                {
                    string gunPrefix = GUN_PREFIX_NAME + (i + 1).ToString("##00");

                    // try find guns subobject by prefix (GUN_XX)
                    MyModelSubObject subObjectGun = shipsSubObjects.Find(x => x.Name.StartsWith(gunPrefix));

                    // if not found, then stop adding gun's positions, because there are no gun's subobjects
                    if (subObjectGun == null)
                    {
                        return;
                    }

                    // if not exists slot at this index, then create new one
                    if (WeaponSlots.Count <= i)
                    {
                        MyWeaponSlot newWeaponSlot = new MyWeaponSlot();
                        WeaponSlots.Add(newWeaponSlot);
                        newWeaponSlot.OnWeaponMounting   += m_weaponMounting;
                        newWeaponSlot.OnWeaponDismouting += m_weaponDismounting;
                    }

                    WeaponSlots[i].WeaponSubObject = subObjectGun;

                    // if this gun's position is preffered by any gun
                    if (subObjectGun.Name.Length != gunPrefix.Length)
                    {
                        string prefferedGunName = subObjectGun.Name.Substring(gunPrefix.Length + 1, subObjectGun.Name.Length - gunPrefix.Length - 1);
                        MyMwcObjectBuilder_SmallShip_Weapon_TypesEnum weaponType;
                        if (m_weaponsModelNames.TryGetValue(prefferedGunName, out weaponType))
                        {
                            WeaponSlots[i].WeaponSubObject.AuxiliaryParam0 = (int)weaponType;
                        }
                    }
                }
            }
        }
コード例 #45
0
        static void AddSubObjectsFromModel(MyModelsEnum modelEnum)
        {
            MyModel model  = MyModels.GetModelOnlyDummies(modelEnum);
            string  prefix = modelEnum.ToString() + "_";

            List <MyModelSubObject> subObjectList;

            m_subObjectsMap.TryGetValue((int)modelEnum, out subObjectList);
            if (subObjectList == null)
            {
                subObjectList = new List <MyModelSubObject>();
                m_subObjectsMap.Add((int)modelEnum, subObjectList);
            }

            foreach (KeyValuePair <string, MyModelDummy> pair in model.Dummies)
            {
                subObjectList.Add(new MyModelSubObject(pair.Key, true, pair.Value.Matrix.Translation, MyMwcUtils.Normalize(pair.Value.Matrix.Forward), MyMwcUtils.Normalize(pair.Value.Matrix.Left), MyMwcUtils.Normalize(pair.Value.Matrix.Up), pair.Value.Matrix.Forward.Length(), 0, pair.Value.CustomData));
            }
        }
コード例 #46
0
        /// <summary>
        /// Returns max weapon's slots from ship's model enum
        /// </summary>
        /// <param name="shipModelEnum">Ship's model enum</param>
        /// <returns>Max weapon's slots</returns>
        public static int GetMaxWeaponsSlots(MyModelsEnum shipModelEnum)
        {
            int slots = 0;
            List <MyModelSubObject> shipsSubObjects = MyModelSubObjects.GetModelSubObjects(shipModelEnum);

            while (true)
            {
                string gunPrefix = GUN_PREFIX_NAME + (slots + 1).ToString("##00");

                // try find guns subobject by prefix (GUN_XX)
                MyModelSubObject subObjectGun = shipsSubObjects.Find(x => x.Name.StartsWith(gunPrefix));

                // if not found, then stop adding gun's positions, because there are no gun's subobjects
                if (subObjectGun == null)
                {
                    break;
                }
                slots++;
            }
            return(slots);
        }
コード例 #47
0
        //  IMPORTANT: This class isn't realy inicialized by constructor, but by Start()
        //  So don't initialize members here, do it in Start()
        public virtual void Init(MyModelsEnum modelLod0Enum, MyModelsEnum? modelLod1Enum, MyMaterialType materialType, float scale, List<MyRBElementDesc> collisionPrimitives, float mass)
        {
            MyPhysicsObjects physobj = MyPhysics.physicsSystem.GetPhysicsObjects();

            base.Init(null, modelLod0Enum, modelLod1Enum, null, scale, null);

            m_maxLifeTimeInMiliseconds = MyMwcUtils.GetRandomInt(MyExplosionsConstants.EXPLOSION_DEBRIS_LIVING_MIN_IN_MILISECONDS, MyExplosionsConstants.EXPLOSION_DEBRIS_LIVING_MAX_IN_MILISECONDS);
            m_randomizedDiffuseTextureColorMultiplier = MyMwcUtils.GetRandomFloat(0.4f, 0.6f);
            m_initialOrientation = Matrix.CreateRotationX(MyMwcUtils.GetRandomRadian()) * Matrix.CreateRotationY(MyMwcUtils.GetRandomRadian()) * Matrix.CreateRotationZ(MyMwcUtils.GetRandomRadian());

            // create physics
            this.Physics = new MyPhysicsBody(this, mass, 0) { MaterialType = materialType };
            
            for (int i = 0; i < collisionPrimitives.Count; i++)
            {
                MyRBSphereElement sphereEl = (MyRBSphereElement)physobj.CreateRBElement(collisionPrimitives[i]);
                //
                sphereEl.Radius *= scale;
                this.Physics.AddElement(sphereEl, true);
            }
        }
コード例 #48
0
        public static void LoadData()
        {
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyDebrisField.LoadData");

            MyMwcLog.WriteLine("MyDebrisField.LoadContent() - START");
            MyMwcLog.IncreaseIndent();

            Array DebrisEnumValues = Enum.GetValues(typeof(MyMwcObjectBuilder_SmallDebris_TypesEnum));

            foreach (MyMwcObjectBuilder_SmallDebris_TypesEnum debrisEnum in DebrisEnumValues)
            {
                MyModelsEnum modelEnum = MySmallDebris.GetModelForType(debrisEnum);
                MyModel      model     = MyModels.GetModelForDraw(modelEnum); //Loads model data
                model.PreloadTextures(Managers.LoadingMode.Immediate);
            }

            MyEntities.OnCloseAll += MyEntities_OnCloseAll;

            MyMwcLog.DecreaseIndent();
            MyMwcLog.WriteLine("MyDebrisField.LoadContent() - END");
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
        }
コード例 #49
0
 /// <summary>
 /// Creates new instance of prefab configuration
 /// </summary>
 /// <param name="modelLod0Enum">Model LOD0</param>
 /// <param name="modelLod1Enum">Model LOD2</param>
 /// <param name="buildType">Build type</param>
 /// <param name="categoryType">Category type</param>
 /// <param name="subCategoryType">Subcategory type</param>
 /// <param name="materialType">Material type</param>
 /// <param name="prefabTypeFlag">Prefab type flags</param>
 protected MyPrefabConfiguration(
     MyModelsEnum modelLod0Enum,
     MyModelsEnum? modelLod1Enum,
     BuildTypesEnum buildType,
     CategoryTypesEnum categoryType,
     SubCategoryTypesEnum? subCategoryType,
     MyMaterialType materialType,
     PrefabTypesFlagEnum prefabTypeFlag,
     MyModelsEnum? collisionModelEnum = null,
     MyMwcObjectBuilder_Prefab_AppearanceEnum? factionSpecific = null,
     bool needsUpdate = false,
     bool initPhysics = true,
     bool enabledInEditor = true,
     float rotatingVelocity = DEFAULT_ROTATING_VELOCITY,
     MySoundCuesEnum? startRotatingCue = null,
     MySoundCuesEnum? loopRotatingCue = null,
     MySoundCuesEnum? loopRotatingDamagedCue = null,
     MySoundCuesEnum? endRotatingCue = null,
     MyPreviewPointOfViewEnum previewAngle = MyPreviewPointOfViewEnum.Front,
     float minElectricCapacity = MyGameplayConstants.DEFAULT_MIN_ELECTRIC_CAPACITY,
     float maxElectricCapacity = MyGameplayConstants.DEFAULT_MAX_ELECTRIC_CAPACITY,
     MyExplosionTypeEnum explosionType = MyExplosionTypeEnum.SMALL_SHIP_EXPLOSION,
     float explosionRadiusMultiplier = 1,
     float explosionDamage = 1,
     float minSizeForExplosion = MyExplosionsConstants.MIN_OBJECT_SIZE_TO_CAUSE_EXPLOSION_AND_CREATE_DEBRIS,
     bool causesAlarm = false,
     bool requiresEnergy = false,
     float explosionParticleEffectScale = 1,
     bool displayHud = false)
     : this(buildType, categoryType, subCategoryType, materialType, prefabTypeFlag, factionSpecific, needsUpdate, initPhysics, enabledInEditor, rotatingVelocity, 
     startRotatingCue, loopRotatingCue, loopRotatingDamagedCue, endRotatingCue,
     previewAngle, minElectricCapacity, maxElectricCapacity, explosionType, explosionRadiusMultiplier, explosionDamage, minSizeForExplosion, causesAlarm, requiresEnergy: requiresEnergy, explosionParticleEffectScale: explosionParticleEffectScale, displayHud: displayHud)
 {
     m_modelLod0Enum = modelLod0Enum;
     m_modelLod1Enum = modelLod1Enum;
     m_collisionModelEnum = collisionModelEnum;
 }
コード例 #50
0
 /// <summary>
 /// Creates new instance of prefab configuration with default prefab type flags
 /// </summary>
 /// <param name="modelLod0Enum">Model LOD0</param>
 /// <param name="modelLod1Enum">Model LOD2</param>
 /// <param name="buildType">Build type</param>
 /// <param name="categoryType">Category type</param>
 /// <param name="subCategoryType">Subcategory type</param>
 /// <param name="materialType">Material type</param>
 /// <param name="factionSpecific">To which faction is this prefab specific. Null if prefab is for all factions. Used for material (texture) set availability. </param>     
 public MyPrefabConfiguration(
     MyModelsEnum modelLod0Enum,
     MyModelsEnum? modelLod1Enum,
     BuildTypesEnum buildType,
     CategoryTypesEnum categoryType,
     SubCategoryTypesEnum? subCategoryType,
     MyMaterialType materialType,
     MyMwcObjectBuilder_Prefab_AppearanceEnum? factionSpecific = null,
     MyModelsEnum? collisionModelEnum = null,
     bool needsUpdate = false,
     bool initPhysics = true,
     bool enabledInEditor = true,
     float rotatingVelocity = DEFAULT_ROTATING_VELOCITY,
     MySoundCuesEnum? startRotatingCue = null,
     MySoundCuesEnum? loopRotatingCue = null,
     MySoundCuesEnum? loopRotatingDamagedCue = null,
     MySoundCuesEnum? endRotatingCue = null,
     MyPreviewPointOfViewEnum previewAngle = MyPreviewPointOfViewEnum.Front,
     MyExplosionTypeEnum explosionType = MyExplosionTypeEnum.SMALL_SHIP_EXPLOSION,
     float explosionRadiusMultiplier = 1,
     float explosionDamageMultiplier = 1,
     float minSizeForExplosion = MyExplosionsConstants.MIN_OBJECT_SIZE_TO_CAUSE_EXPLOSION_AND_CREATE_DEBRIS,
     bool causesAlarm = false,
     bool requiresEnergy = false,
     float explosionParticleEffectScale = 1,
     bool displayHud = false)
     : this(modelLod0Enum, modelLod1Enum, buildType, categoryType, subCategoryType, materialType, PrefabTypesFlagEnum.Default, collisionModelEnum, factionSpecific, needsUpdate, initPhysics, enabledInEditor, rotatingVelocity,
     startRotatingCue, loopRotatingCue, loopRotatingDamagedCue, endRotatingCue,
     previewAngle, explosionType: explosionType, explosionRadiusMultiplier: explosionRadiusMultiplier, explosionDamage: explosionDamageMultiplier, minSizeForExplosion: minSizeForExplosion, causesAlarm: causesAlarm, requiresEnergy: requiresEnergy, explosionParticleEffectScale: explosionParticleEffectScale, displayHud: displayHud)
 {
     System.Diagnostics.Debug.Assert(modelLod0Enum != modelLod1Enum, "LOD0 and LOD1 models are the same!");
     if (collisionModelEnum != null)
     {
         System.Diagnostics.Debug.Assert(modelLod0Enum != collisionModelEnum, "LOD0 and COL models are the same!");
         System.Diagnostics.Debug.Assert(modelLod1Enum != collisionModelEnum, "LOD1 and COL models are the same!");
     }
 }
コード例 #51
0
        //  IMPORTANT: This class isn't realy inicialized by constructor, but by Start()
        //  So don't initialize members here, do it in Start()
        public virtual void Init(MyModelsEnum modelLod0Enum, MyModelsEnum?modelLod1Enum, MyMaterialType materialType, float scale, List <MyRBElementDesc> collisionPrimitives, float mass)
        {
            MyPhysicsObjects physobj = MyPhysics.physicsSystem.GetPhysicsObjects();

            base.Init(null, modelLod0Enum, modelLod1Enum, null, scale, null);

            m_maxLifeTimeInMiliseconds = MyMwcUtils.GetRandomInt(MyExplosionsConstants.EXPLOSION_DEBRIS_LIVING_MIN_IN_MILISECONDS, MyExplosionsConstants.EXPLOSION_DEBRIS_LIVING_MAX_IN_MILISECONDS);
            m_randomizedDiffuseTextureColorMultiplier = MyMwcUtils.GetRandomFloat(0.4f, 0.6f);
            m_initialOrientation = Matrix.CreateRotationX(MyMwcUtils.GetRandomRadian()) * Matrix.CreateRotationY(MyMwcUtils.GetRandomRadian()) * Matrix.CreateRotationZ(MyMwcUtils.GetRandomRadian());

            // create physics
            this.Physics = new MyPhysicsBody(this, mass, 0)
            {
                MaterialType = materialType
            };

            for (int i = 0; i < collisionPrimitives.Count; i++)
            {
                MyRBSphereElement sphereEl = (MyRBSphereElement)physobj.CreateRBElement(collisionPrimitives[i]);
                //
                sphereEl.Radius *= scale;
                this.Physics.AddElement(sphereEl, true);
            }
        }
コード例 #52
0
 public MyPrefabConfigurationLight(MyModelsEnum modelLod0Enum, MyModelsEnum? modelLod1Enum, BuildTypesEnum buildType, CategoryTypesEnum categoryType,
     SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType, MyLightPrefabTypeEnum type, PrefabTypesFlagEnum prefabTypesFlag, MyModelsEnum? collisionModelEnum = null)
     : base(modelLod0Enum, modelLod1Enum, buildType, categoryType, subCategoryType, materialType, prefabTypesFlag, previewAngle: MyPreviewPointOfViewEnum.Bottom, needsUpdate: true, collisionModelEnum: collisionModelEnum)
 {
     LightType = type;
 }
コード例 #53
0
 public MyPrefabConfigurationLight(MyModelsEnum modelLod0Enum, MyModelsEnum? modelLod1Enum, BuildTypesEnum buildType, CategoryTypesEnum categoryType,
     SubCategoryTypesEnum? subCategoryType, MyMaterialType materialType, MyLightPrefabTypeEnum type, MyModelsEnum? collisionModelEnum = null)
     : this(modelLod0Enum, modelLod1Enum, buildType, categoryType, subCategoryType, materialType, type, PrefabTypesFlagEnum.Default, collisionModelEnum)
 {            
 }
コード例 #54
0
        static void AddSubObjectsFromModel(MyModelsEnum modelEnum)
        {
            MyModel model = MyModels.GetModelOnlyDummies(modelEnum);
            string prefix = modelEnum.ToString() + "_";

            List<MyModelSubObject> subObjectList;
            m_subObjectsMap.TryGetValue((int)modelEnum, out subObjectList);
            if (subObjectList == null)
            {
                subObjectList = new List<MyModelSubObject>();
                m_subObjectsMap.Add((int)modelEnum, subObjectList);
            }

            foreach (KeyValuePair<string, MyModelDummy> pair in model.Dummies)
            {
                subObjectList.Add(new MyModelSubObject(pair.Key, true, pair.Value.Matrix.Translation, MyMwcUtils.Normalize(pair.Value.Matrix.Forward), MyMwcUtils.Normalize(pair.Value.Matrix.Left), MyMwcUtils.Normalize(pair.Value.Matrix.Up), pair.Value.Matrix.Forward.Length(), 0, pair.Value.CustomData)); 
            }
        }
コード例 #55
0
     public static List<MyModelSubObject> GetModelSubObjects(MyModelsEnum modelEnum) 
     {
         List<MyModelSubObject> subObjectList;
         m_subObjectsMap.TryGetValue((int)modelEnum, out subObjectList);
         return subObjectList;
 }
コード例 #56
0
        public static MyModelSubObject GetModelSubObject(MyModelsEnum modelEnum, string subObjectName)
        {
            List<MyModelSubObject> subObjectList;
            m_subObjectsMap.TryGetValue((int)modelEnum, out subObjectList);
            if (subObjectList == null)
                return null;

            return subObjectList.Find(x => x.Name == subObjectName);
        }
コード例 #57
0
ファイル: MyCargoBox.cs プロジェクト: ripark/Miner-Wars-2081
 private static MyMwcObjectBuilder_CargoBox_TypesEnum GetTypeFromModelLod0Enum(MyModelsEnum model)
 {
     switch (model)
     {
         case MyModelsEnum.cargo_box_1:
             return MyMwcObjectBuilder_CargoBox_TypesEnum.Type1;
         case MyModelsEnum.cargo_box_2:
             return MyMwcObjectBuilder_CargoBox_TypesEnum.Type2;
         case MyModelsEnum.cargo_box_3:
             return MyMwcObjectBuilder_CargoBox_TypesEnum.Type3;
         case MyModelsEnum.cargo_box_4:
             return MyMwcObjectBuilder_CargoBox_TypesEnum.Type4;
         case MyModelsEnum.cargo_box_5:
             return MyMwcObjectBuilder_CargoBox_TypesEnum.Type5;
         case MyModelsEnum.cargo_box_6:
             return MyMwcObjectBuilder_CargoBox_TypesEnum.Type6;
         case MyModelsEnum.cargo_box_7:
             return MyMwcObjectBuilder_CargoBox_TypesEnum.Type7;
         case MyModelsEnum.cargo_box_8:
             return MyMwcObjectBuilder_CargoBox_TypesEnum.Type8;
         case MyModelsEnum.cargo_box_9:
             return MyMwcObjectBuilder_CargoBox_TypesEnum.Type9;
         case MyModelsEnum.cargo_box_10:
             return MyMwcObjectBuilder_CargoBox_TypesEnum.Type10;
         case MyModelsEnum.cargo_box_11:
             return MyMwcObjectBuilder_CargoBox_TypesEnum.Type11;
         case MyModelsEnum.cargo_box_12:
             return MyMwcObjectBuilder_CargoBox_TypesEnum.Type12;
         case MyModelsEnum.CargoBox_prop_A:
             return MyMwcObjectBuilder_CargoBox_TypesEnum.TypeProp_A;
         case MyModelsEnum.CargoBox_prop_B:
             return MyMwcObjectBuilder_CargoBox_TypesEnum.TypeProp_B;
         case MyModelsEnum.CargoBox_prop_C:
             return MyMwcObjectBuilder_CargoBox_TypesEnum.TypeProp_C;
         case MyModelsEnum.CargoBox_prop_D:
             return MyMwcObjectBuilder_CargoBox_TypesEnum.TypeProp_D;
         case MyModelsEnum.cargo_box_small:
             return MyMwcObjectBuilder_CargoBox_TypesEnum.DroppedItems;
         default:
             return (MyMwcObjectBuilder_CargoBox_TypesEnum)0;
     }
 }
コード例 #58
0
        public void Init(MyPrefabBase kinematicPartOwner, MyMwcObjectBuilderTypeEnum prefabKinematicPartBuilderType, int?prefabKinematicPartBuilderId, MyModelsEnum modelEnum, MyMaterialType materialType, Matrix kinematicLocalMatrix, float kinematicVelocityMax, MySoundCuesEnum?loopSound, MySoundCuesEnum?loopDamagedSound, MySoundCuesEnum?startSound, MySoundCuesEnum?endSound, float kinematicStart, float kinematicEnd)
        {
            m_needsUpdate          = true;
            m_kinematicPartOwner   = kinematicPartOwner;
            m_kinematicLocalMatrix = kinematicLocalMatrix;
            m_kinematicVelocityMax = kinematicVelocityMax;
            m_kinematicStart       = kinematicStart;
            m_kinematicEnd         = kinematicEnd;

            m_loopSoundCue        = loopSound;
            m_loopDamagedSoundCue = loopDamagedSound;
            m_startSoundCue       = startSound;
            m_endSoundCue         = endSound;

            MyMwcObjectBuilder_Base objbuilder = MyMwcObjectBuilder_Base.CreateNewObject(prefabKinematicPartBuilderType, prefabKinematicPartBuilderId);

            m_config = m_kinematicPartOwner.GetConfiguration();
            base.Init(null, modelEnum, null, kinematicPartOwner, null, objbuilder);
            LocalMatrix = Matrix.Identity;

            MaterialIndex = m_kinematicPartOwner.MaterialIndex;


            //InitTrianglePhysics(materialType, 1.0f, ModelLod0, null, MyConstants.COLLISION_LAYER_PREFAB_KINEMATIC_PART);
            InitBoxPhysics(materialType, ModelLod0, 100, 0, MyConstants.COLLISION_LAYER_PREFAB_KINEMATIC_PART, RigidBodyFlag.RBF_RBO_STATIC);
            Physics.Enabled = true;

            m_kinematicPartOwner.OnPositionChanged += OwnerPositionChanged;
        }
コード例 #59
0
 public MyStaticAsteroidModels(MyModelsEnum lod0, MyModelsEnum? lod1, MyModelsEnum? lod2)
 {
     LOD0 = lod0;
     LOD1 = lod1;
     LOD2 = lod2;
 }
コード例 #60
0
        static void AddEntityModels(string assetName, MyModelsEnum lod0, MyModelsEnum? lod1, MyModelsEnum? collision, bool keepInMemory = false)
        {
            AddModel(new MyModel(assetName, MyMeshDrawTechnique.MESH, lod0, keepInMemory));

            if (lod1.HasValue)
                AddModel(new MyModel(assetName + "_LOD1", MyMeshDrawTechnique.MESH, lod1.Value, keepInMemory));
            if (collision.HasValue)
                AddModel(new MyModel(assetName + "_COL", MyMeshDrawTechnique.MESH, collision.Value, keepInMemory));
        }