예제 #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);
        }
예제 #2
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);
     }
 }
예제 #3
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;
        }
예제 #5
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();
        }
예제 #6
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;
        }
예제 #7
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;
        }
예제 #9
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);
            }
        }
예제 #10
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;
     }            
 }
예제 #11
0
 protected override void InitPrefab(string displayName, Vector3 relativePosition, Matrix localOrientation, MyMwcObjectBuilder_PrefabBase objectBuilder, MyPrefabConfiguration prefabConfig)
 {
 }
예제 #12
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();            
        }
예제 #13
0
 public static MyPrefabConfiguration GetPrefabConfiguration(MyMwcObjectBuilder_PrefabBase prefabObjectBuilder)
 {
     return GetPrefabConfiguration(prefabObjectBuilder.GetObjectBuilderType(), prefabObjectBuilder.GetObjectBuilderId().Value);
 }
예제 #14
0
        /// <summary>
        /// CreatePrefab
        /// </summary>
        /// <param name="hudLabelText"></param>
        /// <param name="objBuilder"></param>
        /// <returns></returns>
        public MyPrefabBase CreatePrefab(string hudLabelText, MyPrefabContainer prefabContainer, MyMwcObjectBuilder_PrefabBase prefabBuilder)
        {
            Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyPrefabFactory.CreatePrefab");

            MyPrefabConfiguration config = MyPrefabConstants.GetPrefabConfiguration(prefabBuilder.GetObjectBuilderType(), prefabBuilder.GetObjectBuilderId().Value);
            Vector3 relativePosition = MyPrefabContainer.GetRelativePositionInAbsoluteCoords(prefabBuilder.PositionInContainer);
            Matrix prefabLocalOrientation = Matrix.CreateFromYawPitchRoll(prefabBuilder.AnglesInContainer.X, prefabBuilder.AnglesInContainer.Y, prefabBuilder.AnglesInContainer.Z);

            MyPrefabBase prefab = null;
            if (config is MyPrefabConfigurationKinematic)
            {
                prefab = new MyPrefabKinematic(prefabContainer);                
            }
            else if (config is MyPrefabConfigurationLight)
            {
                prefab = new MyPrefabLight(prefabContainer);                
            }
            else if (config is MyPrefabConfigurationLargeWeapon)
            {
                prefab = new MyPrefabLargeWeapon(prefabContainer);                
            }
            else if (config is MyPrefabConfigurationSound)
            {
                prefab = new MyPrefabSound(prefabContainer);                
            }
            else if (config is MyPrefabConfigurationParticles)
            {
                prefab = new MyPrefabParticles(prefabContainer);                
            }
            else if (config is MyPrefabConfigurationLargeShip)
            {
                prefab = new MyPrefabLargeShip(prefabContainer);                
            }
            else if (config is MyPrefabConfigurationHangar)
            {
                prefab = new MyPrefabHangar(prefabContainer);                
            }
            else if(config is MyPrefabConfigurationFoundationFactory)
            {
                prefab = new MyPrefabFoundationFactory(prefabContainer);                
            }
            else if (config is MyPrefabConfigurationSecurityControlHUB) 
            {
                prefab = new MyPrefabSecurityControlHUB(prefabContainer);                
            }
            else if (config is MyPrefabConfigurationBankNode) 
            {
                prefab = new MyPrefabBankNode(prefabContainer);                
            }
            else if (config is MyPrefabConfigurationGenerator) 
            {
                prefab = new MyPrefabGenerator(prefabContainer);                
            }
            else if (config is MyPrefabConfigurationScanner) 
            {
                prefab = new MyPrefabScanner(prefabContainer);
            }
            else if (config is MyPrefabConfigurationCamera)
            {
                prefab = new MyPrefabCamera(prefabContainer);
            }
            else if (config is MyPrefabConfigurationAlarm)
            {
                prefab = new MyPrefabAlarm(prefabContainer);
            }            
            else
            {
                prefab = new MyPrefab(prefabContainer);
                //prefab.Init(hudLabelText, relativePosition, prefabLocalOrientation, prefabBuilder, config);
            }
            prefab.Init(hudLabelText, relativePosition, prefabLocalOrientation, prefabBuilder, config);

            Render.MyRender.GetRenderProfiler().EndProfilingBlock();

            return prefab;
        }
        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));
                }
            }                                    
        }
예제 #16
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();
        }
예제 #17
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();
        }
예제 #18
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;            
        }