道岔失表状态
This commit is contained in:
parent
971929e867
commit
07174d8fc8
@ -327,6 +327,12 @@ export class TurnoutStates extends GraphicStateBase implements ITurnoutState {
|
||||
set turning(turning: boolean) {
|
||||
this.states.turning = turning;
|
||||
}
|
||||
get split(): boolean {
|
||||
return this.states.split;
|
||||
}
|
||||
set split(split: boolean) {
|
||||
this.states.split = split;
|
||||
}
|
||||
get states(): state.SwitchState {
|
||||
return this.getState<state.SwitchState>();
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ export interface ITurnoutState extends GraphicState {
|
||||
normal?: boolean;
|
||||
reverse?: boolean;
|
||||
turning?: boolean;
|
||||
split?: boolean;
|
||||
}
|
||||
|
||||
export const TurnoutConsts = {
|
||||
@ -208,18 +209,18 @@ export class Turnout extends JlGraphic {
|
||||
this.graphics.sections.forEach((sectionGraphic) => sectionGraphic.paint());
|
||||
|
||||
this.graphics.label.text = this.datas.code;
|
||||
if (this.states.turning) {
|
||||
this.initTurnoutTurning();
|
||||
if (this.states.split) {
|
||||
this.initTurnoutSplit();
|
||||
} else {
|
||||
this.stopTurnoutTurning();
|
||||
this.stopTurnoutSplit();
|
||||
}
|
||||
}
|
||||
initTurnoutTurning() {
|
||||
// 道岔转动
|
||||
const name = `${this.datas.id}_turnout_turning`;
|
||||
let turnoutTurning = this.animation(name);
|
||||
if (!turnoutTurning) {
|
||||
turnoutTurning = GraphicAnimation.init({
|
||||
initTurnoutSplit() {
|
||||
// 道岔失表
|
||||
const name = `${this.datas.id}_turnout_split`;
|
||||
let turnoutSplit = this.animation(name);
|
||||
if (!turnoutSplit) {
|
||||
turnoutSplit = GraphicAnimation.init({
|
||||
name: name,
|
||||
run: (dt: number) => {
|
||||
this.deltaTime += dt;
|
||||
@ -227,15 +228,15 @@ export class Turnout extends JlGraphic {
|
||||
this.graphics.fork.visible = this.deltaTime > 30;
|
||||
},
|
||||
});
|
||||
this.addAnimation(turnoutTurning);
|
||||
this.addAnimation(turnoutSplit);
|
||||
}
|
||||
turnoutTurning.resume();
|
||||
turnoutSplit.resume();
|
||||
}
|
||||
stopTurnoutTurning() {
|
||||
const name = `${this.datas.id}_turnout_turning`;
|
||||
const turnoutTurning = this.animation(name);
|
||||
if (turnoutTurning) {
|
||||
turnoutTurning.pause();
|
||||
stopTurnoutSplit() {
|
||||
const name = `${this.datas.id}_turnout_split`;
|
||||
const turnoutSplit = this.animation(name);
|
||||
if (turnoutSplit) {
|
||||
turnoutSplit.pause();
|
||||
this.deltaTime = 0;
|
||||
}
|
||||
}
|
||||
|
@ -221,6 +221,7 @@ export namespace state {
|
||||
normal?: boolean;
|
||||
reverse?: boolean;
|
||||
turning?: boolean;
|
||||
split?: boolean;
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||
@ -237,6 +238,9 @@ export namespace state {
|
||||
if ("turning" in data && data.turning != undefined) {
|
||||
this.turning = data.turning;
|
||||
}
|
||||
if ("split" in data && data.split != undefined) {
|
||||
this.split = data.split;
|
||||
}
|
||||
}
|
||||
}
|
||||
get id() {
|
||||
@ -263,11 +267,18 @@ export namespace state {
|
||||
set turning(value: boolean) {
|
||||
pb_1.Message.setField(this, 4, value);
|
||||
}
|
||||
get split() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 5, false) as boolean;
|
||||
}
|
||||
set split(value: boolean) {
|
||||
pb_1.Message.setField(this, 5, value);
|
||||
}
|
||||
static fromObject(data: {
|
||||
id?: string;
|
||||
normal?: boolean;
|
||||
reverse?: boolean;
|
||||
turning?: boolean;
|
||||
split?: boolean;
|
||||
}): SwitchState {
|
||||
const message = new SwitchState({});
|
||||
if (data.id != null) {
|
||||
@ -282,6 +293,9 @@ export namespace state {
|
||||
if (data.turning != null) {
|
||||
message.turning = data.turning;
|
||||
}
|
||||
if (data.split != null) {
|
||||
message.split = data.split;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
@ -290,6 +304,7 @@ export namespace state {
|
||||
normal?: boolean;
|
||||
reverse?: boolean;
|
||||
turning?: boolean;
|
||||
split?: boolean;
|
||||
} = {};
|
||||
if (this.id != null) {
|
||||
data.id = this.id;
|
||||
@ -303,6 +318,9 @@ export namespace state {
|
||||
if (this.turning != null) {
|
||||
data.turning = this.turning;
|
||||
}
|
||||
if (this.split != null) {
|
||||
data.split = this.split;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
serialize(): Uint8Array;
|
||||
@ -317,6 +335,8 @@ export namespace state {
|
||||
writer.writeBool(3, this.reverse);
|
||||
if (this.turning != false)
|
||||
writer.writeBool(4, this.turning);
|
||||
if (this.split != false)
|
||||
writer.writeBool(5, this.split);
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
@ -338,6 +358,9 @@ export namespace state {
|
||||
case 4:
|
||||
message.turning = reader.readBool();
|
||||
break;
|
||||
case 5:
|
||||
message.split = reader.readBool();
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user