mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 23:52:35 +00:00
Implemented event system, Implemented initial bit of scripting system, Stubbed component system. Entities can now use the scripting system to place their 'decorations'
This commit is contained in:
@@ -91,10 +91,10 @@ class IMICFPS
|
||||
vs = a
|
||||
vs = b if a == entity
|
||||
|
||||
broadphase = search(Ray.new(entity.position, Vector.new(0, -1, 0), entity.velocity.y.abs))
|
||||
broadphase = search(Ray.new(entity.position, Vector.down, entity.velocity.y.abs))
|
||||
|
||||
broadphase.detect do |ent|
|
||||
ray = Ray.new(entity.position - ent.position, Vector.new(0, -1, 0))
|
||||
ray = Ray.new(entity.position - ent.position, Vector.down)
|
||||
if ent.model.aabb_tree.search(ray).size > 0
|
||||
on_ground = true
|
||||
return true
|
||||
|
||||
@@ -2,9 +2,15 @@ class IMICFPS
|
||||
module EntityManager # Get included into GameState context
|
||||
def add_entity(entity)
|
||||
@collision_manager.add(entity)# Add every entity to collision manager
|
||||
@publisher.publish(:create, self, entity)
|
||||
@entities << entity
|
||||
end
|
||||
|
||||
def insert_entity(package, name, position, orientation, data = {})
|
||||
ent = Map::Entity.new(package, name, position, orientation, Vector.new(1,1,1))
|
||||
add_entity(IMICFPS::Entity.new(map_entity: ent, manifest: Manifest.new(package: package, name: name)))
|
||||
end
|
||||
|
||||
def find_entity(entity)
|
||||
@entities.detect {|entity| entity == entity}
|
||||
end
|
||||
@@ -13,6 +19,7 @@ class IMICFPS
|
||||
ent = @entities.detect {|entity| entity == entity}
|
||||
if ent
|
||||
@collision_manager.remove(entity)
|
||||
@publisher.publish(:destroy, self, entity)
|
||||
@entities.delete(ent)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -115,6 +115,8 @@ IMICFPS::InputMapper.set(:jump, Gosu::KbSpace)
|
||||
IMICFPS::InputMapper.set(:sprint, [Gosu::KbLeftControl])
|
||||
IMICFPS::InputMapper.set(:turn_180, Gosu::KbX)
|
||||
|
||||
IMICFPS::InputMapper.set(:interact, Gosu::KbE)
|
||||
|
||||
IMICFPS::InputMapper.set(:ascend, Gosu::KbSpace)
|
||||
IMICFPS::InputMapper.set(:descend, Gosu::KbC)
|
||||
IMICFPS::InputMapper.set(:toggle_first_person_view, Gosu::KbF)
|
||||
|
||||
Reference in New Issue
Block a user