condition fixed
This commit is contained in:
parent
314e070bee
commit
4657652dd0
5 changed files with 28 additions and 16 deletions
|
@ -10,7 +10,15 @@ export const ArrayExtensions = () => {
|
||||||
return Result.ok(this);
|
return Result.ok(this);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
if ([].atR === undefined) {
|
||||||
|
Array.prototype.atR = function (index) {
|
||||||
|
const result = this.at(index);
|
||||||
|
if (result) {
|
||||||
|
return Result.ok(result);
|
||||||
|
}
|
||||||
|
return Result.error(undefined);
|
||||||
|
};
|
||||||
|
}
|
||||||
if ([].equals === undefined) {
|
if ([].equals === undefined) {
|
||||||
Array.prototype.equals = function (array, strict = true) {
|
Array.prototype.equals = function (array, strict = true) {
|
||||||
if (!array) return false;
|
if (!array) return false;
|
||||||
|
|
|
@ -29,6 +29,7 @@ declare global {
|
||||||
replacePropIndex(property: Partial<T>, index: number): T[];
|
replacePropIndex(property: Partial<T>, index: number): T[];
|
||||||
someR(predicate: (value: T) => boolean): Result<void, Array<T>>;
|
someR(predicate: (value: T) => boolean): Result<void, Array<T>>;
|
||||||
updateAll(value: Partial<T>): Array<T>;
|
updateAll(value: Partial<T>): Array<T>;
|
||||||
|
atR(index: number): Result<void, T>;
|
||||||
}
|
}
|
||||||
interface Date {
|
interface Date {
|
||||||
formatDate(): string;
|
formatDate(): string;
|
||||||
|
|
|
@ -504,4 +504,9 @@ export class Skills {
|
||||||
},
|
},
|
||||||
() => Result.error(false)
|
() => Result.error(false)
|
||||||
);
|
);
|
||||||
|
skillIsCondition = (label: string) =>
|
||||||
|
this.getSkill(label).fold(
|
||||||
|
(s) => s.BTAction.atR(0).map((el) => el.typeAction.isEqualR(BtAction.CONDITION)),
|
||||||
|
(e) => Result.error(undefined)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,13 @@ export class BehaviorTreeBuilderModel {
|
||||||
public static getNodeLabelAtId(editor: NodeEditor<Schemes>, id: string, skills?: Skills) {
|
public static getNodeLabelAtId(editor: NodeEditor<Schemes>, id: string, skills?: Skills) {
|
||||||
try {
|
try {
|
||||||
if (skills?.getSkillsNames().find((el) => el.name.isEqual(editor.getNode(id)!.label))) {
|
if (skills?.getSkillsNames().find((el) => el.name.isEqual(editor.getNode(id)!.label))) {
|
||||||
return `Action ID="RbsAction" do="${skills.getSkillDo(editor.getNode(id)!.label)}" command="${
|
return `${skills.skillIsCondition(skills.getSkillDo(editor.getNode(id)!.label)).fold(
|
||||||
|
() => "Action",
|
||||||
|
() => "Condition"
|
||||||
|
)} ID=${skills.skillIsCondition(skills.getSkillDo(editor.getNode(id)!.label)).fold(
|
||||||
|
() => "RbsAction",
|
||||||
|
() => "ls"
|
||||||
|
)} do="${skills.getSkillDo(editor.getNode(id)!.label)}" command="${
|
||||||
editor.getNode(id)?.label
|
editor.getNode(id)?.label
|
||||||
}" sid=${id}"`;
|
}" sid=${id}"`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,6 +207,7 @@ export class BehaviorTreeBuilderStore extends UiDrawerFormState<BehaviorTreeView
|
||||||
)
|
)
|
||||||
).fold(
|
).fold(
|
||||||
(xml) => {
|
(xml) => {
|
||||||
|
console.log(xml)
|
||||||
this.behaviorTreeModel.skills = this.filledOutTemplates;
|
this.behaviorTreeModel.skills = this.filledOutTemplates;
|
||||||
this.behaviorTreeModel.scene = NodeBehaviorTree.fromReteScene(
|
this.behaviorTreeModel.scene = NodeBehaviorTree.fromReteScene(
|
||||||
this.editor as NodeEditor<Schemes>,
|
this.editor as NodeEditor<Schemes>,
|
||||||
|
@ -229,18 +230,7 @@ export class BehaviorTreeBuilderStore extends UiDrawerFormState<BehaviorTreeView
|
||||||
);
|
);
|
||||||
|
|
||||||
validateBt() {}
|
validateBt() {}
|
||||||
createNewBehaviorTree = async () => {
|
|
||||||
this.viewModel.project = this.activeProject;
|
|
||||||
// this.viewModel.valid().fold(
|
|
||||||
// async (model) => {
|
|
||||||
// await this.messageHttp(this.behaviorTreeBuilderHttpRepository.saveNewBt(model), {
|
|
||||||
// successMessage: "Новое дерево создано",
|
|
||||||
// });
|
|
||||||
// this.mapOk("btTreeModels", this.behaviorTreeBuilderHttpRepository.getAllBtInstances());
|
|
||||||
// },
|
|
||||||
// async (error) => message.error(error)
|
|
||||||
// );
|
|
||||||
};
|
|
||||||
setSelected = (label: string, selected: boolean, sid: string) => {
|
setSelected = (label: string, selected: boolean, sid: string) => {
|
||||||
this.selectedSid = sid;
|
this.selectedSid = sid;
|
||||||
this.selected = label;
|
this.selected = label;
|
||||||
|
@ -349,8 +339,10 @@ export class BehaviorTreeBuilderStore extends UiDrawerFormState<BehaviorTreeView
|
||||||
for (const el of this.primitiveViewModel.primitives) {
|
for (const el of this.primitiveViewModel.primitives) {
|
||||||
if (el.label.isEqual(label)) return el.css;
|
if (el.label.isEqual(label)) return el.css;
|
||||||
}
|
}
|
||||||
|
return this.skillTemplates.skillIsCondition(label).fold(
|
||||||
return this.filledOutTemplates.getCssAtLabel(label);
|
() => Object.assign(this.filledOutTemplates.getCssAtLabel(label), { borderRadius: 33 }),
|
||||||
|
() => this.filledOutTemplates.getCssAtLabel(label)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
changeSceneViewModel = (text: string) => {};
|
changeSceneViewModel = (text: string) => {};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue