All user data for FoundryVTT. Includes worlds, systems, modules, and any asset in the "foundryuserdata" directory. Does NOT include the FoundryVTT installation itself.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
1.3 KiB

1 year ago
1 year ago
  1. Hooks.on("updateToken", (token, updates) => {
  2. if(!token?.object?.controlled) return;
  3. if("elevation" in updates) CONFIG.Levels.handlers.RefreshHandler.refreshPlaceables();
  4. })
  5. Hooks.on("controlToken", (token, controlled)=>{
  6. if(controlled){
  7. CONFIG.Levels.currentToken = canvas.tokens.controlled.find(t => t.document.sight.enabled) ?? canvas.tokens.controlled[0];
  8. }else{
  9. if(game.user.isGM && !canvas.tokens.controlled.length) CONFIG.Levels.currentToken = null;
  10. }
  11. CONFIG.Levels.handlers.RefreshHandler.refreshPlaceables();
  12. })
  13. Hooks.on("preUpdateToken", (token,updates) => {
  14. if(token?.object?.controlled) CONFIG.Levels.handlers.DrawingHandler.executeStairs(updates, token);
  15. if(token.object && "elevation" in updates && !CONFIG.Levels?.useCollision3D){
  16. const elevDiff = token.object.document.elevation - updates.elevation;
  17. const p0 = {x:token.object.x,y:token.object.y,z:updates.elevation}
  18. const p1 = {x:token.object.x,y:token.object.y,z:token.object.losHeight-elevDiff+0.1}
  19. const collision = CONFIG.Levels.handlers.SightHandler.testCollision(p0, p1, "collision")
  20. if(collision){
  21. ui.notifications.error(game.i18n.localize("levels.err.collision"))
  22. if(!game.user.isGM) delete updates.elevation
  23. }
  24. }
  25. })