Exemplo n.º 1
0
        public override void Init(string hudLabelText, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
        {
            MyMwcObjectBuilder_PrefabLargeShip objectBuilderLargeShip = objectBuilder as MyMwcObjectBuilder_PrefabLargeShip;            
            
            m_owner.Inventory.OnInventoryContentChange += OnInventoryContentChanged;

            Name = objectBuilderLargeShip.Name;

            base.Init(Name, relativePosition, localOrientation, objectBuilder, prefabConfig);
        }
Exemplo n.º 2
0
        public static string GetPreviewFileName(MyPrefabConfiguration config, MyMwcObjectBuilder_Prefab_TypesEnum enumValue)
        {
            if (config.BuildType == BuildTypesEnum.MODULES && config.CategoryType == CategoryTypesEnum.WEAPONRY)
            {
                MyModelsEnum baseModelEnum, barelModelEnum;
                if (MyLargeShipGunBase.GetModelEnums(enumValue, out baseModelEnum, out barelModelEnum))
                {
                    return(Path.GetFileName(MyModels.GetModelAssetName(baseModelEnum)));
                }
            }

            return(Path.GetFileName(MyModels.GetModelAssetName(config.ModelLod0Enum)));
        }
Exemplo n.º 3
0
 protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
 {
     MyMwcObjectBuilder_PrefabGenerator objectBuilderGenerator = objectBuilder as MyMwcObjectBuilder_PrefabGenerator;
     UseProperties = new MyUseProperties(MyUseType.FromHUB | MyUseType.Solo, MyUseType.FromHUB | MyUseType.Solo);
     if (objectBuilder.UseProperties == null)
     {
         UseProperties.Init(MyUseType.FromHUB | MyUseType.Solo, MyUseType.FromHUB | MyUseType.Solo, 1, 4000, false);                
     }
     else
     {
         UseProperties.Init(objectBuilder.UseProperties);
     }
 }
Exemplo n.º 4
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;
        }
Exemplo n.º 5
0
 protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
 {
     UseProperties = new MyUseProperties(MyUseType.FromHUB | MyUseType.Solo, MyUseType.None);
     if (objectBuilder.UseProperties == null)
     {
         UseProperties.Init(MyUseType.FromHUB | MyUseType.Solo, MyUseType.None, 0, 1, false);                
     }
     else
     {                
         UseProperties.Init(objectBuilder.UseProperties);
     }            
     
     Enabled = true;
 }
        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;
        }
Exemplo n.º 7
0
        protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
        {
            MyMwcObjectBuilder_PrefabAlarm objectBuilderAlarm = objectBuilder as MyMwcObjectBuilder_PrefabAlarm;
            MyPrefabConfigurationAlarm alarmConfig = prefabConfig as MyPrefabConfigurationAlarm;

            m_modelLod0On = MyModels.GetModelOnlyData(alarmConfig.ModelLod0EnumOn);
            if (alarmConfig.ModelLod1EnumOn != null)
            {
                m_modelLod1On = MyModels.GetModelOnlyData(alarmConfig.ModelLod1EnumOn.Value);
            }
            m_modelLod0Off = m_modelLod0;
            m_modelLod1Off = m_modelLod1;

            Flags |= EntityFlags.EditableInEditor;
            InitLight();
        }
Exemplo n.º 8
0
        protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
        {            
            MyPrefabConfigurationParticles prefabParticleConfig = prefabConfig as MyPrefabConfigurationParticles;
            
            m_lastTimeParticle = MyMinerGame.TotalGamePlayTimeInMilliseconds;
            MyModel model = MyModels.GetModelOnlyDummies(prefabParticleConfig.ModelLod0Enum);
            m_pointLocalMatrix = Matrix.Identity;
            foreach (KeyValuePair<string, MyModelDummy> pair in model.Dummies)
            {
                m_pointLocalMatrix = pair.Value.Matrix;
            }

            m_particleEffect = MyParticlesManager.CreateParticleEffect((int)prefabParticleConfig.EffectID, true);
            m_particleEffect.AutoDelete = false;
            m_particleEffect.WorldMatrix = WorldMatrix;
        }
Exemplo n.º 9
0
        protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
        {
            m_prefabSoundConfig = prefabConfig as MyPrefabConfigurationSound;            

            MyModel model = MyModels.GetModelOnlyDummies(m_prefabSoundConfig.ModelLod0Enum);
            m_pointLocalMatrix = Matrix.Identity;
            m_cueEnum = m_prefabSoundConfig.Sound;
            foreach (KeyValuePair<string, MyModelDummy> pair in model.Dummies)
            {
                m_pointLocalMatrix = pair.Value.Matrix;
            }

            if (IsWorking())
            {
                PlaySound();
            }
        }
        protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
        {
            MyMwcObjectBuilder_PrefabSecurityControlHUB objectBuilderSecurityControlHUB = (MyMwcObjectBuilder_PrefabSecurityControlHUB) objectBuilder;
            //m_connetectedEntitiesIds.AddRange(objectBuilderSecurityControlHUB.ConnectedEntities);

            UseProperties = new MyUseProperties(MyUseType.Solo, MyUseType.Solo);
            if (objectBuilderSecurityControlHUB.UseProperties == null)
            {
                UseProperties.Init(MyUseType.Solo, MyUseType.Solo, 1, 4000, false);
            }
            else
            {
                UseProperties.Init(objectBuilderSecurityControlHUB.UseProperties);
            }

            UpdateSound();

            m_needsUpdate = true;
        }
Exemplo n.º 11
0
 protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
 {
     MyMwcObjectBuilder_PrefabBankNode objectBuilderBankNode = objectBuilder as MyMwcObjectBuilder_PrefabBankNode;
     Cash = objectBuilderBankNode.Cash;
     UseProperties = new MyUseProperties(MyUseType.None, MyUseType.Solo);
     if (objectBuilderBankNode.UseProperties == null)
     {
         UseProperties.Init(MyUseType.None, MyUseType.Solo, 3, 4000, false);                
     }
     else
     {                
         UseProperties.Init(objectBuilderBankNode.UseProperties);
     }
     // some default cash for testing
     if (!UseProperties.IsHacked)
     {
         Cash = 8000f;
     }            
 }
Exemplo n.º 12
0
        protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
        {
            //Physics.RemoveAllElements();

            //float raidus = ModelLod0.BoundingSphere.Radius;
            //Vector3 min = new Vector3(-raidus, -raidus, -raidus);
            //Vector3 max = new Vector3(raidus, raidus, raidus);
            //m_localBoundingBox = new BoundingBox(min, max);            

            UseProperties = new MyUseProperties(MyUseType.None, MyUseType.Solo);
            if (objectBuilder.UseProperties == null)
            {
                UseProperties.Init(MyUseType.None, MyUseType.None, 3, 8000, false);
            }
            else
            {
                UseProperties.Init(objectBuilder.UseProperties);
            }
        }
        /// <summary>
        /// Creates new foundation factory from player's inventory. When player has no foundation factory in inventory, then returns result false.
        /// </summary>
        /// <param name="result">Result of foundation factory creation</param>
        /// <returns>Instance of new foundation factory</returns>
        public static MyPrefabFoundationFactory TryCreateFoundationFactory(MyPlayer player, out bool result)
        {
            MyPrefabFoundationFactory foundationFactory     = null;
            MyInventoryItem           foundationFactoryItem = player.Ship.Inventory.GetInventoryItem(MyMwcObjectBuilderTypeEnum.PrefabFoundationFactory, (int)MyMwcObjectBuilder_PrefabFoundationFactory_TypesEnum.DEFAULT);

            if (foundationFactoryItem == null)
            {
                foundationFactoryItem = player.Ship.Inventory.GetInventoryItem(MyMwcObjectBuilderTypeEnum.FoundationFactory, null);
            }
            if (foundationFactoryItem == null)
            {
                result = false;
            }
            else
            {
                MyMwcObjectBuilder_PrefabFoundationFactory foundationFactoryBuilder =
                    MyMwcObjectBuilder_Base.CreateNewObject(MyMwcObjectBuilderTypeEnum.PrefabFoundationFactory, (int)MyMwcObjectBuilder_PrefabFoundationFactory_TypesEnum.DEFAULT) as MyMwcObjectBuilder_PrefabFoundationFactory;
                MyMwcObjectBuilder_PrefabContainer prefabContainerBuilder = new MyMwcObjectBuilder_PrefabContainer(
                    null, MyMwcObjectBuilder_PrefabContainer_TypesEnum.INSTANCE, new List <MyMwcObjectBuilder_PrefabBase>(), MyClientServer.LoggedPlayer.GetUserId(),
                    player.Faction, new MyMwcObjectBuilder_Inventory(new List <MyMwcObjectBuilder_InventoryItem>(), 1000));

                Matrix ffWorld = Matrix.Identity;
                ffWorld.Translation = player.Ship.WorldMatrix.Translation + player.Ship.WorldMatrix.Forward * 20;

                MyPrefabContainer prefabContainer = new MyPrefabContainer();
                prefabContainer.Init(null, prefabContainerBuilder, ffWorld);
                MyEntities.Add(prefabContainer);

                MyPrefabConfiguration ffConfiguration = MyPrefabConstants.GetPrefabConfiguration(MyMwcObjectBuilderTypeEnum.PrefabFoundationFactory, (int)MyMwcObjectBuilder_PrefabFoundationFactory_TypesEnum.DEFAULT);

                foundationFactory = new MyPrefabFoundationFactory(prefabContainer);
                foundationFactory.Init(null, new Vector3(0f, 0f, 0f), Matrix.Identity, foundationFactoryBuilder, ffConfiguration);
                prefabContainer.AddPrefab(foundationFactory);

                player.Ship.Inventory.RemoveInventoryItemAmount(ref foundationFactoryItem, 1f);

                result = true;
            }
            return(foundationFactory);
        }
Exemplo n.º 14
0
        private void CreateDDSFiles(int sizeInPixels, DirectoryInfo directoryInfo)
        {
            int index = 1;

            foreach (MyMwcObjectBuilder_Prefab_TypesEnum enumValue in MyGuiPrefabHelpers.MyMwcPrefabTypesEnumValues)
            {
                Debug.WriteLine(string.Format("Exporting Prefab Preview {0}/{1} ..", index++,
                                              MyGuiPrefabHelpers.MyMwcPrefabTypesEnumValues.Length));

                MyPrefabConfiguration config = MyPrefabConstants.GetPrefabConfiguration(enumValue);
                string lod0Name = GetPreviewFileName(config, enumValue);

                var    result   = RenderPreview(enumValue, config, sizeInPixels, sizeInPixels);
                string fileName = Path.Combine(directoryInfo.FullName, string.Format("{0}.dds", lod0Name));
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }

                MyDDSFile.DDSToFile(fileName, true, result, false);
            }
        }
Exemplo n.º 15
0
        protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
        {

            m_prefabLightConfig = prefabConfig as MyPrefabConfigurationLight;
            MyMwcObjectBuilder_PrefabLight objectBuilderLight = objectBuilder as MyMwcObjectBuilder_PrefabLight;            

            m_light = MyLights.AddLight();

            m_light.LightType = (MyLight.LightTypeEnum)objectBuilderLight.LightType;

            m_light.Start(m_light.LightType, 1);
            m_light.UseInForwardRender = true;


            //grab first dummy and set it as point source
            //since we dont support yet more lights in one prefab. add just the first one
            MyModel model = MyModels.GetModelOnlyDummies(m_prefabLightConfig.ModelLod0Enum);

            m_pointLocalMatrix = Matrix.Identity;
            bool dummyFound = false;
            foreach (KeyValuePair<string, MyModelDummy> pair in model.Dummies)
            {
                if (pair.Key.StartsWith("Dummy", StringComparison.InvariantCultureIgnoreCase))
                {
                    m_pointLocalMatrix = pair.Value.Matrix;
                    dummyFound = true;
                    break;
                }
            }
            Debug.Assert(dummyFound, "Dummy 'POINT_LIGHT_POS' not found in light prefab model: " + model.AssetName);

            m_light.Color = objectBuilderLight.PointColor;
            m_light.ReflectorColor = objectBuilderLight.SpotColor;
            m_light.Falloff = objectBuilderLight.PointFalloff;
            m_light.ReflectorFalloff = objectBuilderLight.SpotFalloff;
            m_IntensityMax = m_light.Intensity = objectBuilderLight.PointIntensity;
            m_light.ReflectorIntensity = ReflectorIntensityMax = objectBuilderLight.SpotIntensity;
            m_light.ReflectorRange = MathHelper.Clamp(objectBuilderLight.SpotRange, 1, MyLightsConstants.MAX_SPOTLIGHT_RANGE);
            m_light.Range = MathHelper.Clamp(objectBuilderLight.PointRange, 1, MyLightsConstants.MAX_POINTLIGHT_RADIUS);
            m_light.PointLightOffset = objectBuilderLight.PointOffset;
            this.FlashOffset = objectBuilderLight.FlashOffset;

            //to add reflector range to builders
            m_light.SpecularColor = objectBuilderLight.PointSpecular;
            m_light.ReflectorConeDegrees = objectBuilderLight.SpotAgle;
            m_effect = objectBuilderLight.Effect;
            //m_light.LightOn = true;
            m_lastBlickChange = MyMinerGame.TotalGamePlayTimeInMilliseconds;

            // here set the properties of glare for the prefab light
            m_light.GlareOn = true;
            m_light.Glare.Type = MyLightGlare.GlareTypeEnum.Normal;
            m_light.Glare.QuerySize = .8f;
            m_light.ShadowDistance = objectBuilderLight.ShadowsDistance;
            m_light.Glare.Intensity = m_light.Intensity;
            UpdateEffect();

            CastShadows = false;
            UpdateLightWorldMatrix();            
        }
Exemplo n.º 16
0
        protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
        {
            MyMwcObjectBuilder_PrefabGenerator objectBuilderGenerator = objectBuilder as MyMwcObjectBuilder_PrefabGenerator;

            UseProperties = new MyUseProperties(MyUseType.FromHUB | MyUseType.Solo, MyUseType.FromHUB | MyUseType.Solo);
            if (objectBuilder.UseProperties == null)
            {
                UseProperties.Init(MyUseType.FromHUB | MyUseType.Solo, MyUseType.FromHUB | MyUseType.Solo, 1, 4000, false);
            }
            else
            {
                UseProperties.Init(objectBuilder.UseProperties);
            }
        }
Exemplo n.º 17
0
 static void AddPrefabConfiguration(MyMwcObjectBuilderTypeEnum prefabType, ushort prefabId, MyPrefabConfiguration prefabConfiguration)
 {
     ushort prefabTypeInt = (ushort)prefabType;
     if (m_prefabConfigurations[prefabTypeInt] == null)
     {
         m_prefabConfigurations[prefabTypeInt] = new MyPrefabConfiguration[MyMwcObjectBuilder_Base.GetObjectBuilderIDs(prefabType).Max() + 1];
     }
     m_prefabConfigurations[prefabTypeInt][prefabId] = prefabConfiguration;
 }
Exemplo n.º 18
0
        protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
        {
            MyMwcObjectBuilder_PrefabBankNode objectBuilderBankNode = objectBuilder as MyMwcObjectBuilder_PrefabBankNode;

            Cash          = objectBuilderBankNode.Cash;
            UseProperties = new MyUseProperties(MyUseType.None, MyUseType.Solo);
            if (objectBuilderBankNode.UseProperties == null)
            {
                UseProperties.Init(MyUseType.None, MyUseType.Solo, 3, 4000, false);
            }
            else
            {
                UseProperties.Init(objectBuilderBankNode.UseProperties);
            }
            // some default cash for testing
            if (!UseProperties.IsHacked)
            {
                Cash = 8000f;
            }
        }
Exemplo n.º 19
0
        protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
        {
            MyMwcObjectBuilder_PrefabScanner objectBuilderScanner = objectBuilder as MyMwcObjectBuilder_PrefabScanner;

            UseProperties = new MyUseProperties(MyUseType.FromHUB, MyUseType.FromHUB | MyUseType.Solo);
            if (objectBuilderScanner.UseProperties == null)
            {
                UseProperties.Init(MyUseType.FromHUB | MyUseType.Solo, MyUseType.FromHUB | MyUseType.Solo, 3, 4000, false);
            }
            else
            {                
                UseProperties.Init(objectBuilderScanner.UseProperties);
            }

            Size = objectBuilderScanner.Size;
            Color = objectBuilderScanner.Color;
            ScanningSpeed = objectBuilderScanner.ScanningSpeed;
            InitScanningPart();

            Flags |= EntityFlags.EditableInEditor;            
        }
Exemplo n.º 20
0
        public static string GetPreviewFileName(MyPrefabConfiguration config, int prefabId)
        {
            if (config.BuildType == BuildTypesEnum.MODULES && config.CategoryType == CategoryTypesEnum.WEAPONRY)
            {
                MyModelsEnum baseModelEnum, barelModelEnum;
                if (MyLargeShipGunBase.GetModelEnums((MyMwcObjectBuilder_PrefabLargeWeapon_TypesEnum)prefabId, out baseModelEnum, out barelModelEnum))
                {
                    return Path.GetFileName(MyModels.GetModelAssetName(baseModelEnum));
                }
            }            

            return Path.GetFileName(MyModels.GetModelAssetName(config.ModelLod0Enum));
        }
Exemplo n.º 21
0
 protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
 {
 }
        protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
        {
            MyMwcObjectBuilder_PrefabFoundationFactory objectBuilderFF = objectBuilder as MyMwcObjectBuilder_PrefabFoundationFactory;

            IsBuilding = objectBuilderFF.IsBuilding;
            m_buildingTimeFromStart = objectBuilderFF.BuildingTimeFromStart;
            if (objectBuilderFF.BuildingObject != null)
            {
                BuildingObject = MyObjectToBuild.CreateFromObjectBuilder(objectBuilderFF.BuildingObject.ObjectBuilder, objectBuilderFF.BuildingObject.Amount);
            }
            if (objectBuilderFF.BuildingQueue != null)
            {
                foreach (MyMwcObjectBuilder_ObjectToBuild buildingQueue in objectBuilderFF.BuildingQueue)
                {
                    BuildingQueue.Add(MyObjectToBuild.CreateFromObjectBuilder(buildingQueue.ObjectBuilder, buildingQueue.Amount));
                }
            }
        }
Exemplo n.º 23
0
        protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
        {            
            prefabConfiguration = prefabConfig as MyPrefabConfigurationLargeWeapon;
            MyMwcObjectBuilder_PrefabLargeWeapon largeWeaponBuilder = objectBuilder as MyMwcObjectBuilder_PrefabLargeWeapon;
            weaponType = largeWeaponBuilder.PrefabLargeWeaponType;

            UseProperties = new MyUseProperties(MyUseType.FromHUB | MyUseType.Solo, MyUseType.FromHUB);
            if (largeWeaponBuilder.UseProperties == null)
            {
                UseProperties.Init(MyUseType.FromHUB | MyUseType.Solo, MyUseType.FromHUB, 1, 4000, false);
            }
            else
            {                
                UseProperties.Init(largeWeaponBuilder.UseProperties);
            }            

            // create & initialize weapon:
            MyLargeShipGunBase.CreateAloneWeapon(ref m_gun, displayName, Vector3.Zero, Matrix.Identity, largeWeaponBuilder, Activated);
            AddChild(m_gun);

            m_gun.PrefabParent = this;
            m_gun.Enabled = IsWorking();
            m_gun.SetRandomRotation();

           // if (largeWeaponBuilder.SearchingDistance == 2000)
             //   largeWeaponBuilder.SearchingDistance = 1000;

            this.LocalMatrix = Matrix.CreateWorld(relativePosition, localOrientation.Forward, localOrientation.Up);
            m_searchingDistance = MathHelper.Clamp(largeWeaponBuilder.SearchingDistance, MyLargeShipWeaponsConstants.MIN_SEARCHING_DISTANCE, MyLargeShipWeaponsConstants.MAX_SEARCHING_DISTANCE); 
            m_targetDetectorCriterias.Add(new MyEntityDetectorCriterium<MySmallShip>(1, IsPossibleTarget, true));
            m_targetsDetector = new MyEntityDetector(true);
            
            m_potentialTargetsDetector = new MyEntityDetector(true);
            m_potentialTargetDetectorCriterias.Add(new MyEntityDetectorCriterium<MySmallShip>(1, IsPotentialTarget, true));
            //m_targetsDetector.OnEntityEnter += OnTargetDetected;
            //m_targetsDetector.OnEntityLeave += OnTargetLost;
            m_targetsDetector.OnNearestEntityChange += OnNearestTargetChange;
            m_potentialTargetsDetector.OnNearestEntityChange += OnNearestPotentialTargetChange;
            //m_targetsDetector.OnEntityPositionChange += OnTargetPositionChanged;
            InitDetector(Activated);
        }
        protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
        {
            MyMwcObjectBuilder_PrefabSecurityControlHUB objectBuilderSecurityControlHUB = (MyMwcObjectBuilder_PrefabSecurityControlHUB)objectBuilder;

            //m_connetectedEntitiesIds.AddRange(objectBuilderSecurityControlHUB.ConnectedEntities);

            UseProperties = new MyUseProperties(MyUseType.Solo, MyUseType.Solo);
            if (objectBuilderSecurityControlHUB.UseProperties == null)
            {
                UseProperties.Init(MyUseType.Solo, MyUseType.Solo, 1, 4000, false);
            }
            else
            {
                UseProperties.Init(objectBuilderSecurityControlHUB.UseProperties);
            }

            UpdateSound();

            m_needsUpdate = true;
        }
Exemplo n.º 25
0
        private MyToolTips GetPrefabToolTip(StringBuilder prefabDescription, MyPrefabConfiguration prefabConfiguration)
        {
            StringBuilder retval = new StringBuilder(prefabDescription.ToString() + Environment.NewLine);
            /*  //this is loading time killer!!
            MyModel model;
            string BBsize = "";
            model = MyModels.GetModel(prefabConfiguration.ModelLod0Enum);
            if (model == null || !model.LoadedData)
            {
                model = MyModels.GetModelOnlyModelInfo(prefabConfiguration.ModelLod0Enum);
            }
            if (model != null)
            {
                retval.AppendLine("LOD0 asset: " + model.AssetName);
                retval.AppendLine("LOD0 number of triangles: " + model.ModelInfo.TrianglesCount.ToString());
                retval.AppendLine("LOD0 number of vertexes: " + model.ModelInfo.VerticesCount.ToString());
                BBsize = "Bounding box size: (" + model.ModelInfo.BoundingBoxSize.X + ", " + model.ModelInfo.BoundingBoxSize.Y + ", " + model.ModelInfo.BoundingBoxSize.Z + ")";
            }
            if (prefabConfiguration.ModelLod1Enum.HasValue)
            {
                model = MyModels.GetModel(prefabConfiguration.ModelLod1Enum.Value);
                if (model == null || !model.LoadedData)
                {
                    model = MyModels.GetModelOnlyModelInfo(prefabConfiguration.ModelLod1Enum.Value);
                }
                if (model != null)
                {
                    retval.AppendLine("LOD1 asset: " + model.AssetName);
                    retval.AppendLine("LOD1 number of triangles: " + model.ModelInfo.TrianglesCount.ToString());
                    retval.AppendLine("LOD1 number of vertexes: " + model.ModelInfo.VerticesCount.ToString());
                }
            }
            if (prefabConfiguration.ModelCollisionEnum.HasValue)
            {
                model = MyModels.GetModel(prefabConfiguration.ModelCollisionEnum.Value);
                if (model == null || !model.LoadedData)
                {
                    model = MyModels.GetModelOnlyModelInfo(prefabConfiguration.ModelCollisionEnum.Value);
                }
                if (model != null)
                {
                    retval.AppendLine("COL asset: " + model.AssetName);
                    retval.AppendLine("COL number of triangles: " + model.ModelInfo.TrianglesCount.ToString());
                    retval.AppendLine("COL number of vertexes: " + model.ModelInfo.VerticesCount.ToString());
                }
            }
            retval.Append(BBsize);
                  */

            return new MyToolTips(retval);
        }
Exemplo n.º 26
0
        protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
        {
            MyPrefabConfigurationKinematic prefabKinematicConfig = (MyPrefabConfigurationKinematic)prefabConfig;
            MyMwcObjectBuilder_PrefabKinematic kinematicBuilder = objectBuilder as MyMwcObjectBuilder_PrefabKinematic;                        

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

            for (int i = 0; i < prefabKinematicConfig.KinematicParts.Count; i++)
            {
                MyPrefabConfigurationKinematicPart kinematicPart = prefabKinematicConfig.KinematicParts[i];
                MyModelDummy open, close;
                if (model.Dummies.TryGetValue(kinematicPart.m_open, out open) && model.Dummies.TryGetValue(kinematicPart.m_close, out close))
                {
                    float? kinematicPartHealth = kinematicBuilder.KinematicPartsHealth[i];
                    float? kinematicPartMaxHealth = kinematicBuilder.KinematicPartsMaxHealth[i];
                    uint? kinematicPartEntityId = kinematicBuilder.KinematicPartsEntityId[i];

                    // if health is not set or not destroyed, then create part
                    if (kinematicPartHealth == null || kinematicPartHealth != 0)
                    {
                        MyPrefabKinematicPart newPart = new MyPrefabKinematicPart(m_owner);
                        if (kinematicPartEntityId.HasValue)
                        {
                            newPart.EntityId = new MyEntityIdentifier(kinematicPartEntityId.Value);
                        }
                        Parts[i] = newPart;
                        newPart.Init(this, kinematicPart, prefabKinematicConfig.m_openTime, prefabKinematicConfig.m_closeTime, (MyModelsEnum)kinematicPart.m_modelMovingEnum, open.Matrix, close.Matrix, prefabKinematicConfig.MaterialType, prefabKinematicConfig.m_soundLooping, prefabKinematicConfig.m_soundOpening, prefabKinematicConfig.m_soundClosing/*, m_groupMask*/, kinematicPartHealth, kinematicPartMaxHealth, Activated);
                    }
                }
            }                        

            //make handler
            m_sensorHandler = new MyPrefabKinematicSensor(this);
            MySphereSensorElement sensorEl = new MySphereSensorElement();
            sensorEl.Radius = DETECT_RADIUS;
            sensorEl.LocalPosition = new Vector3(0, 0, 0);
            sensorEl.DetectRigidBodyTypes = MyConstants.RIGIDBODY_TYPE_SHIP;            
            sensorEl.SpecialDetectingAngle = DETECTION_ANGLE;
            MySensorDesc senDesc = new MySensorDesc();
            senDesc.m_Element = sensorEl;
            senDesc.m_Matrix = WorldMatrix;
            senDesc.m_SensorEventHandler = m_sensorHandler;
            m_sensor = new MySensor();
            m_sensor.LoadFromDesc(senDesc);
            MyPhysics.physicsSystem.GetSensorModule().AddSensor(m_sensor);

            GetOwner().UpdateAABB();

            UseProperties = new MyUseProperties(MyUseType.FromHUB | MyUseType.Solo, MyUseType.FromHUB);
            if (kinematicBuilder.UseProperties == null)
            {
                UseProperties.Init(MyUseType.FromHUB, MyUseType.FromHUB, 3, 4000, false);
            }
            else
            {
                UseProperties.Init(kinematicBuilder.UseProperties);
            }
            UpdateHudAndCloseStatus();
        }
Exemplo n.º 27
0
        public virtual void Init(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
        {
            Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyPrefabBase.Init");

            StringBuilder displayNameSb = GetDisplayNameSb(displayName);// (displayName == null) ? null : new StringBuilder(displayName);
            //StringBuilder hudLabelTextSb = new StringBuilder(Enum.GetName(typeof(MyModelsEnum), prefabConfig.ModelLod0Enum));

            //TODO: Config.MaterialType 
            //m_prefabTypeEnum = prefabTypeEnum;
            m_prefabId = objectBuilder.GetObjectBuilderId().Value;
            m_config = prefabConfig;

            base.Init(displayNameSb, prefabConfig.ModelLod0Enum, prefabConfig.ModelLod1Enum, GetOwner(), null, objectBuilder, prefabConfig.ModelCollisionEnum);

            m_needsUpdate = m_config.NeedsUpdate;
            if (!string.IsNullOrEmpty(objectBuilder.DisplayName))
            {
                DisplayName = objectBuilder.DisplayName;
            }

            if (HasAvailableFactionMaterial(objectBuilder.FactionAppearance))
            {
                MaterialIndex = (ushort)objectBuilder.FactionAppearance;
            }

            this.LocalMatrix = Matrix.CreateWorld(relativePosition, localOrientation.Forward, localOrientation.Up);
            
            CastShadows = true;
            
            ////This solves bad saved values in DB   //this solves old prefabs max value
            //if (objectBuilder.PrefabMaxHealth == 0 || objectBuilder.PrefabMaxHealth == MyGameplayConstants.MAX_HEALTH_MAX)
            //{
            //    objectBuilder.PrefabMaxHealth = m_gameplayProperties.MaxHealth;
            //}

            ////This solves bad saved values in DB   //this solves old prefabs max value
            //if (objectBuilder.PrefabHealthRatio == 0 || objectBuilder.PrefabHealthRatio == 500 ||
            //    objectBuilder.PrefabHealthRatio == MyGameplayConstants.HEALTH_MAX)
            //{
            //    objectBuilder.PrefabHealthRatio = m_gameplayProperties.MaxHealth;
            //}            

            Flags |= EntityFlags.EditableInEditor;

            //MaxHealth = objectBuilder.PrefabMaxHealth;
            //Health = objectBuilder.PrefabHealthRatio;
            SetMaxHealth(objectBuilder.PrefabMaxHealth);
            HealthRatio = objectBuilder.PrefabHealthRatio;

            ElectricCapacity = objectBuilder.ElectricCapacity;

            if (RequiresEnergy != null && RequiresEnergy.Value == false)
            {   //We dont want these kind of prefabs to be charged every time sector is loaded
                m_electricCapacity = m_config.MaxElectricCapacity;
            }

            m_causesAlarm = objectBuilder.CausesAlarm;
            m_requiresEnergy = objectBuilder.RequiresEnergy;
            AIPriority = objectBuilder.AIPriority;

            if (m_config.InitPhysics)
            {
                InitPhysics();
            }

            SnapPoints = GetSnapPoints(GetModelLod0(), this);
            InitKinematicParts();

            m_smokeMatrices = GetSmokePoints(GetModelLod0());
            m_smokeEffects = new MyParticleEffect[m_smokeMatrices.Length];
            Debug.Assert(m_smokeMatrices != null);
            Debug.Assert(m_smokeEffects != null);

            InitLampsAndLights();
            InitPrefab(displayName, relativePosition, localOrientation, objectBuilder, prefabConfig);
            m_isInitialized = true;
            
            WorkingChanged();
            Render.MyRender.GetRenderProfiler().EndProfilingBlock();
        }
Exemplo n.º 28
0
        protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
        {
            UseProperties = new MyUseProperties(MyUseType.FromHUB | MyUseType.Solo, MyUseType.None);
            if (objectBuilder.UseProperties == null)
            {
                UseProperties.Init(MyUseType.FromHUB | MyUseType.Solo, MyUseType.None, 0, 1, false);
            }
            else
            {
                UseProperties.Init(objectBuilder.UseProperties);
            }

            Enabled = true;
        }
        protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
        {
            MyMwcObjectBuilder_PrefabFoundationFactory objectBuilderFF = objectBuilder as MyMwcObjectBuilder_PrefabFoundationFactory;                        

            IsBuilding = objectBuilderFF.IsBuilding;
            m_buildingTimeFromStart = objectBuilderFF.BuildingTimeFromStart;
            if (objectBuilderFF.BuildingObject != null)
            {
                BuildingObject = MyObjectToBuild.CreateFromObjectBuilder(objectBuilderFF.BuildingObject.ObjectBuilder, objectBuilderFF.BuildingObject.Amount);
            }
            if (objectBuilderFF.BuildingQueue != null)
            {
                foreach (MyMwcObjectBuilder_ObjectToBuild buildingQueue in objectBuilderFF.BuildingQueue)
                {
                    BuildingQueue.Add(MyObjectToBuild.CreateFromObjectBuilder(buildingQueue.ObjectBuilder, buildingQueue.Amount));
                }
            }                                    
        }
Exemplo n.º 30
0
        /// <summary>
        /// IMPORTANT: using Lod1Normals here, since this is done in a separate time to normal rendering
        /// </summary>
        public Texture RenderPrefabPreview(int prefabId, MyPrefabConfiguration config, MyMwcObjectBuilder_Prefab_AppearanceEnum appearance, int width, int height, float lightsIntensity = 2.5f)
        {             
            m_fullSizeRT = MyRender.GetRenderTarget(MyRenderTargets.SSAO);

            if (m_fullSizeRT == null || MyGuiScreenGamePlay.Static == null)
            {
                return null;
            }

            MyFakes.RENDER_PREVIEWS_WITH_CORRECT_ALPHA = true;

            Texture renderTarget = new Texture(MyMinerGame.Static.GraphicsDevice, width, height, 0, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default);

            PrepareRender(width, height);
            MyRender.Sun.Intensity = lightsIntensity;
            foreach (var light in m_setup.LightsToUse)
            {
                light.Intensity = lightsIntensity;
            }

            if (MySession.PlayerShip != null)
            {
                MySession.PlayerShip.Visible = false;
            }

            bool weapon = false;

            if (config.BuildType == BuildTypesEnum.MODULES && config.CategoryType == CategoryTypesEnum.WEAPONRY)
            {
                MyModel baseModel = null;
                MyModel barrelModel = null;
                Matrix baseMatrix = Matrix.Identity;
                Matrix barrelMatrix = Matrix.Identity;

                weapon = MyLargeShipGunBase.GetVisualPreviewData((MyMwcObjectBuilder_PrefabLargeWeapon_TypesEnum)prefabId, ref baseModel, ref barrelModel, ref baseMatrix, ref barrelMatrix);

                if (weapon)
                {
                    m_setup.ViewMatrix = Matrix.Identity;

                    SetupRenderElements(baseModel, baseMatrix, (int) appearance);
                    SetupRenderElements(barrelModel, barrelMatrix, (int)appearance);

                    SetupLights(baseModel);

                    MyRender.PushRenderSetup(m_setup);
                    MyRender.Draw();
                    MyRender.PopRenderSetup();

                    BlitToThumbnail(MyMinerGame.Static.GraphicsDevice, renderTarget);
                }
            }
            
            if (!weapon)
            {
                //load new model from prefab config
                MyModel model = MyModels.GetModelForDraw(config.ModelLod0Enum);

                float distanceMultiplier = 2f;

                Matrix viewMatrix = Matrix.Identity;
                m_setup.ViewMatrix = viewMatrix;

                //generate world matrix
                Matrix worldMatrix = Matrix.Identity;
                worldMatrix.Translation = -model.BoundingSphere.Center;
                
                worldMatrix *= config.PreviewPointOfView.Transform;

                worldMatrix *= Matrix.CreateRotationY(-.85f * MathHelper.PiOver4);
                worldMatrix *= Matrix.CreateRotationX(.35f * MathHelper.PiOver4);
                worldMatrix.Translation += new Vector3(0, 0, -model.BoundingSphere.Radius * distanceMultiplier);

                SetupRenderElements(model, worldMatrix, (int)appearance);

                SetupLights(model);

                //MyGuiManager.TakeScreenshot();
                MyRender.PushRenderSetup(m_setup);
                MyRender.EnableShadows = false;
                MyRender.Draw();
                MyRender.EnableShadows = true;
                MyRender.PopRenderSetup();
                //MyGuiManager.StopTakingScreenshot();

                BlitToThumbnail(MyMinerGame.Static.GraphicsDevice, renderTarget);
            }

            if (MySession.PlayerShip != null)
            {
                MySession.PlayerShip.Visible = true;
            }
            
            MyFakes.RENDER_PREVIEWS_WITH_CORRECT_ALPHA = false;
                               
            return renderTarget;
        }
Exemplo n.º 31
0
        /// <summary>
        /// IMPORTANT: using Lod1Normals here, since this is done in a separate time to normal rendering
        /// </summary>
        public RenderTarget2D RenderPreview(MyMwcObjectBuilder_Prefab_TypesEnum enumValue, MyPrefabConfiguration config, int width, int height)
        {
            m_fullSizeRT = MyRender.GetRenderTarget(MyRenderTargets.Lod1Normals);

            if (m_fullSizeRT == null || MyGuiScreenGamePlay.Static == null)
            {
                return(null);
            }

            m_setup.RenderTargets[0] = new RenderTargetBinding(m_fullSizeRT);

            if (MySession.PlayerShip != null)
            {
                MySession.PlayerShip.Visible = false;
            }

            GraphicsDevice device = MyMinerGame.Static.GraphicsDevice;

            RenderTarget2D renderTarget = new RenderTarget2D(device, width, height, true, SurfaceFormat.Color, DepthFormat.Depth24, 0, RenderTargetUsage.DiscardContents);

            m_setup.RenderElementsToDraw.Clear();
            m_setup.TransparentRenderElementsToDraw.Clear();

            // make actual viewport one pixel larger in order to remove the deformed border caused by antialiasing
            m_setup.Viewport    = new Viewport(0, 0, 2 * renderTarget.Width, 2 * renderTarget.Height);
            m_setup.AspectRatio = 1;
            m_setup.Fov         = MathHelper.ToRadians(70);

            MyRender.Sun.Direction = new Vector3(.5f, -.3f, -1);
            MyRender.Sun.Direction.Normalize();
            MyRender.Sun.Color = Vector4.One;
            MyRender.EnableSun = true;
            float previousSunIntensityMultiplier = MyRender.SunIntensityMultiplier;

            MyRender.SunIntensityMultiplier = 1.2f;

            if (config.BuildType == BuildTypesEnum.MODULES && config.CategoryType == CategoryTypesEnum.WEAPONRY)
            {
                MyModel baseModel    = null;
                MyModel barrelModel  = null;
                Matrix  baseMatrix   = Matrix.Identity;
                Matrix  barrelMatrix = Matrix.Identity;

                bool result = MyLargeShipGunBase.GetVisualPreviewData(enumValue, ref baseModel, ref barrelModel, ref baseMatrix, ref barrelMatrix);

                if (result)
                {
                    m_setup.ViewMatrix = Matrix.Identity;

                    setupRenderElement(baseModel, baseMatrix);
                    setupRenderElement(barrelModel, barrelMatrix);

                    setupLights(baseModel);

                    MyRender.PushRenderSetup(m_setup);
                    MyRender.Draw();
                    MyRender.PopRenderSetup();

                    BlitToThumbnail(device, renderTarget);
                }
            }
            else
            {
                //load new model from prefab config
                MyModel model = MyModels.GetModelForDraw(config.ModelLod0Enum);

                float distance = 1.85f;

                Matrix viewMatrix = Matrix.Identity;
                m_setup.ViewMatrix = viewMatrix;

                //generate world matrix
                Matrix worldMatrix = Matrix.Identity;
                worldMatrix.Translation  = -model.BoundingSphere.Center;
                worldMatrix             *= Matrix.CreateRotationY(-.85f * MathHelper.PiOver4);
                worldMatrix             *= Matrix.CreateRotationX(.35f * MathHelper.PiOver4);
                worldMatrix.Translation += new Vector3(0, 0, -model.BoundingSphere.Radius * distance);

                setupRenderElement(model, worldMatrix);

                setupLights(model);

                MyRender.PushRenderSetup(m_setup);
                MyRender.Draw();
                MyRender.PopRenderSetup();

                BlitToThumbnail(device, renderTarget);
            }

            MyRender.SunIntensityMultiplier = previousSunIntensityMultiplier;

            if (MySession.PlayerShip != null)
            {
                MySession.PlayerShip.Visible = true;
            }

            return(renderTarget);
        }
Exemplo n.º 32
0
        protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
        {
            MyMwcObjectBuilder_PrefabScanner objectBuilderScanner = objectBuilder as MyMwcObjectBuilder_PrefabScanner;

            UseProperties = new MyUseProperties(MyUseType.FromHUB, MyUseType.FromHUB | MyUseType.Solo);
            if (objectBuilderScanner.UseProperties == null)
            {
                UseProperties.Init(MyUseType.FromHUB | MyUseType.Solo, MyUseType.FromHUB | MyUseType.Solo, 3, 4000, false);
            }
            else
            {
                UseProperties.Init(objectBuilderScanner.UseProperties);
            }

            Size          = objectBuilderScanner.Size;
            Color         = objectBuilderScanner.Color;
            ScanningSpeed = objectBuilderScanner.ScanningSpeed;
            InitScanningPart();

            Flags |= EntityFlags.EditableInEditor;
        }
Exemplo n.º 33
0
        protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
        {
            MyMwcObjectBuilder_PrefabAlarm objectBuilderAlarm = objectBuilder as MyMwcObjectBuilder_PrefabAlarm;
            MyPrefabConfigurationAlarm     alarmConfig        = prefabConfig as MyPrefabConfigurationAlarm;

            m_modelLod0On = MyModels.GetModelOnlyData(alarmConfig.ModelLod0EnumOn);
            if (alarmConfig.ModelLod1EnumOn != null)
            {
                m_modelLod1On = MyModels.GetModelOnlyData(alarmConfig.ModelLod1EnumOn.Value);
            }
            m_modelLod0Off = m_modelLod0;
            m_modelLod1Off = m_modelLod1;

            Flags |= EntityFlags.EditableInEditor;
            InitLight();
        }