Add screen phantoms #113
Merged
maxime.batista
merged 7 commits from editor/screen-phantoms
into master
1 year ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'editor/screen-phantoms'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Add phantoms when doing a screen to a player (or another phantom !).
setForceEmptyComponents(false)
}, [setForceEmptyComponents])
const usedComponents = forceEmptyComponents ? [] : components
You may only use
useLayoutEffect
to access browser APIs that aren't available during the first render. It is not the case here.): PlayerLike | undefined {
const playerOrigin =
player.type === "player" ? player : getOrigin(player, components)
const pathItems = playerOrigin.path?.items!
Optional chain expressions can return undefined by design, but you immediately use a non-null assertion.
no-non-null-asserted-optional-chain
targetIdx == 0
? playerOrigin
: getComponent<PlayerLike>(pathItems[targetIdx - 1], components)
return result
content = updateComponent(
{
...playerBefore,
actions: playerBefore.actions.toSpliced(actionIdx, 1),
const origin = getOrigin(player, content.components)
return truncatePlayerPath(origin, player, content)
content = truncatePlayerPath(origin, player, content)
console.log(content)
c6ca4e6c76
toa316edc341
1 year agoa316edc341
to1043207e2d
1 year ago? document
.getElementById(lastSegmentStart)!
.getBoundingClientRect()
: lastSegmentStart
Are we really sure that heavily nested ternaries is the way to go?
yeah i also find it ugly but TS does not treat blocks and condition expressions as value expressions 😔
maybe i should use declare the variable ahead and use if/else to initialize it
id: string,
components: TacticComponent[],
): T {
return components.find((c) => c.id === id)! as T
Unsafe cast incoming...
It is more of an utility function than an actual feature/trait definition function
I used to write
components.find((c) => c.id === id)! as T
anyway so there is no changes with this function.But i think there is a way to prove that the component is actually of the expected type, just didn't took the time to look at it.
I think a cast is relevant here as we search a component by and identifier and there is no such case where two TacticComponent can have the same identifier but with a different type
I quite agree that in some scenarios, runtime tricks cannot be easily avoided and may be fine.
The unsafe taint was previously "delimited" because it was written explicitly. This convenience function hides it. IDs may be inadvertently swapped/copy pasted.
Anyway, this code interface cannot be made more type safe without changing some of the infrastructure.
It could, maybe, be useful to check the type at runtime:
export interface Player extends PlayerInfo, Component<"player"> {
export interface Player extends PlayerInfo, Component<"player", Pos> {
readonly id: PlayerId
}
Two
Player
types are exported.fd9b5e2063
into master 1 year agoReviewers
fd9b5e2063
.