コード例 #1
0
        public override void Init(MyObjectBuilder_CubeBlock builder, MyCubeGrid cubeGrid)
        {
            base.ResourceSink = new MyResourceSinkComponent(1);
            base.ResourceSink.Init(MyStringHash.GetOrCompute(this.BlockDefinition.ResourceSinkGroup), this.BlockDefinition.PowerConsumptionMoving, new Func <float>(this.UpdatePowerInput));
            base.Init(builder, cubeGrid);
            base.NeedsWorldMatrix = false;
            MyObjectBuilder_AirtightDoorGeneric generic = (MyObjectBuilder_AirtightDoorGeneric)builder;

            base.m_open.SetLocalValue(generic.Open);
            this.m_currOpening             = MathHelper.Clamp(generic.CurrOpening, 0f, 1f);
            this.m_openingSpeed            = this.BlockDefinition.OpeningSpeed;
            this.m_sound                   = new MySoundPair(this.BlockDefinition.Sound, true);
            this.m_openSound               = new MySoundPair(this.BlockDefinition.OpenSound, true);
            this.m_closeSound              = new MySoundPair(this.BlockDefinition.CloseSound, true);
            this.m_subpartMovementDistance = this.BlockDefinition.SubpartMovementDistance;
            if (!base.Enabled || !base.ResourceSink.IsPoweredByType(MyResourceDistributorComponent.ElectricityId))
            {
                this.UpdateDoorPosition();
            }
            this.OnStateChange();
            base.ResourceSink.IsPoweredChanged += new Action(this.Receiver_IsPoweredChanged);
            base.ResourceSink.Update();
            base.SlimBlock.ComponentStack.IsFunctionalChanged += new Action(this.ComponentStack_IsFunctionalChanged);
            base.ResourceSink.Update();
            if (!Sync.IsServer)
            {
                base.NeedsWorldMatrix = true;
            }
        }
コード例 #2
0
        public override MyObjectBuilder_CubeBlock GetObjectBuilderCubeBlock(bool copy = false)
        {
            MyObjectBuilder_AirtightDoorGeneric objectBuilderCubeBlock = (MyObjectBuilder_AirtightDoorGeneric)base.GetObjectBuilderCubeBlock(copy);

            objectBuilderCubeBlock.Open        = (bool)base.m_open;
            objectBuilderCubeBlock.CurrOpening = this.m_currOpening;
            return(objectBuilderCubeBlock);
        }