Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions docs/source/making-a-roguelike/part13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ the individual pieces like +5 maxhp. You can subclass this to define a new named
--- @module "modules.game.statusinstance"
prism.GameStatusInstance = require ("modules.game.statusinstance")

The path string manipulation is just so that this file loads correctly now matter which folder our module is loaded from, that won't matter here,
but it's a good idea to do this.

Modifying health
----------------

Expand Down
7 changes: 7 additions & 0 deletions engine/core/components/controller.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@ function Controller:act(level, actor)
error("Controller is an abstract class and must have act overwritten!")
end

--- Returns a boolean indiciating if this actor is currently player controlled.
--- This is used by displays to indicate whether to draw this actor's perspective.
--- @return boolean isPlayerControlled
function Controller:isPlayerControlled()
return false
end

return Controller
16 changes: 0 additions & 16 deletions engine/core/components/player_controller.lua

This file was deleted.

2 changes: 1 addition & 1 deletion engine/core/decisions/actiondecision.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--- Represents an action to be taken, generally by the player.
--- :lua:class:`PlayerController` yields one to decide what action to perform.
--- :lua:class:`PlayerController` from the template yields one to decide what action to perform.
--- @class ActionDecision : Decision
--- @field actor Actor The actor making the decision.
--- @field action Action|nil The action to perform.
Expand Down
4 changes: 2 additions & 2 deletions engine/core/systems/senses.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local SensesSystem = prism.System:extend("SensesSystem")
SensesSystem.name = "Senses"

function SensesSystem:onTurn(level, actor)
if actor:has(prism.components.PlayerController) then return end
if actor:get(prism.components.Controller):isPlayerControlled() then return end
self:triggerRebuild(level, actor)
end

Expand All @@ -17,7 +17,7 @@ end
---@param event Message
function SensesSystem:onYield(level, event)
for actor in level:query(prism.components.Senses):iter() do
if actor:get(prism.components.PlayerController) then self:triggerRebuild(level, actor) end
if actor:get(prism.components.Controller):isPlayerControlled() then self:triggerRebuild(level, actor) end
end
end

Expand Down
3 changes: 0 additions & 3 deletions engine/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,6 @@ prism.components.Collider = prism.require "core.components.collider"
--- @module "engine.core.components.controller"
prism.components.Controller = prism.require "core.components.controller"

--- @module "engine.core.components.player_controller"
prism.components.PlayerController = prism.require "core.components.player_controller"

--- @module "engine.core.components.senses"
prism.components.Senses = prism.require "core.components.senses"

Expand Down
11 changes: 7 additions & 4 deletions spectrum/gamestates/levelstate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function LevelState:getSenses()
---@cast actionDecision ActionDecision
curActor = actionDecision.actor
elseif self.message then
if self.message.action.owner:has(prism.components.PlayerController) then
if self.message.action.owner:get(prism.components.Controller):isPlayerControlled() then
curActor = self.message.action.owner
end
end
Expand All @@ -78,9 +78,12 @@ function LevelState:getSenses()
local primary = { sensesComponent }
local secondary = {}

local query = self.level:query(prism.components.PlayerController, prism.components.Senses)
for _, _, senses in query:iter() do
table.insert(secondary, senses)
local query = self.level:query(prism.components.Controller, prism.components.Senses)
for _, controller, senses in query:iter() do
--- @cast controller Controller
if controller:isPlayerControlled() then
table.insert(secondary, senses)
end
end

if #primary == 0 then
Expand Down