private bool ToggleStateServer(Vector3?openerPoint, ulong timestamp, bool?fallbackReverse = null) { if (!this.serverLastTimeStamp.HasValue || timestamp > this.serverLastTimeStamp.Value) { if (this.waitsTarget && (this.state == BasicDoor.State.Opening || this.state == BasicDoor.State.Closing)) { return(false); } this.serverLastTimeStamp = new ulong?(timestamp); BasicDoor.State state = this.target; bool flag = this.openingInReverse; if (this.target != BasicDoor.State.Closed) { this.StartOpeningOrClosing(0, timestamp); } else if (!openerPoint.HasValue && fallbackReverse.HasValue) { this.StartOpeningOrClosing(((!fallbackReverse.HasValue ? !this.defaultReversed : !fallbackReverse.Value) ? 1 : 2), timestamp); } else if (this.CalculateOpenWay(openerPoint) != BasicDoor.Side.Forward) { this.StartOpeningOrClosing(2, timestamp); } else { this.StartOpeningOrClosing(1, timestamp); } if (state != this.target || flag != this.openingInReverse) { return(true); } } return(false); }
protected void DOc(sbyte open) { long num; BasicDoor.State state; this.CaptureOriginals(); if ((int)open == 0) { int num1 = 3; state = (BasicDoor.State)num1; this.target = (BasicDoor.State)num1; this.state = state; num = (long)((double)this.durationOpen * 1000); this.DoDoorFraction(0); } else { int num2 = 1; state = (BasicDoor.State)num2; this.target = (BasicDoor.State)num2; this.state = state; num = (long)((double)this.durationOpen * 1000); this.openingInReverse = (int)open == 2; this.DoDoorFraction(1); } ulong num3 = BasicDoor.time; if (num <= num3) { this.timeStampChanged = null; } else { this.timeStampChanged = new ulong?(num3 - num); } }
protected void Awake() { BasicDoor.State state; this.CaptureOriginals(); this.openingInReverse = this.defaultReversed; this.InitializeObstacle(); if (!this.startsOpened) { int num = 3; state = (BasicDoor.State)num; this.state = (BasicDoor.State)num; this.target = state; this.DoDoorFraction(0); } else { int num1 = 1; state = (BasicDoor.State)num1; this.state = (BasicDoor.State)num1; this.target = state; this.DoDoorFraction(1); } base.enabled = false; }
protected void StartOpeningOrClosing(sbyte open, ulong timestamp) { BasicDoor.State state; long num; double num1; double num2; bool flag = this.openingInReverse; if ((int)open == 0) { state = BasicDoor.State.Closed; if (state == this.state || (byte)state == (byte)((byte)this.state + (byte)BasicDoor.State.Opened)) { return; } double num3 = this.elapsed; if ((double)this.durationOpen > 0) { num1 = (num3 < (double)this.durationOpen ? num3 / (double)this.durationOpen : 1); } else { num1 = 1; } double num4 = num1; num = (long)((1 - num4) * (double)this.durationClose * 1000); } else { if (this.state == BasicDoor.State.Closed) { flag = (!this.canOpenReverse ? false : (int)open == 2); } state = BasicDoor.State.Opened; if (state == this.state || (byte)state == (byte)((byte)this.state + (byte)BasicDoor.State.Opened)) { return; } double num5 = this.elapsed; if ((double)this.durationClose > 0) { num2 = (num5 < (double)this.durationClose ? 1 - num5 / (double)this.durationClose : 0); } else { num2 = 0; } num = (long)(num2 * (double)this.durationOpen * 1000); } if (num <= timestamp) { this.timeStampChanged = new ulong?(timestamp - num); } else { this.timeStampChanged = null; } base.enabled = true; this.openingInReverse = flag; this.target = state; }
private void DoorUpdate() { double num = this.elapsed; if (num <= 0) { return; } bool flag = this.state != this.target; switch (this.target) { case BasicDoor.State.Opened: { if (num < (double)this.durationOpen) { if (this.state == BasicDoor.State.Closed) { this.OnDoorStartOpen(); } this.state = BasicDoor.State.Opening; this.DoDoorFraction(num / (double)this.durationOpen); } else { base.enabled = false; this.state = BasicDoor.State.Opened; this.DoDoorFraction(1); if (flag) { this.OnDoorEndOpen(); } } return; } case BasicDoor.State.Closing: { return; } case BasicDoor.State.Closed: { if (num < (double)this.durationClose) { if (this.state == BasicDoor.State.Opened) { this.OnDoorStartClose(); } this.state = BasicDoor.State.Closing; this.DoDoorFraction(1 - num / (double)this.durationClose); } else { base.enabled = false; this.state = BasicDoor.State.Closed; this.DoDoorFraction(0); if (flag) { this.OnDoorEndClose(); } } return; } default: { return; } } }