|
|
@ -1,5 +1,5 @@
|
|
|
|
import {BallState, Player, PlayerLike, PlayerPhantom,} from "../model/tactic/Player"
|
|
|
|
import {BallState, Player, PlayerLike, PlayerPhantom,} from "../model/tactic/Player"
|
|
|
|
import {TacticComponent, TacticContent} from "../model/tactic/Tactic"
|
|
|
|
import {ComponentId, TacticComponent, TacticContent} from "../model/tactic/Tactic"
|
|
|
|
import {removeComponent, updateComponent} from "./TacticContentDomains"
|
|
|
|
import {removeComponent, updateComponent} from "./TacticContentDomains"
|
|
|
|
import {removeAllActionsTargeting, spreadNewStateFromOriginStateChange,} from "./ActionsDomains"
|
|
|
|
import {removeAllActionsTargeting, spreadNewStateFromOriginStateChange,} from "./ActionsDomains"
|
|
|
|
import {ActionKind} from "../model/tactic/Action"
|
|
|
|
import {ActionKind} from "../model/tactic/Action"
|
|
|
@ -56,7 +56,6 @@ export function computePhantomPositioning(phantom: PlayerPhantom,
|
|
|
|
: playerBeforePhantom.pos)
|
|
|
|
: playerBeforePhantom.pos)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const segment = posWithinBase(relativeTo(referentPos, pivotPoint), area)
|
|
|
|
const segment = posWithinBase(relativeTo(referentPos, pivotPoint), area)
|
|
|
|
const segmentLength = norm(segment)
|
|
|
|
const segmentLength = norm(segment)
|
|
|
|
const phantomDistanceFromReferent = PLAYER_RADIUS_PIXELS //TODO Place this in constants
|
|
|
|
const phantomDistanceFromReferent = PLAYER_RADIUS_PIXELS //TODO Place this in constants
|
|
|
@ -107,7 +106,7 @@ export function isNextInPath(
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function removePlayerPath(
|
|
|
|
export function clearPlayerPath(
|
|
|
|
player: Player,
|
|
|
|
player: Player,
|
|
|
|
content: TacticContent,
|
|
|
|
content: TacticContent,
|
|
|
|
): TacticContent {
|
|
|
|
): TacticContent {
|
|
|
@ -128,18 +127,35 @@ export function removePlayerPath(
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function removeAllPhantomsAttached(to: ComponentId, content: TacticContent): TacticContent {
|
|
|
|
|
|
|
|
let i = 0
|
|
|
|
|
|
|
|
while (i < content.components.length) {
|
|
|
|
|
|
|
|
const component = content.components[i]
|
|
|
|
|
|
|
|
if (component.type === "phantom") {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (component.pos.type === "follows" && component.pos.attach === to) {
|
|
|
|
|
|
|
|
content = removePlayer(component, content)
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
i++
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return content
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function removePlayer(
|
|
|
|
export function removePlayer(
|
|
|
|
player: PlayerLike,
|
|
|
|
player: PlayerLike,
|
|
|
|
content: TacticContent,
|
|
|
|
content: TacticContent,
|
|
|
|
): TacticContent {
|
|
|
|
): TacticContent {
|
|
|
|
content = removeAllActionsTargeting(player.id, content)
|
|
|
|
content = removeAllActionsTargeting(player.id, content)
|
|
|
|
|
|
|
|
content = removeAllPhantomsAttached(player.id, content)
|
|
|
|
|
|
|
|
|
|
|
|
if (player.type == "phantom") {
|
|
|
|
if (player.type === "phantom") {
|
|
|
|
const origin = getOrigin(player, content.components)
|
|
|
|
const origin = getOrigin(player, content.components)
|
|
|
|
return truncatePlayerPath(origin, player, content)
|
|
|
|
return truncatePlayerPath(origin, player, content)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
content = removePlayerPath(player, content)
|
|
|
|
content = clearPlayerPath(player, content)
|
|
|
|
content = removeComponent(player.id, content)
|
|
|
|
content = removeComponent(player.id, content)
|
|
|
|
|
|
|
|
|
|
|
|
for (const action of player.actions) {
|
|
|
|
for (const action of player.actions) {
|
|
|
|