Esempio n. 1
0
        public virtual void Init(string storageName, Sandbox.Engine.Voxels.IMyStorage storage, MatrixD worldMatrix)
        {
            ProfilerShort.Begin("MyVoxelBase::Init");
            SyncFlag = true;

            base.Init(null);

            StorageName = storageName;
            m_storage   = storage;

            CreateStorageCopyOnWrite = m_storage.Shared;

            InitVoxelMap(worldMatrix, storage.Size);

            ProfilerShort.End();
        }
Esempio n. 2
0
        public virtual void Init(string storageName, Sandbox.Engine.Voxels.IMyStorage storage, MatrixD worldMatrix)
        {
            ProfilerShort.Begin("MyVoxelBase::Init");
            SyncFlag = true;

            // Planet initalization needs to be re-done basically so issues like this don't exist anymore
            if (Name == null)
            {
                base.Init(null);
            }

            StorageName = storageName;
            m_storage   = storage;

            CreateStorageCopyOnWrite = m_storage.Shared;

            InitVoxelMap(worldMatrix, storage.Size);

            ProfilerShort.End();
        }
Esempio n. 3
0
        public override void Init(MyObjectBuilder_EntityBase builder, Sandbox.Engine.Voxels.IMyStorage storage)
        {
            ProfilerShort.Begin("MyPlanet::Init()");
            if (MyFakes.ENABLE_PLANETS == false)
            {
                throw new PlanetsNotEnabledException();
            }

            ProfilerShort.Begin("MyVoxelBase Init");

            SyncFlag = true;

            base.Init(builder);

            ProfilerShort.BeginNextBlock("Load Saved Data");

            var ob = (MyObjectBuilder_Planet)builder;

            if (ob == null)
            {
                return;
            }

            MyLog.Default.WriteLine("Planet init info - MutableStorage:" + ob.MutableStorage + " StorageName:" + ob.StorageName + " storage?:" + (storage != null).ToString());

            if (ob.MutableStorage)
            {
                StorageName = ob.StorageName;
            }
            else
            {
                StorageName = string.Format("{0}", ob.StorageName);
            }

            m_planetInitValues.StorageName           = StorageName;
            m_planetInitValues.PositionMinCorner     = ob.PositionAndOrientation.Value.Position;
            m_planetInitValues.HasAtmosphere         = ob.HasAtmosphere;
            m_planetInitValues.AtmosphereRadius      = ob.AtmosphereRadius;
            m_planetInitValues.AtmosphereWavelengths = ob.AtmosphereWavelengths;
            m_planetInitValues.GravityFalloff        = ob.GravityFalloff;
            m_planetInitValues.MarkAreaEmpty         = ob.MarkAreaEmpty;
            m_planetInitValues.SurfaceGravity        = ob.SurfaceGravity;
            m_planetInitValues.AddGps = ob.ShowGPS;
            m_planetInitValues.SpherizeWithDistance = ob.SpherizeWithDistance;
            m_planetInitValues.Generator            = ob.PlanetGenerator == ""
                ? null
                : MyDefinitionManager.Static.GetDefinition <MyPlanetGeneratorDefinition>(
                MyStringHash.GetOrCompute(ob.PlanetGenerator));
            if (m_planetInitValues.Generator == null)
            {
                string message = string.Format("No definition found for planet generator {0}.", ob.PlanetGenerator);
                MyLog.Default.WriteLine(message);
                throw new MyIncompatibleDataException(message);
            }

            m_planetInitValues.AtmosphereSettings = m_planetInitValues.Generator.AtmosphereSettings.HasValue
                ? m_planetInitValues.Generator.AtmosphereSettings.Value
                : MyAtmosphereSettings.Defaults();
            m_planetInitValues.UserCreated = false;

            ProfilerShort.BeginNextBlock("Load Storage");
            if (storage != null)
            {
                m_planetInitValues.Storage = storage;
            }
            else
            {
                m_planetInitValues.Storage = MyStorageBase.Load(ob.StorageName);

                if (m_planetInitValues.Storage == null)
                {
                    string message = string.Format("No storage loaded for planet {0}.", ob.StorageName);
                    MyLog.Default.WriteLine(message);
                    throw new MyIncompatibleDataException(message);
                }
            }

            m_planetInitValues.InitializeComponents = false;

            ProfilerShort.BeginNextBlock("Init Internal");

            // MZ: if any crashes are related to MP planet init in the future, i added logging of MyPlanetInitArguments and other sanity checks.
            //     we are currently having crashes without this additional info and it is likely that even after my hotfixes it is going to crash again
            //     ...but we can check the logs and know the setup of the player :)
            MyLog.Default.Log(MyLogSeverity.Info, "Planet generator name: {0}", ob.PlanetGenerator ?? "<null>");

            // Initialize!
            Init(m_planetInitValues);

            ProfilerShort.End();

            ProfilerShort.End();
        }
Esempio n. 4
0
        public override void Init(MyObjectBuilder_EntityBase builder, Sandbox.Engine.Voxels.IMyStorage storage)
        {
            ProfilerShort.Begin("MyPlanet::Init()");
            if (MyFakes.ENABLE_PLANETS == false)
            {
                throw new PlanetsNotEnabledException();
            }

            ProfilerShort.Begin("MyVoxelBase Init");

            SyncFlag = true;

            base.Init(builder);

            ProfilerShort.BeginNextBlock("Load Saved Data");

            var ob = (MyObjectBuilder_Planet)builder;

            if (ob == null)
            {
                return;
            }

            if (ob.MutableStorage)
            {
                StorageName = ob.StorageName;
            }
            else
            {
                StorageName = string.Format("{0}", ob.StorageName);
            }

            m_planetInitValues.StorageName           = StorageName;
            m_planetInitValues.PositionMinCorner     = ob.PositionAndOrientation.Value.Position;
            m_planetInitValues.HasAtmosphere         = ob.HasAtmosphere;
            m_planetInitValues.AtmosphereRadius      = ob.AtmosphereRadius;
            m_planetInitValues.AtmosphereWavelengths = ob.AtmosphereWavelengths;
            m_planetInitValues.GravityFalloff        = ob.GravityFalloff;
            m_planetInitValues.MarkAreaEmpty         = ob.MarkAreaEmpty;
            m_planetInitValues.SurfaceGravity        = ob.SurfaceGravity;
            m_planetInitValues.AddGps = ob.ShowGPS;
            m_planetInitValues.SpherizeWithDistance = ob.SpherizeWithDistance;
            m_planetInitValues.Generator            = ob.PlanetGenerator == "" ? null : MyDefinitionManager.Static.GetDefinition <MyPlanetGeneratorDefinition>(MyStringHash.GetOrCompute(ob.PlanetGenerator));
            if (m_planetInitValues.Generator == null)
            {
                string message = string.Format("No definition found for planet generator {0}.", ob.PlanetGenerator);
                MyLog.Default.WriteLine(message);
                throw new Exception(message);
            }

            m_planetInitValues.AtmosphereSettings = m_planetInitValues.Generator.AtmosphereSettings.HasValue ? m_planetInitValues.Generator.AtmosphereSettings.Value : MyAtmosphereSettings.Defaults();
            m_planetInitValues.UserCreated        = false;

            ProfilerShort.BeginNextBlock("Load Storage");
            if (storage != null)
            {
                m_planetInitValues.Storage = storage;
            }
            else
            {
                m_planetInitValues.Storage = MyStorageBase.Load(ob.StorageName);
            }

            ProfilerShort.BeginNextBlock("Init Internal");
            Init(m_planetInitValues);
            ProfilerShort.End();

            ProfilerShort.End();
        }
Esempio n. 5
0
        public void Init(string storageName, Sandbox.Engine.Voxels.IMyStorage storage, Vector3D positionMinCorner)
        {
            MatrixD worldMatrix = MatrixD.CreateTranslation(positionMinCorner + storage.Size / 2);

            Init(storageName, storage, worldMatrix);
        }
Esempio n. 6
0
 abstract public void Init(MyObjectBuilder_EntityBase builder, Sandbox.Engine.Voxels.IMyStorage storage);
Esempio n. 7
0
        public virtual void Init(string storageName, Sandbox.Engine.Voxels.IMyStorage storage, MatrixD worldMatrix)
        {
            ProfilerShort.Begin("MyVoxelBase::Init");
            SyncFlag = true;

            // Planet initalization needs to be re-done basically so issues like this don't exist anymore
            if (Name == null)
            base.Init(null);

            StorageName = storageName;
            m_storage = storage;

            CreateStorageCopyOnWrite = m_storage.Shared;

            InitVoxelMap(worldMatrix, storage.Size);

            ProfilerShort.End();
        }
Esempio n. 8
0
        public virtual void Init(string storageName, Sandbox.Engine.Voxels.IMyStorage storage, MatrixD worldMatrix)
        {
            ProfilerShort.Begin("MyVoxelBase::Init");
            SyncFlag = true;

            base.Init(null);

            StorageName = storageName;
            m_storage = storage;

            CreateStorageCopyOnWrite = m_storage.Shared;

            InitVoxelMap(worldMatrix, storage.Size);

            ProfilerShort.End();
        }