Skip to content

Commit

Permalink
vision: extract the OAM of all stages and plot just what the vision n…
Browse files Browse the repository at this point in the history
…eeds

It is necessary because some visions has more than 3 stages
and if we plot the OAM of all stages more than necessary
we'll show trash on the map
  • Loading branch information
macabeus committed Jun 9, 2019
1 parent b926a5f commit 4152946
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 37 deletions.
55 changes: 19 additions & 36 deletions brush/src/components/Map/OAMLayer/index.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,30 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Layer } from 'react-konva'
import { range } from 'ramda'
import PointOam from '../Point/PointOam'

const OAMLayer = ({ setSelectedPointInfos, vision }) => {
const OAMLayer = ({ setSelectedPointInfos, totalStages, vision }) => {
const { oam } = vision

const oamList = oam
.map(oamEntry => oamEntry.data)
.map(({
kind,
xStage1,
xStage2,
xStage3,
yStage1,
yStage2,
yStage3,
}) =>
[
<PointOam
key={`${xStage1} ${yStage1} 1`}
oamId={kind}
stage={1}
showPointInfosHandle={setSelectedPointInfos}
x={xStage1}
y={yStage1}
/>,
<PointOam
key={`${xStage2} ${yStage2} 2`}
oamId={kind}
stage={2}
showPointInfosHandle={setSelectedPointInfos}
x={xStage2}
y={yStage2}
/>,
<PointOam
key={`${xStage3} ${yStage3} 3`}
oamId={kind}
stage={3}
showPointInfosHandle={setSelectedPointInfos}
x={xStage3}
y={yStage3}
/>,
])
.map(oamData =>
range(1, totalStages + 1).map((i) => {
const x = oamData[`xStage${i}`]
const y = oamData[`yStage${i}`]

return (
<PointOam
key={`${x} ${y} ${i}`}
oamId={oamData.kind}
stage={i}
showPointInfosHandle={setSelectedPointInfos}
x={x}
y={y}
/>
)
}))

return (
<Layer>
Expand All @@ -53,6 +35,7 @@ const OAMLayer = ({ setSelectedPointInfos, vision }) => {

OAMLayer.propTypes = {
setSelectedPointInfos: PropTypes.func,
totalStages: PropTypes.number.isRequired,
vision: PropTypes.shape({
oam: PropTypes.arrayOf(PropTypes.shape({
data: PropTypes.object.isRequired,
Expand Down
2 changes: 2 additions & 0 deletions brush/src/components/Map/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const Map = ({
infos: {
tilemap: {
height,
totalStages,
width,
},
},
Expand All @@ -47,6 +48,7 @@ const Map = ({
/>
{optShowOAM && <OAMLayer
setSelectedPointInfos={setSelectedPointInfos}
totalStages={totalStages}
vision={vision}
/>}
<Layer>
Expand Down
8 changes: 7 additions & 1 deletion scissors/src/visionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ const extractOAM = (romBuffer, [addressStart, addressEnd]) =>
.skip(4)
.word16lu('xStage3')
.word16lu('yStage3')
.skip(21)
.skip(4)
.word16lu('xStage4')
.word16lu('yStage4')
.skip(4)
.word16lu('xStage5')
.word16lu('yStage5')
.skip(5)
.word8lu('kind')
.vars,
memory,
Expand Down
1 change: 1 addition & 0 deletions scissors/src/visions/1-1.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default {
oam: [0xE2B90, 0xE2F59],
},
tilemap: {
totalStages: 3,
height: 60,
width: 420,
scheme: [
Expand Down
1 change: 1 addition & 0 deletions scissors/src/visions/1-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default {
oam: [0xE3CC0, 0xE3FAC],
},
tilemap: {
totalStages: 3,
height: 60,
width: 300,
scheme: [
Expand Down

0 comments on commit 4152946

Please sign in to comment.