protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            var ob = builder as MyObjectBuilder_AgentDefinition;
            this.BotModel = ob.BotModel;
        }
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            var eventBuilder = builder as MyObjectBuilder_GlobalEventDefinition;

            // This ensures that either both min and max activation time are specified or neither of them is
            if (eventBuilder.MinActivationTimeMs.HasValue && !eventBuilder.MaxActivationTimeMs.HasValue)
            {
                eventBuilder.MaxActivationTimeMs = eventBuilder.MinActivationTimeMs;
            }
            if (eventBuilder.MaxActivationTimeMs.HasValue && !eventBuilder.MinActivationTimeMs.HasValue)
            {
                eventBuilder.MinActivationTimeMs = eventBuilder.MaxActivationTimeMs;
            }

            Debug.Assert(FirstActivationTime.HasValue || eventBuilder.MinActivationTimeMs.HasValue, "Global event definition has to have either the FirstActivationTime or [Min/Max]ActivationTime specified");

            if (eventBuilder.MinActivationTimeMs.HasValue)
                MinActivationTime = TimeSpan.FromTicks(eventBuilder.MinActivationTimeMs.Value * TimeSpan.TicksPerMillisecond);
            if (eventBuilder.MaxActivationTimeMs.HasValue)
                MaxActivationTime = TimeSpan.FromTicks(eventBuilder.MaxActivationTimeMs.Value * TimeSpan.TicksPerMillisecond);
            if (eventBuilder.FirstActivationTimeMs.HasValue)
                FirstActivationTime = TimeSpan.FromTicks(eventBuilder.FirstActivationTimeMs.Value * TimeSpan.TicksPerMillisecond);
        }
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);
            var ob = builder as MyObjectBuilder_OreDetectorDefinition;
	        ResourceSinkGroup = MyStringHash.GetOrCompute(ob.ResourceSinkGroup);
            MaximumRange = ob.MaximumRange;
        }
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            // Backward compatibility with definitions of events that have MyObjectBuilder_GlobalEventDefinition as the TypeId 
            if (builder.Id.TypeId == typeof(MyObjectBuilder_GlobalEventDefinition))
            {
                builder.Id = new VRage.ObjectBuilders.SerializableDefinitionId(typeof(MyObjectBuilder_GlobalEventBase), builder.Id.SubtypeName);
            }

            base.Init(builder);

            var eventBuilder = builder as MyObjectBuilder_GlobalEventDefinition;

            // This ensures that either both min and max activation time are specified or neither of them is
            if (eventBuilder.MinActivationTimeMs.HasValue && !eventBuilder.MaxActivationTimeMs.HasValue)
            {
                eventBuilder.MaxActivationTimeMs = eventBuilder.MinActivationTimeMs;
            }
            if (eventBuilder.MaxActivationTimeMs.HasValue && !eventBuilder.MinActivationTimeMs.HasValue)
            {
                eventBuilder.MinActivationTimeMs = eventBuilder.MaxActivationTimeMs;
            }

            Debug.Assert(eventBuilder.FirstActivationTimeMs.HasValue || eventBuilder.MinActivationTimeMs.HasValue, "Global event definition has to have either the FirstActivationTime or [Min/Max]ActivationTime specified");

            if (eventBuilder.MinActivationTimeMs.HasValue)
                MinActivationTime = TimeSpan.FromTicks(eventBuilder.MinActivationTimeMs.Value * TimeSpan.TicksPerMillisecond);
            if (eventBuilder.MaxActivationTimeMs.HasValue)
                MaxActivationTime = TimeSpan.FromTicks(eventBuilder.MaxActivationTimeMs.Value * TimeSpan.TicksPerMillisecond);
            if (eventBuilder.FirstActivationTimeMs.HasValue)
                FirstActivationTime = TimeSpan.FromTicks(eventBuilder.FirstActivationTimeMs.Value * TimeSpan.TicksPerMillisecond);
        }
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);
            var ob = builder as MyObjectBuilder_VoxelHandDefinition;

            MyDebug.AssertDebug(ob != null);
        }
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            MyDebug.AssertDebug(builder is MyObjectBuilder_ProductionBlockDefinition);
            var obDefinition = builder as MyObjectBuilder_ProductionBlockDefinition;

            this.InventoryMaxVolume = obDefinition.InventoryMaxVolume;
            this.InventorySize = obDefinition.InventorySize;
            this.StandbyPowerConsumption = obDefinition.StandbyPowerConsumption;
            this.OperationalPowerConsumption = obDefinition.OperationalPowerConsumption;

            System.Diagnostics.Debug.Assert(obDefinition.BlueprintClasses != null, "Production block has no blueprint classes specified");
            if (obDefinition.BlueprintClasses == null)
                InitializeLegacyBlueprintClasses(obDefinition);

            BlueprintClasses = new List<MyBlueprintClassDefinition>();
            for (int i = 0; i < obDefinition.BlueprintClasses.Length; ++i)
            {
                var className = obDefinition.BlueprintClasses[i];
                var classDef = MyDefinitionManager.Static.GetBlueprintClass(className);
                System.Diagnostics.Debug.Assert(classDef != null, "Production block references non-existent blueprint class");
                if (classDef == null) continue;

                BlueprintClasses.Add(classDef);
            }
        }
        public void InitLazy(MyObjectBuilder_DefinitionBase baseBuilder)
        {
            var builder = baseBuilder as MyObjectBuilder_PrefabDefinition;

            Debug.Assert(builder.CubeGrid != null || builder.CubeGrids != null, "No cube grids defined in prefab " + PrefabPath);
            if (builder.CubeGrid == null && builder.CubeGrids == null) return;

            // Backwards compatiblity
            if (builder.CubeGrid != null)
                m_cubeGrids = new MyObjectBuilder_CubeGrid[1] { builder.CubeGrid };
            else
                m_cubeGrids = builder.CubeGrids;

            m_boundingSphere = new BoundingSphere(Vector3.Zero, float.MinValue);
            m_boundingBox = BoundingBox.CreateInvalid();
         
            foreach (var grid in m_cubeGrids)
            {
                BoundingBox localBB = grid.CalculateBoundingBox();
                Matrix gridTransform = grid.PositionAndOrientation.HasValue ? (Matrix)grid.PositionAndOrientation.Value.GetMatrix() : Matrix.Identity;
                m_boundingBox.Include(localBB.Transform(gridTransform));
            }

            m_boundingSphere = BoundingSphere.CreateFromBoundingBox(m_boundingBox);

            foreach (var gridBuilder in m_cubeGrids)
            {
                gridBuilder.CreatePhysics = true;
                gridBuilder.XMirroxPlane = null;
                gridBuilder.YMirroxPlane = null;
                gridBuilder.ZMirroxPlane = null;
            }
            
            Initialized = true;
        }
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            var warheadBuilder = (MyObjectBuilder_WarheadDefinition)builder;
            ExplosionRadius = warheadBuilder.ExplosionRadius;
        }
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            m_postprocessBuilder = builder as MyObjectBuilder_ComponentGroupDefinition;
            MyDebug.AssertDebug(m_postprocessBuilder != null);
        }
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            var ob = builder as MyObjectBuilder_EnvironmentItemDefinition;
            MyDebug.AssertDebug(ob != null);
        }
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);
            var ob = builder as MyObjectBuilder_PlanetGeneratorDefinition;

            Diameter = ob.Diameter;
            Deviation = ob.Deviation;
            StructureRatio = ob.StructureRatio;
            NormalNoiseValue = ob.NormalNoiseValue;
            HasAtmosphere = ob.HasAtmosphere;

            HillParams = ob.HillParams;
            CanyonParams = ob.CanyonParams;
            NumLayers = ob.NumLayers;
            HostilityProbability = ob.HostilityProbability;

            SouthPole = ob.SouthPole;
            NorthPole = ob.NorthPole;

            FloraMaterialSpawnProbability = ob.FloraMaterialSpawnProbability;


            OrganicHeightEnd = ob.OrganicHeightEnd;

            MetalsOreProbability =  ob.MetalsOreProbability;

            GravityFalloffPower = ob.GravityFalloffPower;

            HostileAtmosphereColorShift = ob.HostileAtmosphereColorShift;

            MaterialsMaxDeph = ob.MaterialsMaxDeph;
            MaterialsMinDeph = ob.MaterialsMinDeph;
        }
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            MyObjectBuilder_ContainerTypeDefinition definition = builder as MyObjectBuilder_ContainerTypeDefinition;

            CountMin = definition.CountMin;
            CountMax = definition.CountMax;
            ItemsCumulativeFrequency = 0.0f;
            
            int i = 0;
            Items = new ContainerTypeItem[definition.Items.Count()];
            m_itemSelection = new bool[definition.Items.Count()];
            foreach (var itemBuilder in definition.Items)
            {
                ContainerTypeItem item = new ContainerTypeItem();
                item.AmountMax = MyFixedPoint.DeserializeStringSafe(itemBuilder.AmountMax);
                item.AmountMin = MyFixedPoint.DeserializeStringSafe(itemBuilder.AmountMin);
                item.Frequency = Math.Max(itemBuilder.Frequency, 0.0f);
                item.DefinitionId = itemBuilder.Id;

                ItemsCumulativeFrequency += item.Frequency;

                Items[i] = item;
                m_itemSelection[i] = false;
                ++i;
            }

            m_tempCumulativeFreq = ItemsCumulativeFrequency;
        }
 protected override void Init(MyObjectBuilder_DefinitionBase builder)
 {
     base.Init(builder);
     var batteryBlockBuilder = builder as MyObjectBuilder_BatteryBlockDefinition;
     MaxStoredPower = batteryBlockBuilder.MaxStoredPower;
     RequiredPowerInput = batteryBlockBuilder.RequiredPowerInput;
 }
示例#14
0
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            var thrustBuilder = builder as MyObjectBuilder_ThrustDefinition;
            MyDebug.AssertDebug(thrustBuilder != null, "Initializing thrust definition using wrong object builder.");

	        ResourceSinkGroup = MyStringHash.GetOrCompute(thrustBuilder.ResourceSinkGroup);
            FuelConverter = thrustBuilder.FuelConverter;
			SlowdownFactor = thrustBuilder.SlowdownFactor;
            ForceMagnitude = thrustBuilder.ForceMagnitude;
            MaxPowerConsumption = thrustBuilder.MaxPowerConsumption;
            MinPowerConsumption = thrustBuilder.MinPowerConsumption;
            FlameDamageLengthScale = thrustBuilder.FlameDamageLengthScale;
            FlameDamage = thrustBuilder.FlameDamage;
            FlameLengthScale = thrustBuilder.FlameLengthScale;
            FlameFullColor = thrustBuilder.FlameFullColor;
            FlameIdleColor = thrustBuilder.FlameIdleColor;
            FlamePointMaterial = thrustBuilder.FlamePointMaterial;
            FlameLengthMaterial = thrustBuilder.FlameLengthMaterial;
            FlameGlareMaterial = thrustBuilder.FlameGlareMaterial;
            FlameVisibilityDistance = thrustBuilder.FlameVisibilityDistance;
            FlameGlareSize = thrustBuilder.FlameGlareSize;
            FlameGlareQuerySize = thrustBuilder.FlameGlareQuerySize;

            EffectivenessAtMinInfluence = thrustBuilder.EffectivenessAtMinInfluence;
            EffectivenessAtMaxInfluence = thrustBuilder.EffectivenessAtMaxInfluence;
        }
        protected override void Init(MyObjectBuilder_DefinitionBase ob)
        {
            base.Init(ob);

            var builder = ob as MyObjectBuilder_VoxelMaterialDefinition;
            MyDebug.AssertDebug(builder != null);

			this.MaterialTypeName		= builder.MaterialTypeName;
            this.MinedOre               = builder.MinedOre;
            this.MinedOreRatio          = builder.MinedOreRatio;
            this.CanBeHarvested         = builder.CanBeHarvested;
            this.IsRare                 = builder.IsRare;
            this.SpawnsInAsteroids      = builder.SpawnsInAsteroids;
            this.SpawnsFromMeteorites   = builder.SpawnsFromMeteorites;
            this.DamageRatio            = builder.DamageRatio;
            this.DiffuseXZ              = builder.DiffuseXZ;
            this.DiffuseY               = builder.DiffuseY;
            this.NormalXZ               = builder.NormalXZ;
            this.NormalY                = builder.NormalY;
            this.SpecularPower          = builder.SpecularPower;
            this.SpecularShininess      = builder.SpecularShininess;
            this.MinVersion             = builder.MinVersion;
            this.SpawnsFlora            = builder.SpawnsFlora;
            this.BiomeValue = 0;
            SpawnChannels = builder.SpawnChannels;
        }
        protected override void Init(MyObjectBuilder_DefinitionBase ob)
        {
            base.Init(ob);

            MyObjectBuilder_BlueprintDefinition builder = (MyObjectBuilder_BlueprintDefinition)ob;

            Prerequisites = new Item[builder.Prerequisites.Length];
            for (int i = 0; i < Prerequisites.Length; ++i)
            {
                Prerequisites[i] = Item.FromObjectBuilder(builder.Prerequisites[i]);
            }
            if (builder.Result != null)
            {
                Results = new Item[1];
                Results[0] = Item.FromObjectBuilder(builder.Result);
            }
            else
            {
                Results = new Item[builder.Results.Length];
                for (int i = 0; i < Results.Length; ++i)
                {
                    Results[i] = Item.FromObjectBuilder(builder.Results[i]);
                }
            }
            BaseProductionTimeInSeconds = builder.BaseProductionTimeInSeconds;
            PostprocessNeeded = true;
        }
 protected override void Init(MyObjectBuilder_DefinitionBase builder)
 {
     base.Init(builder);
     var cbuilder = builder as MyObjectBuilder_ShipControllerDefinition;
     EnableFirstPerson = cbuilder.EnableFirstPerson;
     EnableShipControl = cbuilder.EnableShipControl;
 }
 protected override void Init(MyObjectBuilder_DefinitionBase builder)
 {
     base.Init(builder);
     var chamberDef = builder as MyObjectBuilder_CryoChamberDefinition;
     OverlayTexture = chamberDef.OverlayTexture;
     IdlePowerConsumption = chamberDef.IdlePowerConsumption;
 }
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            var ob = (MyObjectBuilder_ReflectorBlockDefinition)builder;
            ReflectorTexture = ob.ReflectorTexture;
        }
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            var ob = builder as MyObjectBuilder_EnvironmentItemsDefinition;
            MyDebug.AssertDebug(ob != null);

            m_itemDefinitions = new HashSet<MyStringHash>(MyStringHash.Comparer);
            m_definitionList = new List<MyStringHash>();

            System.Type classType = builder.Id.TypeId;
            var attribs = classType.GetCustomAttributes(typeof(MyEnvironmentItemsAttribute), inherit: false);
            Debug.Assert(attribs.Length <= 1, "Environment item class can only have one EnvironmentItemDefinition attribute!");
            if (attribs.Length == 1)
            {
                var attrib = attribs[0] as MyEnvironmentItemsAttribute;
                m_itemDefinitionType = attrib.ItemDefinitionType;
            }
            else
            {
                m_itemDefinitionType = typeof(MyObjectBuilder_EnvironmentItemDefinition);
            }

            Channel = ob.Channel;
            MaxViewDistance = ob.MaxViewDistance;
            SectorSize = ob.SectorSize;
            ItemSize = ob.ItemSize;
            Material = MyStringHash.GetOrCompute(ob.PhysicalMaterial);
        }
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            var ob = (MyObjectBuilder_MissileLauncherDefinition)builder;
            ProjectileMissile = ob.ProjectileMissile;
        }
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            var ob = builder as MyObjectBuilder_MultiBlockDefinition;
            MyDebug.AssertDebug(ob != null);

            if (ob.BlockDefinitions != null && ob.BlockDefinitions.Length > 0)
            {
                MinPosition = Vector3I.MaxValue;
                MaxPosition = Vector3I.MinValue;

                BlockDefinitions = new MyMultiBlockPartDefinition[ob.BlockDefinitions.Length];
                for (int i = 0; i < ob.BlockDefinitions.Length; ++i)
                {
                    BlockDefinitions[i] = new MyMultiBlockPartDefinition();

                    var obBlockDef = ob.BlockDefinitions[i];
                    BlockDefinitions[i].Id = obBlockDef.Id;
                    BlockDefinitions[i].Position = obBlockDef.Position;
                    BlockDefinitions[i].Forward = obBlockDef.Orientation.Forward;
                    BlockDefinitions[i].Up = obBlockDef.Orientation.Up;

                    MinPosition = Vector3I.Min(MinPosition, obBlockDef.Position);
                    MaxPosition = Vector3I.Max(MaxPosition, obBlockDef.Position);
                }
            }
        }
示例#23
0
 protected override void Init(MyObjectBuilder_DefinitionBase builder)
 {
     base.Init(builder);
     var ob = builder as MyObjectBuilder_AudioEffectDefinition;
     Effect.EffectId = Id.SubtypeId;
     foreach( var soundsEffects in ob.Sounds)
     {
         var soundsEffects2 = new List<MyAudioEffect.SoundEffect>();
         foreach(var effect in soundsEffects.SoundEffects)
         {
             var seff = new MyAudioEffect.SoundEffect();
             MyCurveDefinition def;
             if(!MyDefinitionManager.Static.TryGetDefinition<MyCurveDefinition>(new MyDefinitionId(typeof (MyObjectBuilder_CurveDefinition), effect.VolumeCurve), out def))
             {
                 seff.VolumeCurve = null;
             }
             else
                 seff.VolumeCurve = def.Curve;
             seff.Duration = effect.Duration;
             seff.Filter = effect.Filter;
             seff.Frequency = (float)(2 * Math.Sin(3.14 * effect.Frequency / 44100));
             
             seff.OneOverQ = 1 / effect.Q;
             seff.StopAfter = effect.StopAfter;
             soundsEffects2.Add(seff);
         }
         Effect.SoundsEffects.Add(soundsEffects2);
     }
     if (ob.OutputSound == 0)
         Effect.ResultEmitterIdx = Effect.SoundsEffects.Count - 1;
     else
         Effect.ResultEmitterIdx = ob.OutputSound - 1;
 }
示例#24
0
 protected override void Init(MyObjectBuilder_DefinitionBase baseBuilder)
 {
     base.Init(baseBuilder);
     var builder = baseBuilder as MyObjectBuilder_PrefabDefinition;
     PrefabPath = builder.PrefabPath;
     Initialized = false;
 }
示例#25
0
		protected override void Init(MyObjectBuilder_DefinitionBase builder)
		{
			base.Init(builder);

			var objectBuilder = builder as MyObjectBuilder_GasProperties;

			EnergyDensity = objectBuilder.EnergyDensity;
		}
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            var cargoBuilder = builder as MyObjectBuilder_CargoContainerDefinition;
            MyDebug.AssertDebug(cargoBuilder != null);
            InventorySize = cargoBuilder.InventorySize;
        }
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            var ob = builder as MyObjectBuilder_RespawnShipDefinition;
            Cooldown = ob.CooldownSeconds;
            Prefab = MyDefinitionManager.Static.GetPrefabDefinition(ob.Prefab);
        }
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            MyDebug.AssertDebug(builder is MyObjectBuilder_AssemblerDefinition);
            var obRefineryDef = builder as MyObjectBuilder_AssemblerDefinition;
            m_assemblySpeed = obRefineryDef.AssemblySpeed;
        }
        protected override void Init(MyObjectBuilder_DefinitionBase builder)
        {
            base.Init(builder);

            var ob = builder as MyObjectBuilder_AiCommandBehaviorDefinition;
            BehaviorTreeName = ob.BehaviorTreeName;
            CommandEffect = ob.CommandEffect;
        }
 protected override void Init(MyObjectBuilder_DefinitionBase builder)
 {
     base.Init(builder);
     var cbuilder = builder as MyObjectBuilder_ShipDrillDefinition;
     SensorRadius = cbuilder.SensorRadius;
     SensorOffset = cbuilder.SensorOffset;
     DeformationRatio = 0.5f;
 }