Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nearnshaw committed Oct 3, 2023
1 parent 686dbaf commit e9e1c68
Show file tree
Hide file tree
Showing 4 changed files with 277 additions and 277 deletions.
122 changes: 61 additions & 61 deletions Dance-floor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,79 +3,79 @@ import { Quaternion, Vector3 } from '@dcl/sdk/math'
import { colors, Beat, Tile } from './definitions'

export function main() {
// Add floor Tiles
;[0, 1, 2, 3].forEach((x) => {
;[0, 1, 2, 3].forEach((z) => {
const tileEntity = engine.addEntity()
// Add floor Tiles
;[0, 1, 2, 3].forEach((x) => {
;[0, 1, 2, 3].forEach((z) => {
const tileEntity = engine.addEntity()

MeshRenderer.setPlane(tileEntity)
MeshRenderer.setPlane(tileEntity)

Transform.create(tileEntity, {
position: Vector3.create(x * 4 + 2, 0, z * 4 + 2),
rotation: Quaternion.fromEulerDegrees(90, 0, 0),
scale: Vector3.create(4, 4, 4)
})
Transform.create(tileEntity, {
position: Vector3.create(x * 4 + 2, 0, z * 4 + 2),
rotation: Quaternion.fromEulerDegrees(90, 0, 0),
scale: Vector3.create(4, 4, 4)
})

randomizeTileColor(tileEntity)
randomizeTileColor(tileEntity)

Tile.create(tileEntity)
})
})
Tile.create(tileEntity)
})
})

// Add Trevor NPC dancing
const trevorNPCEntity = engine.addEntity()
GltfContainer.create(trevorNPCEntity, {
src: 'models/Trevor.glb'
})
Animator.create(trevorNPCEntity, {
states: [
{
clip: 'Armature_Idle',
playing: true,
loop: true
}
]
})
Transform.create(trevorNPCEntity, {
position: Vector3.create(5, 0.1, 5),
rotation: Quaternion.fromEulerDegrees(0, -90, 0),
scale: Vector3.create(1.5, 1.5, 1.5)
})
// Add Trevor NPC dancing
const trevorNPCEntity = engine.addEntity()
GltfContainer.create(trevorNPCEntity, {
src: 'models/Trevor.glb'
})
Animator.create(trevorNPCEntity, {
states: [
{
clip: 'Armature_Idle',
playing: true,
loop: true
}
]
})
Transform.create(trevorNPCEntity, {
position: Vector3.create(5, 0.1, 5),
rotation: Quaternion.fromEulerDegrees(0, -90, 0),
scale: Vector3.create(1.5, 1.5, 1.5)
})

// Add audio
AudioSource.create(trevorNPCEntity, {
audioClipUrl: 'sounds/Vexento.mp3',
playing: true,
loop: true
})
// Add audio
AudioSource.create(trevorNPCEntity, {
audioClipUrl: 'sounds/Vexento.mp3',
playing: true,
loop: true
})

// Add beat keeper
const beatKeeperEntity = engine.addEntity()
const beatKeeperComponent = Beat.create(beatKeeperEntity, {
interval: 0.5,
timer: 0.5
})
// Add beat keeper
const beatKeeperEntity = engine.addEntity()
const beatKeeperComponent = Beat.create(beatKeeperEntity, {
interval: 0.5,
timer: 0.5
})

// System to change tiles color
function tilesColorChangeSystem(dt: number) {
beatKeeperComponent.timer -= dt
// System to change tiles color
function tilesColorChangeSystem(dt: number) {
beatKeeperComponent.timer -= dt

if (beatKeeperComponent.timer < 0) {
beatKeeperComponent.timer = beatKeeperComponent.interval
if (beatKeeperComponent.timer < 0) {
beatKeeperComponent.timer = beatKeeperComponent.interval

for (const [tileEntity] of engine.getEntitiesWith(Tile)) {
randomizeTileColor(tileEntity)
}
}
}
for (const [tileEntity] of engine.getEntitiesWith(Tile)) {
randomizeTileColor(tileEntity)
}
}
}

engine.addSystem(tilesColorChangeSystem)
engine.addSystem(tilesColorChangeSystem)
}

function randomizeTileColor(entity: Entity) {
const colorNum = Math.floor(Math.random() * colors.length)
Material.setPbrMaterial(entity, {
albedoColor: colors[colorNum],
metallic: 0
})
const colorNum = Math.floor(Math.random() * colors.length)
Material.setPbrMaterial(entity, {
albedoColor: colors[colorNum],
metallic: 0
})
}
122 changes: 61 additions & 61 deletions Gnark/src/gnark.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Coordinates of path to patrol
import { Animator, engine, Entity, GltfContainer, Transform } from '@dcl/sdk/ecs'
import { } from '@dcl/sdk/math'
import {} from '@dcl/sdk/math'

const point1 = { x: 8, y: 0, z: 8 }
const point2 = { x: 8, y: 0, z: 24 }
Expand All @@ -16,72 +16,72 @@ import { PathDataComponent } from './components/pathData'
import { TimeOutComponent } from './components/timeOut'

export function createGnark(startingSegment: number = 1): Entity {
const gnark = engine.addEntity()
const gnark = engine.addEntity()

Transform.create(gnark, {
position: point1
})
Transform.create(gnark, {
position: point1
})

GltfContainer.create(gnark, {
src: 'models/gnark.glb'
})
GltfContainer.create(gnark, {
src: 'models/gnark.glb'
})

Animator.create(gnark, {
states: [
{
clip: 'walk',
playing: true,
weight: 1,
speed: 1,
loop: true,
shouldReset: false
},
{
clip: 'turnRight',
playing: false,
weight: 1,
speed: 1,
loop: false,
shouldReset: true
},
{
clip: 'raiseDead',
playing: false,
weight: 1,
speed: 1,
loop: true,
shouldReset: true
}
]
})
Animator.create(gnark, {
states: [
{
clip: 'walk',
playing: true,
weight: 1,
speed: 1,
loop: true,
shouldReset: false
},
{
clip: 'turnRight',
playing: false,
weight: 1,
speed: 1,
loop: false,
shouldReset: true
},
{
clip: 'raiseDead',
playing: false,
weight: 1,
speed: 1,
loop: true,
shouldReset: true
}
]
})

NPComponent.create(gnark, {
state: gnarkStates.TURNING,
previousState: gnarkStates.WALKING
})
NPComponent.create(gnark, {
state: gnarkStates.TURNING,
previousState: gnarkStates.WALKING
})

PathDataComponent.create(gnark, {
path: pathArray,
paused: false,
origin: startingSegment,
target: startingSegment + 1
})
PathDataComponent.create(gnark, {
path: pathArray,
paused: false,
origin: startingSegment,
target: startingSegment + 1
})

MoveTransformComponent.create(gnark, {
start: pathArray[startingSegment],
end: pathArray[startingSegment + 1],
normalizedTime: 0,
lerpTime: 0,
speed: 0.1,
hasFinished: false,
interpolationType: 0
})
MoveTransformComponent.create(gnark, {
start: pathArray[startingSegment],
end: pathArray[startingSegment + 1],
normalizedTime: 0,
lerpTime: 0,
speed: 0.1,
hasFinished: false,
interpolationType: 0
})

TimeOutComponent.create(gnark, {
timeLeft: 0.9,
hasFinished: false,
paused: false
})
TimeOutComponent.create(gnark, {
timeLeft: 0.9,
hasFinished: false,
paused: false
})

return gnark
return gnark
}
100 changes: 50 additions & 50 deletions tin-can-alley/src/modules/rifle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,58 @@ import { playshotSilencerSound } from './sound'
import { OnlyInScene } from './onlyRenderInScene'

export function createRifle(model: string, position: Position, rotation: Vector3) {
const rifle = engine.addEntity()

Transform.create(rifle, {
position: position,
rotation: Quaternion.fromEulerDegrees(rotation.x, rotation.y, rotation.z)
})
GltfContainer.create(rifle, {
src: model,
invisibleMeshesCollisionMask: ColliderLayer.CL_PHYSICS,
visibleMeshesCollisionMask: ColliderLayer.CL_POINTER
})

OnlyInScene.create(rifle)

Cooldown.create(rifle)

Transform.getMutable(rifle).parent = engine.CameraEntity
Transform.getMutable(rifle).position = Vector3.create(0.075, -0.5, 0.2)

Animator.create(rifle, {
states: [
{
clip: 'Blank',
playing: true,
loop: false
},
{
clip: 'Fire',
playing: false,
loop: false
}
]
})

return { rifle }
const rifle = engine.addEntity()

Transform.create(rifle, {
position: position,
rotation: Quaternion.fromEulerDegrees(rotation.x, rotation.y, rotation.z)
})
GltfContainer.create(rifle, {
src: model,
invisibleMeshesCollisionMask: ColliderLayer.CL_PHYSICS,
visibleMeshesCollisionMask: ColliderLayer.CL_POINTER
})

OnlyInScene.create(rifle)

Cooldown.create(rifle)

Transform.getMutable(rifle).parent = engine.CameraEntity
Transform.getMutable(rifle).position = Vector3.create(0.075, -0.5, 0.2)

Animator.create(rifle, {
states: [
{
clip: 'Blank',
playing: true,
loop: false
},
{
clip: 'Fire',
playing: false,
loop: false
}
]
})

return { rifle }
}

// Play gun fire animation
export function playFireAnim(rifle: Entity) {
playshotSilencerSound()
Animator.stopAllAnimations(rifle)
Animator.playSingleAnimation(rifle, 'Fire')
engine.addSystem(CooldownSystem)

let timer = Cooldown.getMutable(rifle).time
function CooldownSystem(dt: number) {
Cooldown.getMutable(rifle).on = true
timer -= dt
if (timer <= 0) {
timer = Cooldown.getMutable(rifle).time
Cooldown.getMutable(rifle).on = false
engine.removeSystem(CooldownSystem)
}
}
playshotSilencerSound()
Animator.stopAllAnimations(rifle)
Animator.playSingleAnimation(rifle, 'Fire')
engine.addSystem(CooldownSystem)

let timer = Cooldown.getMutable(rifle).time
function CooldownSystem(dt: number) {
Cooldown.getMutable(rifle).on = true
timer -= dt
if (timer <= 0) {
timer = Cooldown.getMutable(rifle).time
Cooldown.getMutable(rifle).on = false
engine.removeSystem(CooldownSystem)
}
}
}
Loading

0 comments on commit e9e1c68

Please sign in to comment.