lib/gamefic/plot/entities.rb in gamefic-1.6.0 vs lib/gamefic/plot/entities.rb in gamefic-1.7.0
- old
+ new
@@ -16,10 +16,22 @@
if ent.kind_of?(Entity) == false
raise "Invalid entity class"
end
p_entities.push ent
p_dynamic.push ent if running?
- ent.playbook = playbook if ent.kind_of?(Character)
+ ent
+ end
+
+ # Cast an active entity.
+ # This method is similar to make, but it also provides the plot's
+ # playbook to the entity so it can perform actions. The entity should
+ # either be a kind of Gamefic::Actor or include the Gamefic::Active
+ # module.
+ #
+ # @return [Gamefic::Actor, Gamefic::Active]
+ def cast cls, args = {}, &block
+ ent = make cls, args, &block
+ ent.playbooks.push playbook
ent
end
def destroy entity
if p_dynamic.include?(entity)