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);
|
||||
};
|
||||
}
|
||||
|
||||
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) {
|
||||
Array.prototype.equals = function (array, strict = true) {
|
||||
if (!array) return false;
|
||||
|
|
|
@ -29,6 +29,7 @@ declare global {
|
|||
replacePropIndex(property: Partial<T>, index: number): T[];
|
||||
someR(predicate: (value: T) => boolean): Result<void, Array<T>>;
|
||||
updateAll(value: Partial<T>): Array<T>;
|
||||
atR(index: number): Result<void, T>;
|
||||
}
|
||||
interface Date {
|
||||
formatDate(): string;
|
||||
|
|
|
@ -504,4 +504,9 @@ export class Skills {
|
|||
},
|
||||
() => 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) {
|
||||
try {
|
||||
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
|
||||
}" sid=${id}"`;
|
||||
}
|
||||
|
|
|
@ -207,6 +207,7 @@ export class BehaviorTreeBuilderStore extends UiDrawerFormState<BehaviorTreeView
|
|||
)
|
||||
).fold(
|
||||
(xml) => {
|
||||
console.log(xml)
|
||||
this.behaviorTreeModel.skills = this.filledOutTemplates;
|
||||
this.behaviorTreeModel.scene = NodeBehaviorTree.fromReteScene(
|
||||
this.editor as NodeEditor<Schemes>,
|
||||
|
@ -229,18 +230,7 @@ export class BehaviorTreeBuilderStore extends UiDrawerFormState<BehaviorTreeView
|
|||
);
|
||||
|
||||
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) => {
|
||||
this.selectedSid = sid;
|
||||
this.selected = label;
|
||||
|
@ -349,8 +339,10 @@ export class BehaviorTreeBuilderStore extends UiDrawerFormState<BehaviorTreeView
|
|||
for (const el of this.primitiveViewModel.primitives) {
|
||||
if (el.label.isEqual(label)) return el.css;
|
||||
}
|
||||
|
||||
return this.filledOutTemplates.getCssAtLabel(label);
|
||||
return this.skillTemplates.skillIsCondition(label).fold(
|
||||
() => Object.assign(this.filledOutTemplates.getCssAtLabel(label), { borderRadius: 33 }),
|
||||
() => this.filledOutTemplates.getCssAtLabel(label)
|
||||
);
|
||||
}
|
||||
changeSceneViewModel = (text: string) => {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue