mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 23:52:35 +00:00
Ran rubocop autocorrect
This commit is contained in:
@@ -1,34 +1,35 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class IMICFPS
|
||||
class Manifest
|
||||
attr_reader :name, :model, :collision, :collision_mesh, :collision_resolution, :physics, :scripts, :uses
|
||||
def initialize(manifest_file: nil, package: nil, name: nil)
|
||||
|
||||
def initialize(manifest_file: nil, package: nil, name: nil)
|
||||
unless manifest_file
|
||||
raise "Entity package not specified!" unless package
|
||||
raise "Entity name not specified!" unless name
|
||||
|
||||
manifest_file = "#{IMICFPS.assets_path}/#{package}/#{name}/manifest.yaml"
|
||||
end
|
||||
|
||||
raise "No manifest found at: #{manifest_file}" unless File.exist?(manifest_file)
|
||||
|
||||
raise "No manifest found at: #{manifest_file}" unless File.exist?(manifest_file)
|
||||
|
||||
@file = manifest_file
|
||||
parse(manifest_file)
|
||||
end
|
||||
|
||||
def parse(file)
|
||||
data = YAML.load(File.read(file))
|
||||
data = YAML.safe_load(File.read(file))
|
||||
|
||||
# required
|
||||
@name = data["name"]
|
||||
@model = data["model"]
|
||||
|
||||
# optional
|
||||
@collision = data["collision"] ? data["collision"] : nil
|
||||
@collision_mesh = data["collision_mesh"] ? data["collision_mesh"] : nil
|
||||
@collision = data["collision"] || nil
|
||||
@collision_mesh = data["collision_mesh"] || nil
|
||||
@collision_resolution = data["collision_resolution"] ? data["collision_resolution"].to_sym : :static
|
||||
@physics = data["physics"] ? data["physics"] : false
|
||||
@physics = data["physics"] || false
|
||||
@scripts = data["scripts"] ? parse_scripts(data["scripts"]) : []
|
||||
@uses = data["uses"] ? parse_dependencies(data["uses"]) : [] # List of entities that this Entity uses
|
||||
end
|
||||
@@ -40,7 +41,7 @@ class IMICFPS
|
||||
|
||||
if script.start_with?("!")
|
||||
script = script.sub("!", "")
|
||||
path = File.expand_path("../shared/", file_path) + "/scripts/" + script
|
||||
path = "#{File.expand_path('../shared/', file_path)}/scripts/#{script}"
|
||||
else
|
||||
path = "#{file_path}/scripts/#{script}"
|
||||
end
|
||||
@@ -48,7 +49,7 @@ class IMICFPS
|
||||
list << Script.new(script, File.read("#{path}.rb"))
|
||||
end
|
||||
|
||||
return list
|
||||
list
|
||||
end
|
||||
|
||||
def parse_dependencies(list)
|
||||
@@ -57,7 +58,7 @@ class IMICFPS
|
||||
dependencies << Dependency.new(item["package"], item["name"])
|
||||
end
|
||||
|
||||
return dependencies
|
||||
dependencies
|
||||
end
|
||||
|
||||
def file_path
|
||||
|
||||
Reference in New Issue
Block a user