System cleanup
parent
bcf10e416b
commit
d5f0cbd678
|
@ -113,6 +113,8 @@ pub struct Content {
|
||||||
|
|
||||||
/// Textures
|
/// Textures
|
||||||
pub textures: Vec<part::texture::Texture>,
|
pub textures: Vec<part::texture::Texture>,
|
||||||
|
/// Map strings to texture names.
|
||||||
|
/// This is only necessary because we need to hard-code a few texture names for UI elements.
|
||||||
texture_index: HashMap<String, handle::TextureHandle>,
|
texture_index: HashMap<String, handle::TextureHandle>,
|
||||||
/// The texture to use for starfield stars
|
/// The texture to use for starfield stars
|
||||||
starfield_handle: Option<handle::TextureHandle>,
|
starfield_handle: Option<handle::TextureHandle>,
|
||||||
|
@ -127,7 +129,7 @@ pub struct Content {
|
||||||
ships: Vec<part::ship::Ship>,
|
ships: Vec<part::ship::Ship>,
|
||||||
|
|
||||||
/// Star systems
|
/// Star systems
|
||||||
pub systems: Vec<part::system::System>,
|
systems: Vec<part::system::System>,
|
||||||
|
|
||||||
/// Factions
|
/// Factions
|
||||||
factions: Vec<part::faction::Faction>,
|
factions: Vec<part::faction::Faction>,
|
||||||
|
|
|
@ -7,7 +7,11 @@
|
||||||
mod outfits;
|
mod outfits;
|
||||||
mod projectile;
|
mod projectile;
|
||||||
mod ship;
|
mod ship;
|
||||||
|
mod system;
|
||||||
|
mod systemobject;
|
||||||
|
|
||||||
pub use outfits::{OutfitSet, OutfitStatSum, ShipGun};
|
pub use outfits::{OutfitSet, OutfitStatSum, ShipGun};
|
||||||
pub use projectile::Projectile;
|
pub use projectile::Projectile;
|
||||||
pub use ship::Ship;
|
pub use ship::Ship;
|
||||||
|
pub use system::System;
|
||||||
|
pub use systemobject::SystemObject;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use super::SystemObject;
|
use crate::SystemObject;
|
||||||
use crate::content;
|
use galactica_content as content;
|
||||||
use galactica_render::ObjectSprite;
|
use galactica_render::ObjectSprite;
|
||||||
|
|
||||||
pub struct System {
|
pub struct System {
|
||||||
|
@ -8,13 +8,14 @@ pub struct System {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl System {
|
impl System {
|
||||||
pub fn new(ct: &content::System) -> Self {
|
pub fn new(ct: &content::Content, handle: content::SystemHandle) -> Self {
|
||||||
|
let sys = ct.get_system(handle);
|
||||||
let mut s = System {
|
let mut s = System {
|
||||||
name: ct.name.clone(),
|
name: sys.name.clone(),
|
||||||
bodies: Vec::new(),
|
bodies: Vec::new(),
|
||||||
};
|
};
|
||||||
|
|
||||||
for o in &ct.objects {
|
for o in &sys.objects {
|
||||||
s.bodies.push(SystemObject {
|
s.bodies.push(SystemObject {
|
||||||
pos: o.position,
|
pos: o.position,
|
||||||
sprite_texture: o.sprite_texture,
|
sprite_texture: o.sprite_texture,
|
|
@ -1,6 +1,6 @@
|
||||||
use cgmath::{Deg, Point3};
|
use cgmath::{Deg, Point3};
|
||||||
|
|
||||||
use crate::content;
|
use galactica_content as content;
|
||||||
use galactica_render::ObjectSprite;
|
use galactica_render::ObjectSprite;
|
||||||
|
|
||||||
pub struct SystemObject {
|
pub struct SystemObject {
|
|
@ -1,8 +1,9 @@
|
||||||
use cgmath::{Deg, InnerSpace, Point2};
|
use cgmath::{Deg, InnerSpace, Point2};
|
||||||
|
use content::SystemHandle;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use winit::event::{ElementState, MouseButton, MouseScrollDelta, TouchPhase, VirtualKeyCode};
|
use winit::event::{ElementState, MouseButton, MouseScrollDelta, TouchPhase, VirtualKeyCode};
|
||||||
|
|
||||||
use super::{camera::Camera, system::System};
|
use super::camera::Camera;
|
||||||
use crate::{content, inputstatus::InputStatus};
|
use crate::{content, inputstatus::InputStatus};
|
||||||
use galactica_constants;
|
use galactica_constants;
|
||||||
use galactica_gameobject as object;
|
use galactica_gameobject as object;
|
||||||
|
@ -70,7 +71,7 @@ pub struct Game {
|
||||||
pub input: InputStatus,
|
pub input: InputStatus,
|
||||||
pub last_update: Instant,
|
pub last_update: Instant,
|
||||||
pub player: ShipPhysicsHandle,
|
pub player: ShipPhysicsHandle,
|
||||||
pub system: System,
|
pub system: object::System,
|
||||||
pub camera: Camera,
|
pub camera: Camera,
|
||||||
paused: bool,
|
paused: bool,
|
||||||
pub time_scale: f32,
|
pub time_scale: f32,
|
||||||
|
@ -142,7 +143,7 @@ impl Game {
|
||||||
pos: (0.0, 0.0).into(),
|
pos: (0.0, 0.0).into(),
|
||||||
zoom: 500.0,
|
zoom: 500.0,
|
||||||
},
|
},
|
||||||
system: System::new(&ct.systems[0]),
|
system: object::System::new(&ct, SystemHandle { index: 0 }),
|
||||||
|
|
||||||
paused: false,
|
paused: false,
|
||||||
time_scale: 1.0,
|
time_scale: 1.0,
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
//! This module contains high-level game control logic.
|
//! This module is responsible for high-level game control logic.
|
||||||
|
|
||||||
mod camera;
|
mod camera;
|
||||||
mod game;
|
mod game;
|
||||||
mod system;
|
|
||||||
mod systemobject;
|
|
||||||
|
|
||||||
pub use game::Game;
|
pub use game::Game;
|
||||||
pub use systemobject::SystemObject;
|
|
||||||
|
|
Loading…
Reference in New Issue