Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do i make my module compatible #81

Open
Saibot393 opened this issue Aug 28, 2023 · 8 comments
Open

How do i make my module compatible #81

Saibot393 opened this issue Aug 28, 2023 · 8 comments

Comments

@Saibot393
Copy link

Hello, i was just informed, that a module of mine is not compatible with Elevated Vision. So far the problem seems to be the "ClockwiseSweepPolygon.prototype._testWallInclusion" function. My module adds an additional condition to this (similar to the Wall-Height module). I tried to look through your code but was so far not successful at finding the way Wall-Height is made compatible, so i could not replicate it.
What would be the preferred way to ensure compatibility with Elevated Vision while adding a condition to the "_testWallInclusion" function?

@caewok
Copy link
Owner

caewok commented Sep 7, 2023

Which module of yours has the issue?

@Saibot393
Copy link
Author

Saibot393 commented Sep 7, 2023

The module is question is perceptive more precisely this code

@caewok
Copy link
Owner

caewok commented Sep 7, 2023

Short term at least, I am not going to be able to use the default _testWallInclusion. This is because I need the walls that would be included absent Wall Height, and I have no good way to get at that without just using a copy of the original function.

There might be an easy solution for you, though. If you export PeekingManager to a public-facing API, I can use that to call PeekingManager.IgnoreWall. One common way for modules to expose their API is like what I do here. So on your end, you would want something like:

Hooks.once("init", function() {
  game.modules.get(MODULE_ID).api = {  PeekingManager }; 
}

Then on my end, I could call something like:

const PeekingManager = game.modules.get("perceptive").api.PeekingManager;
PeekingManager.IgnoreWall(wallDoc, objectDoc);

@Saibot393
Copy link
Author

Thank you, i have added api for that in the newest update, the code for it looks like this: game.modules.get("perceptive").api.IgnoreWall(pWallDoc, pTokenDoc)

@caewok
Copy link
Owner

caewok commented Oct 23, 2023

I made a change in v0.5.11 that incorporates your api when selecting walls for a VisionSource. Let me know if that helps!

@Saibot393
Copy link
Author

Saibot393 commented Oct 23, 2023

Thanks for the work, i did a few tests and it almost works. While tokens are visible trough the peeked walls, as intended, the walls shadow doesn't update correctly i.e. the wall still casts a shadow. I dug through your code and found a way to solve this problem by adding this code into the _includeWall function in SouceShadowWallGeometry.js (lines 211-220, before the original return):

const IgnoreWall = game.modules.get("perceptive")?.api?.IgnoreWall;

if (IgnoreWall) {
	const token = this.source?.object;
	
	if (token) {
		return this.source._testWallInclusion(wall, PIXI.Point.fromObject(this.source)) && !IgnoreWall(wall.document, token.document);
	}
}

This still leaves one problem though, since shadows only seem to update correctly once a token moves, i would guess that i would have to update the vision source on my end. Normally token.updateVisionSource(); should surfice here, i guess you wrote a kind of custom vision update for the wall shadows?

@caewok
Copy link
Owner

caewok commented Jan 2, 2024

Try token.renderFlags.set({refreshVisibility: true}) or token.renderFlags.set({refresh: true}). My vision update should work but you might have to update the other tokens. Moving a token triggers vision updates for everyone.

@Saibot393
Copy link
Author

Thank you, will try it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants