예제 #1
0
        public override MyObjectBuilder_CubeBlock GetObjectBuilderCubeBlock(bool copy = false)
        {
            MyObjectBuilder_Door objectBuilderCubeBlock = (MyObjectBuilder_Door)base.GetObjectBuilderCubeBlock(copy);

            objectBuilderCubeBlock.State      = base.Open;
            objectBuilderCubeBlock.Opening    = this.m_currOpening;
            objectBuilderCubeBlock.OpenSound  = this.m_openSound.ToString();
            objectBuilderCubeBlock.CloseSound = this.m_closeSound.ToString();
            return(objectBuilderCubeBlock);
        }
예제 #2
0
 public DoorEntity(CubeGridEntity parent, MyObjectBuilder_Door definition, Object backingObject)
     : base(parent, definition, backingObject)
 {
     m_state = definition.State;
 }
예제 #3
0
        public override void Init(MyObjectBuilder_CubeBlock builder, MyCubeGrid cubeGrid)
        {
            MyStringHash orCompute;

            this.m_physicsInitiated = false;
            MyDoorDefinition blockDefinition = base.BlockDefinition as MyDoorDefinition;

            if (blockDefinition != null)
            {
                this.MaxOpen        = blockDefinition.MaxOpen;
                this.m_openSound    = new MySoundPair(blockDefinition.OpenSound, true);
                this.m_closeSound   = new MySoundPair(blockDefinition.CloseSound, true);
                orCompute           = MyStringHash.GetOrCompute(blockDefinition.ResourceSinkGroup);
                this.m_openingSpeed = blockDefinition.OpeningSpeed;
            }
            else
            {
                this.MaxOpen        = 1.2f;
                this.m_openSound    = new MySoundPair("BlockDoorSmallOpen", true);
                this.m_closeSound   = new MySoundPair("BlockDoorSmallClose", true);
                orCompute           = MyStringHash.GetOrCompute("Doors");
                this.m_openingSpeed = 1f;
            }
            MyResourceSinkComponent sinkComp = new MyResourceSinkComponent(1);

            sinkComp.Init(orCompute, 3E-05f, delegate {
                if (!this.Enabled || !this.IsFunctional)
                {
                    return(0f);
                }
                return(sinkComp.MaxRequiredInputByType(MyResourceDistributorComponent.ElectricityId));
            });
            sinkComp.IsPoweredChanged += new Action(this.Receiver_IsPoweredChanged);
            base.ResourceSink          = sinkComp;
            base.Init(builder, cubeGrid);
            base.NeedsWorldMatrix = false;
            MyObjectBuilder_Door door = (MyObjectBuilder_Door)builder;

            base.m_open.SetLocalValue(door.State);
            if (door.Opening != -1f)
            {
                this.m_currOpening = MathHelper.Clamp(door.Opening, 0f, this.MaxOpen);
            }
            else
            {
                this.m_currOpening = base.IsFunctional ? 0f : this.MaxOpen;
                base.m_open.SetLocalValue(!base.IsFunctional);
            }
            if (!base.Enabled || !base.ResourceSink.IsPoweredByType(MyResourceDistributorComponent.ElectricityId))
            {
                this.UpdateSlidingDoorsPosition();
            }
            this.OnStateChange();
            if (((base.m_open != null) && base.Open) && (this.m_currOpening == this.MaxOpen))
            {
                this.UpdateSlidingDoorsPosition();
            }
            sinkComp.Update();
            base.SlimBlock.ComponentStack.IsFunctionalChanged += new Action(this.ComponentStack_IsFunctionalChanged);
            if (!Sync.IsServer)
            {
                base.NeedsWorldMatrix = true;
            }
        }
예제 #4
0
 public DoorEntity(CubeGridEntity parent, MyObjectBuilder_Door definition)
     : base(parent, definition)
 {
 }