Water pistol test assets added
This commit is contained in:
117
system/wpn_waterpistol.modifier.api.wren
Normal file
117
system/wpn_waterpistol.modifier.api.wren
Normal file
@ -0,0 +1,117 @@
|
||||
|
||||
class Modifier {
|
||||
static id : String { "system/wpn_waterpistol.modifier" }
|
||||
static system(world: World) : System { World.get_system(world, Modifier.id) }
|
||||
static get(entity: Entity) : Data { Mod.get(entity, Modifier.id) }
|
||||
construct new(world: World) {
|
||||
_world = world
|
||||
_block = World.get_modifier_block(_world, Modifier.id)
|
||||
}
|
||||
world : World { _world }
|
||||
attached_count : Num { Block.count(_block) }
|
||||
|
||||
init(world: World) : None {}
|
||||
pre(entity: Entity, data) : None {}
|
||||
attach(entity: Entity, data) : None {}
|
||||
detach(entity: Entity, data) : None {}
|
||||
change(entity: Entity, change: ModifierChange) : None {}
|
||||
tick(delta: Num) : None {}
|
||||
|
||||
internal_tick(delta: Num) : None {
|
||||
}
|
||||
|
||||
editor_init(world: World) : None {}
|
||||
editor_pre(entity: Entity, data) : None {}
|
||||
editor_attach(entity: Entity, data) : None {}
|
||||
editor_detach(entity: Entity, data) : None {}
|
||||
editor_change(entity: Entity, change: ModifierChange) : None {}
|
||||
|
||||
editor_tick(delta: Num) : None {}
|
||||
|
||||
get(entity: Entity) : Data { Mod.get(entity, Modifier.id) }
|
||||
each(fn: Fn) {
|
||||
var count = attached_count
|
||||
for(idx in 0 ... count) {
|
||||
var inst = Block.get_at(_block, idx)
|
||||
var data = Block.instance(_block, inst)
|
||||
var entity = Block.get_handle(_block, inst, HandleTag.entity)
|
||||
fn.call(entity, data)
|
||||
}
|
||||
}
|
||||
each(start: Num, count: Num, fn: Fn) {
|
||||
for(idx in start ... start + count) {
|
||||
var inst = Block.get_at(_block, idx)
|
||||
var data = Block.instance(_block, inst)
|
||||
var entity = Block.get_handle(_block, inst, HandleTag.entity)
|
||||
fn.call(entity, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class API {
|
||||
static id { Modifier.id }
|
||||
static create(entity: Entity) { Mod.create(Modifier.id, entity) }
|
||||
static has(entity: Entity) { Mod.has(Modifier.id, entity) }
|
||||
static destroy(entity: Entity) { Mod.destroy(Modifier.id, entity) }
|
||||
static get(entity: Entity) : Data { Mod.get(entity, Modifier.id) }
|
||||
static system_in(world: World) : System { World.get_system(world, Modifier.id) }
|
||||
static system(entity: Entity) : System { World.get_system(Entity.get_world(entity), Modifier.id) }
|
||||
static count(world: World) : Num { system_in(world).attached_count }
|
||||
static each(world: World, fn: Fn) : System { system_in(world).each(fn) }
|
||||
static get : APIGet { APIGetter }
|
||||
static set : APISet { APISetter }
|
||||
static connect : APIWireConnect { APIWireConnects }
|
||||
static send : APIWireSend { APIWireSends }
|
||||
}
|
||||
|
||||
class Fields {
|
||||
static starting_ammo : String { "starting_ammo" }
|
||||
static max_capacity : String { "max_capacity" }
|
||||
static trigger_held : String { "trigger_held" }
|
||||
static current_ammo : String { "current_ammo" }
|
||||
}
|
||||
|
||||
import "luxe: world/states" for AState, States, Op
|
||||
#doc="The base class for a state, and our API for accessing it"
|
||||
class State is AState {
|
||||
construct create(in_name: String, in_parent: State) { super(in_name, in_parent) }
|
||||
goto_on(entity: Entity, state: State, wire: Num) { this.goto_on(entity, state, This, wire) }
|
||||
}
|
||||
|
||||
class APIWireSend {
|
||||
construct new() {}
|
||||
}
|
||||
|
||||
class APIWireConnect {
|
||||
construct new() {}
|
||||
}
|
||||
|
||||
class APIGet {
|
||||
construct new() {}
|
||||
starting_ammo(entity: Entity) : Num { Modifier.get(entity).starting_ammo }
|
||||
max_capacity(entity: Entity) : Num { Modifier.get(entity).max_capacity }
|
||||
trigger_held(entity: Entity) : Bool { Modifier.get(entity).trigger_held }
|
||||
current_ammo(entity: Entity) : Num { Modifier.get(entity).current_ammo }
|
||||
}
|
||||
|
||||
class APISet {
|
||||
construct new() {}
|
||||
starting_ammo(entity: Entity, value: Num) { Modifier.get(entity).starting_ammo = value }
|
||||
max_capacity(entity: Entity, value: Num) { Modifier.get(entity).max_capacity = value }
|
||||
trigger_held(entity: Entity, value: Bool) { Modifier.get(entity).trigger_held = value }
|
||||
current_ammo(entity: Entity, value: Num) { Modifier.get(entity).current_ammo = value }
|
||||
}
|
||||
|
||||
var APIGetter = APIGet.new()
|
||||
var APISetter = APISet.new()
|
||||
var APIWireSends = APIWireSend.new()
|
||||
var APIWireConnects = APIWireConnect.new()
|
||||
|
||||
import "system/wpn_waterpistol.modifier" for Data, System
|
||||
import "luxe: world/world" for World, Wire
|
||||
import "luxe: world" for Entity
|
||||
import "luxe: world/modifier" for Modifier as Mod, ModifierChange
|
||||
import "luxe: blocks" for Block
|
||||
import "luxe: io" for HandleTag
|
||||
|
||||
|
||||
2
system/wpn_waterpistol.modifier.api.wren.meta.lx
Normal file
2
system/wpn_waterpistol.modifier.api.wren.meta.lx
Normal file
@ -0,0 +1,2 @@
|
||||
tags = []
|
||||
uuid = "d24dbe9d-04f1-4f17-8ce4-49a0fc0fe683"
|
||||
54
system/wpn_waterpistol.modifier.wren
Normal file
54
system/wpn_waterpistol.modifier.wren
Normal file
@ -0,0 +1,54 @@
|
||||
import "system/wpn_waterpistol.modifier.api" for API, Modifier, APIGet, APISet, Wire, Fields, State, Op
|
||||
import "luxe: io" for IO
|
||||
import "luxe: assets" for Strings
|
||||
import "luxe: world" for Entity, World
|
||||
import "luxe.project/asset" for Asset
|
||||
|
||||
#block = data
|
||||
class Data {
|
||||
var starting_ammo: Num = 200
|
||||
var max_capacity: Num = 200
|
||||
|
||||
#hidden
|
||||
var trigger_held: Bool = false
|
||||
|
||||
#hidden
|
||||
var current_ammo: Num = 200
|
||||
}
|
||||
|
||||
#api
|
||||
#display = "Weapon: Water Pistol"
|
||||
#desc = "**Weapon**. Handles behaviour for the water pistol"
|
||||
#icon = "luxe: image/modifier/modifier.svg"
|
||||
class WeaponWaterPistol is API {
|
||||
//add public facing API here
|
||||
}
|
||||
|
||||
#system
|
||||
#phase(on, tick)
|
||||
class System is Modifier {
|
||||
|
||||
//required atm
|
||||
construct new(world: World) { super(world) }
|
||||
|
||||
init(world: World) {
|
||||
Log.print("init `%(This)` in world `%(world)`")
|
||||
}
|
||||
|
||||
#hidden
|
||||
attach(entity: Entity, data: Data) {
|
||||
Log.print("attached to `%(Strings.get(Entity.get_name(entity)))` `%(entity)` - `%(This)`")
|
||||
}
|
||||
|
||||
#hidden
|
||||
detach(entity: Entity, data: Data) {
|
||||
Log.print("detached from `%(Strings.get(Entity.get_name(entity)))` `%(entity)` - `%(This)`")
|
||||
}
|
||||
|
||||
#hidden
|
||||
tick(delta: Num) {
|
||||
// each {|entity: Entity, data: Data|
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
2
system/wpn_waterpistol.modifier.wren.meta.lx
Normal file
2
system/wpn_waterpistol.modifier.wren.meta.lx
Normal file
@ -0,0 +1,2 @@
|
||||
tags = []
|
||||
uuid = "cc2b1d2a-e188-494a-b583-2b93946b417b"
|
||||
Reference in New Issue
Block a user