-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Internal } from "bc-minecraft-bedrock-project"; | ||
import { Types } from "bc-minecraft-bedrock-types"; | ||
import { DiagnosticsBuilder } from "../../../Types/DiagnosticsBuilder/DiagnosticsBuilder"; | ||
import { minecraft_animation_used } from "../../Minecraft/Animation"; | ||
|
||
export function behaviorpack_animation_used(animations: Types.Definition | undefined, diagnoser: DiagnosticsBuilder, script?: Internal.Script): void { | ||
if (animations === undefined) return; | ||
|
||
minecraft_animation_used(animations, diagnoser, diagnoser.context.getCache().BehaviorPacks.animation_controllers, script); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Internal, ResourcePack, BehaviorPack } from "bc-minecraft-bedrock-project"; | ||
import { DataSetConnector } from "bc-minecraft-bedrock-project/lib/src/Lib/Types/DataSet/DataSetConnector"; | ||
import { Types } from "bc-minecraft-bedrock-types"; | ||
import { DiagnosticsBuilder } from "../../Types/DiagnosticsBuilder/DiagnosticsBuilder"; | ||
import { DiagnosticSeverity } from "../../Types/DiagnosticsBuilder/Severity"; | ||
|
||
export function minecraft_animation_used( | ||
animations: Types.Definition, | ||
diagnoser: DiagnosticsBuilder, | ||
controllers: DataSetConnector< | ||
ResourcePack.AnimationController.AnimationController | BehaviorPack.AnimationController.AnimationController, | ||
ResourcePack.ResourcePack | ||
>, | ||
script?: Internal.Script | ||
): void { | ||
const used: string[] = []; | ||
|
||
if (script) { | ||
Types.Conditional.forEach(script.animate, (ref, condition) => used.push(ref)); | ||
} | ||
|
||
//Extract animations from controllers | ||
Types.Definition.forEach(animations, (ref, id) => { | ||
const controller = controllers.get(id); | ||
|
||
//If it is a controller, then add used animations | ||
if (controller) { | ||
used.push(...controller.animations.using); | ||
} | ||
}); | ||
|
||
// | ||
Types.Definition.forEach(animations, (ref, id) => { | ||
//If the used animations does not contain the referenced animation, then its unused | ||
if (!used.includes(ref)) { | ||
diagnoser.Add(`${ref}/${id}`, `Animation: ${id} is not being used, could be removed`, DiagnosticSeverity.info, `minecraft.animation.unused`); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Internal } from "bc-minecraft-bedrock-project"; | ||
import { Types } from "bc-minecraft-bedrock-types"; | ||
import { DiagnosticsBuilder } from "../../../Types/DiagnosticsBuilder/DiagnosticsBuilder"; | ||
import { minecraft_animation_used } from "../../Minecraft/Animation"; | ||
|
||
export function resourcepack_animation_used(animations: Types.Definition | undefined, diagnoser: DiagnosticsBuilder, script?: Internal.Script): void { | ||
if (animations === undefined) return; | ||
|
||
minecraft_animation_used(animations, diagnoser, diagnoser.context.getCache().ResourcePacks.animation_controllers, script); | ||
} |
Binary file not shown.