Skip to content

Commit

Permalink
Rename pf2Environment region behavior type to environment (foundr…
Browse files Browse the repository at this point in the history
  • Loading branch information
In3luki committed May 30, 2024
1 parent 415d2cd commit 8eec3b1
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/module/actor/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
extractRollSubstitutions,
extractRollTwice,
} from "@module/rules/helpers.ts";
import { EnviornmentPF2eRegionBehavior } from "@scene/region-behaviors/types.ts";
import { EnvironmentRegionBehaviorPF2e } from "@scene/region-behaviors/types.ts";
import { eventToRollParams } from "@scripts/sheet-util.ts";
import { CheckCheckContext, CheckPF2e, CheckRoll } from "@system/check/index.ts";
import { DamageDamageContext, DamagePF2e } from "@system/damage/index.ts";
Expand Down Expand Up @@ -272,7 +272,7 @@ function createEnvironmentRollOptions(actor: ActorPF2e): Record<string, boolean>
if (token.elevation < bottom || token.elevation > top) continue;

for (const behavior of region.behaviors.filter(
(b): b is EnviornmentPF2eRegionBehavior => b.type === "pf2eEnvironment",
(b): b is EnvironmentRegionBehaviorPF2e => b.type === "environment",
)) {
const system = behavior.system;
switch (system.mode) {
Expand Down
10 changes: 5 additions & 5 deletions src/module/scene/region-behaviors/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { PauseGameRegionBehaviorTypeSchema } from "types/foundry/client-esm
import type { SuppressWeatherRegionBehaviorTypeSchema } from "types/foundry/client-esm/data/region-behaviors/suppress-weather.d.ts";
import type { TeleportTokenRegionBehaviorTypeSchema } from "types/foundry/client-esm/data/region-behaviors/teleport-token.d.ts";
import type { ToggleBehaviorRegionBehaviorTypeSchema } from "types/foundry/client-esm/data/region-behaviors/toggle-behavior.d.ts";
import type { EnvironmentTypeData } from "./terrain.ts";
import type { EnvironmentTypeData } from "./environment.ts";

type RegionEventPF2e = RegionEvent<TokenDocumentPF2e, UserPF2e, CombatantPF2e, RegionDocument<ScenePF2e | null>>;

Expand Down Expand Up @@ -66,9 +66,9 @@ interface ToggleBehaviorRegionBehavior<TParent extends RegionDocument = RegionDo
system: ModelPropsFromSchema<ToggleBehaviorRegionBehaviorTypeSchema>;
}

interface EnviornmentPF2eRegionBehavior<TParent extends RegionDocument = RegionDocument>
interface EnvironmentRegionBehaviorPF2e<TParent extends RegionDocument = RegionDocument>
extends BaseRegionBehavior<TParent> {
type: "pf2eEnvironment";
type: "environment";

system: EnvironmentTypeData;
}
Expand All @@ -81,6 +81,6 @@ type RegionBehaviorInstance<TParent extends RegionDocument = RegionDocument> =
| SuppressWeatherRegionBehavior<TParent>
| TeleportTokenRegionBehavior<TParent>
| ToggleBehaviorRegionBehavior<TParent>
| EnviornmentPF2eRegionBehavior<TParent>;
| EnvironmentRegionBehaviorPF2e<TParent>;

export type { EnviornmentPF2eRegionBehavior, RegionBehaviorInstance, RegionEventPF2e };
export type { EnvironmentRegionBehaviorPF2e, RegionBehaviorInstance, RegionEventPF2e };
4 changes: 1 addition & 3 deletions src/scripts/hooks/canvas-ready.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ export const CanvasReady = {
if (game.ready) {
if (
hasSceneTerrains ||
(token.document.regions ?? []).some((r) =>
r.behaviors.some((b) => b.type === "pf2eEnvironment"),
)
(token.document.regions ?? []).some((r) => r.behaviors.some((b) => b.type === "environment"))
) {
token.actor?.reset();
}
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/hooks/i18n-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const I18nInit = {
// Document.defaultName only checks `TYPES` for documents with a `TypeDataModel`
// todo: Remove once https://github.com/foundryvtt/foundryvtt/issues/11029 is fixed
fu.mergeObject(game.i18n.translations, {
"TYPES.RegionBehavior.pf2eEnvironment": game.i18n.localize("PF2E.Region.Environment.Label"),
"TYPES.RegionBehavior.environment": game.i18n.localize("PF2E.Region.Environment.Label"),
});
});
},
Expand Down
8 changes: 4 additions & 4 deletions src/scripts/hooks/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from "@module/canvas/index.ts";
import { setPerceptionModes } from "@module/canvas/perception/modes.ts";
import { PointVisionSourcePF2e } from "@module/canvas/perception/point-vision-source.ts";
import { EnvironmentBehaviorTypePF2e } from "@scene/region-behaviors/terrain.ts";
import { EnvironmentBehaviorTypePF2e } from "@scene/region-behaviors/environment.ts";
import { PF2ECONFIG } from "@scripts/config/index.ts";
import { registerHandlebarsHelpers } from "@scripts/handlebars.ts";
import { registerFonts } from "@scripts/register-fonts.ts";
Expand Down Expand Up @@ -51,9 +51,9 @@ export const Init = {
CONFIG.Canvas.layers.templates.layerClass = TemplateLayerPF2e;
CONFIG.Canvas.visionSourceClass = PointVisionSourcePF2e;

CONFIG.RegionBehavior.dataModels.pf2eEnvironment = EnvironmentBehaviorTypePF2e;
CONFIG.RegionBehavior.typeLabels.pf2eEnvironment = "PF2E.Region.Environment.Label";
CONFIG.RegionBehavior.typeIcons.pf2eEnvironment = "fa-solid fa-mountain-sun";
CONFIG.RegionBehavior.dataModels.environment = EnvironmentBehaviorTypePF2e;
CONFIG.RegionBehavior.typeLabels.environment = "PF2E.Region.Environment.Label";
CONFIG.RegionBehavior.typeIcons.environment = "fa-solid fa-mountain-sun";

setPerceptionModes();

Expand Down
2 changes: 1 addition & 1 deletion src/scripts/hooks/ready.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export const Ready = {
if (!token.actor) continue;
if (hasSceneTerrains) {
inTerrains.push(token.actor);
} else if ((token.regions ?? []).some((r) => r.behaviors.some((b) => b.type === "pf2eEnvironment"))) {
} else if ((token.regions ?? []).some((r) => r.behaviors.some((b) => b.type === "environment"))) {
inTerrains.push(token.actor);
}
}
Expand Down
2 changes: 1 addition & 1 deletion static/system.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"documentTypes": {
"RegionBehavior": {
"pf2eEnvironment": {}
"environment": {}
}
},
"packs": [
Expand Down

0 comments on commit 8eec3b1

Please sign in to comment.