Repaired engine flares
parent
35c6676e95
commit
94bd26b49e
|
@ -45,10 +45,7 @@ impl Game {
|
||||||
//o1.add_gun(&ct, content::GunHandle { index: 0 });
|
//o1.add_gun(&ct, content::GunHandle { index: 0 });
|
||||||
//o1.add_gun(&ct, content::GunHandle { index: 0 });
|
//o1.add_gun(&ct, content::GunHandle { index: 0 });
|
||||||
|
|
||||||
let mut o1 = OutfitSet::new(ss.space, &[]);
|
print!("{:?}", o1);
|
||||||
o1.add(&ct.get_outfit(content::OutfitHandle { index: 0 }));
|
|
||||||
//o1.add_gun(&ct, content::GunHandle { index: 0 });
|
|
||||||
|
|
||||||
let player = gamedata.create_ship(
|
let player = gamedata.create_ship(
|
||||||
&ct,
|
&ct,
|
||||||
content::ShipHandle { index: 0 },
|
content::ShipHandle { index: 0 },
|
||||||
|
@ -67,6 +64,10 @@ impl Game {
|
||||||
&content::SystemHandle { index: 0 },
|
&content::SystemHandle { index: 0 },
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let mut o1 = OutfitSet::new(ss.space, &[]);
|
||||||
|
o1.add(&ct.get_outfit(content::OutfitHandle { index: 0 }));
|
||||||
|
//o1.add_gun(&ct, content::GunHandle { index: 0 });
|
||||||
|
|
||||||
gamedata.create_ship(
|
gamedata.create_ship(
|
||||||
&ct,
|
&ct,
|
||||||
content::ShipHandle { index: 0 },
|
content::ShipHandle { index: 0 },
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use content::{GunPoint, OutfitHandle, OutfitSpace};
|
use content::{GunPoint, OutfitHandle, OutfitSpace, SpriteHandle};
|
||||||
use galactica_content as content;
|
use galactica_content as content;
|
||||||
|
|
||||||
/// Possible outcomes when adding an outfit
|
/// Possible outcomes when adding an outfit
|
||||||
|
@ -98,6 +98,12 @@ impl OutfitSet {
|
||||||
generation: o.shield_generation,
|
generation: o.shield_generation,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if self.outfits.contains_key(&o.handle) {
|
||||||
|
*self.outfits.get_mut(&o.handle).unwrap() += 1;
|
||||||
|
} else {
|
||||||
|
self.outfits.insert(o.handle, 1);
|
||||||
|
}
|
||||||
|
|
||||||
return OutfitAddResult::Ok;
|
return OutfitAddResult::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,6 +137,17 @@ impl OutfitSet {
|
||||||
|
|
||||||
return OutfitRemoveResult::Ok;
|
return OutfitRemoveResult::Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: pick these better
|
||||||
|
pub fn get_flare_sprite(&self, ct: &content::Content) -> Option<SpriteHandle> {
|
||||||
|
for i in self.outfits.keys() {
|
||||||
|
let c = ct.get_outfit(*i);
|
||||||
|
if c.engine_flare_sprite.is_some() {
|
||||||
|
return c.engine_flare_sprite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return None;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Simple getters to make sure nobody meddles with our internal state
|
// Simple getters to make sure nobody meddles with our internal state
|
||||||
|
|
|
@ -22,7 +22,7 @@ impl GPUState {
|
||||||
s: &ShipWorldObject,
|
s: &ShipWorldObject,
|
||||||
) {
|
) {
|
||||||
let r = state.world.get_rigid_body(s.rigid_body).unwrap();
|
let r = state.world.get_rigid_body(s.rigid_body).unwrap();
|
||||||
let ship = state.data.get_ship(s.data_handle);
|
let ship = state.data.get_ship(s.data_handle).unwrap();
|
||||||
let ship_pos = util::rigidbody_position(&r);
|
let ship_pos = util::rigidbody_position(&r);
|
||||||
let ship_rot = util::rigidbody_rotation(r);
|
let ship_rot = util::rigidbody_rotation(r);
|
||||||
let ship_ang = -ship_rot.angle(Vector2 { x: 0.0, y: 1.0 }); // TODO: inconsistent angles. Fix!
|
let ship_ang = -ship_rot.angle(Vector2 { x: 0.0, y: 1.0 }); // TODO: inconsistent angles. Fix!
|
||||||
|
@ -85,25 +85,18 @@ impl GPUState {
|
||||||
);
|
);
|
||||||
self.vertex_buffers.object_counter += 1;
|
self.vertex_buffers.object_counter += 1;
|
||||||
|
|
||||||
/*
|
let flare = ship.get_outfits().get_flare_sprite(state.content);
|
||||||
// Draw engine flares if necessary
|
if s.get_controls().thrust && flare.is_some() && !ship.is_dead() {
|
||||||
//if s.controls.thrust && !s.ship.is_dead() {
|
for engine_point in &ship_cnt.engines {
|
||||||
if s.controls.thrust {
|
|
||||||
for f in s.ship.outfits.iter_enginepoints() {
|
|
||||||
let flare = match s.ship.outfits.get_flare_sprite() {
|
|
||||||
None => continue,
|
|
||||||
Some(s) => s,
|
|
||||||
};
|
|
||||||
|
|
||||||
self.queue.write_buffer(
|
self.queue.write_buffer(
|
||||||
&self.global_uniform.object_buffer,
|
&self.global_uniform.object_buffer,
|
||||||
ObjectData::SIZE * self.vertex_buffers.object_counter as u64,
|
ObjectData::SIZE * self.vertex_buffers.object_counter as u64,
|
||||||
bytemuck::cast_slice(&[ObjectData {
|
bytemuck::cast_slice(&[ObjectData {
|
||||||
xpos: f.pos.x,
|
xpos: engine_point.pos.x,
|
||||||
ypos: f.pos.y - f.size / 2.0,
|
ypos: engine_point.pos.y - engine_point.size / 2.0,
|
||||||
zpos: 1.0,
|
zpos: 1.0,
|
||||||
angle: 0.0,
|
angle: 0.0,
|
||||||
size: f.size,
|
size: engine_point.size,
|
||||||
parent: idx as u32,
|
parent: idx as u32,
|
||||||
is_child: 1,
|
is_child: 1,
|
||||||
_padding: Default::default(),
|
_padding: Default::default(),
|
||||||
|
@ -122,14 +115,13 @@ impl GPUState {
|
||||||
&self.vertex_buffers.object.instances,
|
&self.vertex_buffers.object.instances,
|
||||||
ObjectInstance::SIZE * self.vertex_buffers.object_counter,
|
ObjectInstance::SIZE * self.vertex_buffers.object_counter,
|
||||||
bytemuck::cast_slice(&[ObjectInstance {
|
bytemuck::cast_slice(&[ObjectInstance {
|
||||||
sprite_index: flare.get_index(),
|
sprite_index: flare.unwrap().get_index(),
|
||||||
object_index: self.vertex_buffers.object_counter as u32,
|
object_index: self.vertex_buffers.object_counter as u32,
|
||||||
}]),
|
}]),
|
||||||
);
|
);
|
||||||
self.vertex_buffers.object_counter += 1;
|
self.vertex_buffers.object_counter += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn world_push_projectile(
|
pub(super) fn world_push_projectile(
|
||||||
|
|
|
@ -304,3 +304,10 @@ impl ShipWorldObject {
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ShipWorldObject {
|
||||||
|
/// Get this ship's control state
|
||||||
|
pub fn get_controls(&self) -> &ShipControls {
|
||||||
|
&self.controls
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue