当前位置: 首页>>代码示例>>C#>>正文


C# ObjectBuilders.MyObjectBuilder_CubeBlock类代码示例

本文整理汇总了C#中Sandbox.Common.ObjectBuilders.MyObjectBuilder_CubeBlock的典型用法代码示例。如果您正苦于以下问题:C# MyObjectBuilder_CubeBlock类的具体用法?C# MyObjectBuilder_CubeBlock怎么用?C# MyObjectBuilder_CubeBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MyObjectBuilder_CubeBlock类属于Sandbox.Common.ObjectBuilders命名空间,在下文中一共展示了MyObjectBuilder_CubeBlock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            base.Init(objectBuilder, cubeGrid);

            m_cargoDefinition = (MyCargoContainerDefinition)MyDefinitionManager.Static.GetCubeBlockDefinition(objectBuilder.GetId());
            var cargoBuilder = (MyObjectBuilder_CargoContainer)objectBuilder;
            m_containerType = cargoBuilder.ContainerType;

            if (!Components.Has<MyInventoryBase>())
            {
                m_inventory = new MyInventory(m_cargoDefinition.InventorySize.Volume, m_cargoDefinition.InventorySize, MyInventoryFlags.CanSend | MyInventoryFlags.CanReceive, this);
				if(MyFakes.ENABLE_MEDIEVAL_INVENTORY)
					Components.Add<MyInventoryBase>(m_inventory);

                if (m_containerType != null && MyFakes.RANDOM_CARGO_PLACEMENT && (cargoBuilder.Inventory == null || cargoBuilder.Inventory.Items.Count == 0))
                    SpawnRandomCargo();
                else
                    m_inventory.Init(cargoBuilder.Inventory);
            }
            else
            {
                m_inventory = Components.Get<MyInventoryBase>() as MyInventory;
				Debug.Assert(m_inventory != null);
                //m_inventory.Owner = this;
            }

            if(MyPerGameSettings.InventoryMass)
                m_inventory.ContentsChanged += Inventory_ContentsChanged;

            m_conveyorEndpoint = new MyMultilineConveyorEndpoint(this);
            AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawConveyorEndpoint(m_conveyorEndpoint));
            UpdateIsWorking();
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:33,代码来源:MyCargoContainer.cs

示例2: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            base.Init(objectBuilder, cubeGrid);

            PowerReceiver = new MyPowerReceiver(
                MyConsumerGroupEnum.Utility,
                false,
                BlockDefinition.RequiredPowerInput,
                this.CalculateRequiredPowerInput);
            PowerReceiver.IsPoweredChanged += Receiver_IsPoweredChanged;
            PowerReceiver.Update();

            if (Physics != null)
            {
                Physics.Close();
            }

            var detectorShape = new HkBoxShape(new Vector3(cubeGrid.GridSize / 3.0f));
            var massProperties = HkInertiaTensorComputer.ComputeBoxVolumeMassProperties(detectorShape.HalfExtents, BlockDefinition.VirtualMass);
            Physics = new Engine.Physics.MyPhysicsBody(this, RigidBodyFlag.RBF_DEFAULT);
            Physics.IsPhantom = false;
            Physics.CreateFromCollisionObject(detectorShape, Vector3.Zero, WorldMatrix, massProperties, MyPhysics.VirtualMassLayer);
            Physics.Enabled = IsWorking && cubeGrid.Physics != null && cubeGrid.Physics.Enabled;
            Physics.RigidBody.Activate();
            detectorShape.Base.RemoveReference();

            UpdateText();

            NeedsUpdate = MyEntityUpdateEnum.EACH_FRAME;

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;

        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:33,代码来源:MyVirtualMass.cs

示例3: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            m_cameraDummy = Matrix.Identity;
            m_characterDummy = Matrix.Identity;

            base.Init(objectBuilder, cubeGrid);

            var chamberOb = objectBuilder as MyObjectBuilder_CryoChamber;

            if (chamberOb.SteamId != null && chamberOb.SerialId != null)
            {
                m_currentPlayerId = new MyPlayer.PlayerId(chamberOb.SteamId.Value, chamberOb.SerialId.Value);
            }
            else
            {
                m_currentPlayerId = null;
            }

            var overlayTexture = BlockDefinition.OverlayTexture;
            if (!string.IsNullOrEmpty(overlayTexture))
            {
                m_overlayTextureName = overlayTexture;
            }

            var sinkComp = new MyResourceSinkComponent();
			sinkComp.Init(
                MyStringHash.GetOrCompute(BlockDefinition.ResourceSinkGroup),
                BlockDefinition.IdlePowerConsumption,
                this.CalculateRequiredPowerInput);
            sinkComp.IsPoweredChanged += Receiver_IsPoweredChanged;
	        ResourceSink = sinkComp;

            NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:34,代码来源:MyCryoChamber.cs

示例4: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            m_cameraDummy = Matrix.Identity;
            m_characterDummy = Matrix.Identity;

            base.Init(objectBuilder, cubeGrid);

            var chamberOb = objectBuilder as MyObjectBuilder_CryoChamber;

            if (chamberOb.SteamId != null && chamberOb.SerialId != null)
            {
                m_currentPlayerId = new MyPlayer.PlayerId(chamberOb.SteamId.Value, chamberOb.SerialId.Value);
            }
            else
            {
                m_currentPlayerId = null;
            }

            var overlayTexture = BlockDefinition.OverlayTexture;
            if (!string.IsNullOrEmpty(overlayTexture))
            {
                m_overlayTextureName = overlayTexture;
            }

            PowerReceiver = new MyPowerReceiver(
                MyConsumerGroupEnum.Utility,
                false,
                BlockDefinition.IdlePowerConsumption,
                this.CalculateRequiredPowerInput);
            PowerReceiver.IsPoweredChanged += Receiver_IsPoweredChanged;

            NeedsUpdate |= Common.MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:33,代码来源:MyCryoChamber.cs

示例5: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            base.Init(objectBuilder, cubeGrid);
            var def = BlockDefinition as MyPoweredCargoContainerDefinition;
            var ob = objectBuilder as MyObjectBuilder_Collector;
            m_inventory = new MyInventory(def.InventorySize.Volume, def.InventorySize, MyInventoryFlags.CanSend, this);
            m_inventory.Init(ob.Inventory);
            m_inventory.ContentsChanged += Inventory_ContentChangedCallback;
            if (Sync.IsServer && CubeGrid.CreatePhysics)
                LoadDummies();

			var sinkComp = new MyResourceSinkComponent();
            sinkComp.Init(
                MyStringHash.GetOrCompute(def.ResourceSinkGroup),
                MyEnergyConstants.MAX_REQUIRED_POWER_COLLECTOR,
                () => base.CheckIsWorking() ? ResourceSink.MaxRequiredInput : 0f);
	        ResourceSink = sinkComp;
			ResourceSink.Update();
			ResourceSink.IsPoweredChanged += Receiver_IsPoweredChanged;
            AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawPowerReciever(ResourceSink,this));

            SlimBlock.ComponentStack.IsFunctionalChanged += UpdateReceiver;
            base.EnabledChanged += UpdateReceiver;

            m_useConveyorSystem = ob.UseConveyorSystem;
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:26,代码来源:MyCollector.cs

示例6: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            base.Init(objectBuilder, cubeGrid);

            MyDebug.AssertDebug(BlockDefinition is MyRefineryDefinition);
            m_refineryDef = BlockDefinition as MyRefineryDefinition;

            InputInventory.Constraint = m_refineryDef.InputInventoryConstraint;
            bool removed = InputInventory.FilterItemsUsingConstraint();
            Debug.Assert(!removed, "Inventory filter removed items which were present in the object builder.");
            InputInventory.ContentsChanged += inventory_OnContentsChanged;

            OutputInventory.Constraint = m_refineryDef.OutputInventoryConstraint;
            removed = OutputInventory.FilterItemsUsingConstraint();
            Debug.Assert(!removed, "Inventory filter removed items which were present in the object builder.");
            OutputInventory.ContentsChanged += inventory_OnContentsChanged;

            m_queueNeedsRebuild = true;

            UpgradeValues.Add("Productivity", 0f);
            UpgradeValues.Add("Effectiveness", 1f);
            UpgradeValues.Add("PowerEfficiency", 1f);

            PowerReceiver.RequiredInputChanged += PowerReceiver_RequiredInputChanged;
            OnUpgradeValuesChanged += UpdateDetailedInfo;

            UpdateDetailedInfo();
        }
开发者ID:caomw,项目名称:SpaceEngineers,代码行数:28,代码来源:MyRefinery.cs

示例7: Init

 public override void Init(MyObjectBuilder_CubeBlock builder, MyCubeGrid cubeGrid)
 {
     base.Init(builder, cubeGrid);
     this.NeedsUpdate = MyEntityUpdateEnum.EACH_100TH_FRAME;
     m_emissivitySet = false;
     AddDebugRenderComponent(new Components.MyDebugRenderComponentDrawConveyorSegment(m_segment));
 }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:7,代码来源:MyConveyorConnector.cs

示例8: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {             
            base.Init(objectBuilder, cubeGrid);

            MyDebug.AssertDebug(BlockDefinition.Id.TypeId == typeof(MyObjectBuilder_Reactor));
            m_reactorDefinition = BlockDefinition as MyReactorDefinition;
            MyDebug.AssertDebug(m_reactorDefinition != null);

            CurrentPowerOutput = 0;
            m_inventory = new MyInventory(m_reactorDefinition.InventoryMaxVolume, m_reactorDefinition.InventorySize, MyInventoryFlags.CanReceive, this);

            var obGenerator = (MyObjectBuilder_Reactor)objectBuilder;
            m_inventory.Init(obGenerator.Inventory);
            m_inventory.ContentsChanged += inventory_ContentsChanged;
            m_inventory.Constraint = m_reactorDefinition.InventoryConstraint;
            RefreshRemainingCapacity();

            UpdateText();

            SlimBlock.ComponentStack.IsFunctionalChanged += ComponentStack_IsFunctionalChanged;

            NeedsUpdate |= MyEntityUpdateEnum.EACH_100TH_FRAME;
            //if (MyFakes.SHOW_DAMAGE_EFFECTS && IsWorking)
            //    NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME;

            m_baseIdleSound = BlockDefinition.PrimarySound;

            m_useConveyorSystem = obGenerator.UseConveyorSystem;

            if (IsWorking)
                OnStartWorking();
        }
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:32,代码来源:MyReactor.cs

示例9: Init

        public override void Init(MyObjectBuilder_CubeBlock builder, MyCubeGrid cubeGrid)
        {
            var rotorOb = builder as MyObjectBuilder_MotorRotor;

            base.Init(builder, cubeGrid);

            LoadDummies();
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:8,代码来源:MyMotorRotor.cs

示例10: Init

        public override void Init(MyObjectBuilder_CubeBlock builder, MyCubeGrid cubeGrid)
        {
            base.Init(builder, cubeGrid);

            var ob = builder as MyObjectBuilder_PistonTop;
            m_pistonBlockId = ob.PistonBlockId;
            NeedsUpdate |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
        }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:8,代码来源:MyPistonTop.cs

示例11: CreateCubeBlock

 public static object CreateCubeBlock(MyObjectBuilder_CubeBlock builder)
 {
     var obj = m_objectFactory.CreateInstance(builder.TypeId);
     MyEntity entity = obj as MyEntity;
     var scriptManager = Sandbox.Game.World.MyScriptManager.Static;
     if (entity != null && scriptManager != null && scriptManager.EntityScripts.ContainsKey(builder.TypeId))
         entity.GameLogic = (Sandbox.Common.Components.MyGameLogicComponent)Activator.CreateInstance(scriptManager.EntityScripts[builder.TypeId]);
     return obj;
 }
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:9,代码来源:MyCubeBlockFactory.cs

示例12: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            base.Init(objectBuilder, cubeGrid);

            var ob = (MyObjectBuilder_FunctionalBlock)objectBuilder;

            m_enabled = ob.Enabled;
            IsWorkingChanged += CubeBlock_IsWorkingChanged;
        }
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:9,代码来源:MyFunctionalBlock.cs

示例13: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            base.Init(objectBuilder, cubeGrid);

            var ob = objectBuilder as MyObjectBuilder_CompoundCubeBlock;

            if (ob.Blocks != null)
            {
                if (ob.BlockIds != null)
                {
                    Debug.Assert(ob.Blocks.Length == ob.BlockIds.Length);

                    for (int i = 0; i < ob.Blocks.Length; ++i)
                    {
                        ushort id = ob.BlockIds[i];
                        if (m_blocks.ContainsKey(id))
                        {
                            Debug.Fail("Block with the same id found");
                            continue;
                        }

                        var blockBuilder = ob.Blocks[i];
                        object objectBlock = MyCubeBlockFactory.CreateCubeBlock(blockBuilder);
                        MySlimBlock cubeBlock = objectBlock as MySlimBlock;
                        if (cubeBlock == null)
                            cubeBlock = new MySlimBlock();

                        cubeBlock.Init(blockBuilder, cubeGrid, objectBlock as MyCubeBlock);

                        cubeBlock.FatBlock.Hierarchy.Parent = Hierarchy;
                        m_blocks.Add(id, cubeBlock);
                    }

                    RefreshNextId();
                }
                else
                {
                    for (int i = 0; i < ob.Blocks.Length; ++i)
                    {
                        var blockBuilder = ob.Blocks[i];
                        object objectBlock = MyCubeBlockFactory.CreateCubeBlock(blockBuilder);
                        MySlimBlock cubeBlock = objectBlock as MySlimBlock;
                        if (cubeBlock == null)
                            cubeBlock = new MySlimBlock();

                        cubeBlock.Init(blockBuilder, cubeGrid, objectBlock as MyCubeBlock);

                        cubeBlock.FatBlock.Hierarchy.Parent = Hierarchy;
                        ushort id = CreateId(cubeBlock);
                        m_blocks.Add(id, cubeBlock);
                    }
                }
             }

            RefreshTemplates();
        }
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:56,代码来源:MyCompoundCubeBlock.cs

示例14: Init

 public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
 {
     base.Init(objectBuilder, cubeGrid);
     if (CubeGrid.GridSizeEnum == MyCubeSize.Large)
     {
         IDLE_SOUND.Init("ToolLrgGrindIdle");
         METAL_SOUND.Init("ToolLrgGrindMetal");
     }
     m_rotationSpeed = 0.0f;
 }
开发者ID:austusross,项目名称:SpaceEngineers,代码行数:10,代码来源:MyShipGrinder.cs

示例15: Init

        public override void Init(MyObjectBuilder_CubeBlock objectBuilder, MyCubeGrid cubeGrid)
        {
            SyncFlag = true;

            base.Init(objectBuilder, cubeGrid);

            m_missingComponents = new Dictionary<string, int>();

            var builder = (MyObjectBuilder_ShipWelder)objectBuilder;
            m_helpOthers = builder.HelpOthers;
        }
开发者ID:notten,项目名称:SpaceEngineers,代码行数:11,代码来源:MyShipWelder.cs


注:本文中的Sandbox.Common.ObjectBuilders.MyObjectBuilder_CubeBlock类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。