Skip to content

Comments

Removed PlayerController from core. Added Controller:isPlayerControlled#169

Draft
MatthewBlanchard wants to merge 1 commit intomasterfrom
enhancement/commoncontrollerroot
Draft

Removed PlayerController from core. Added Controller:isPlayerControlled#169
MatthewBlanchard wants to merge 1 commit intomasterfrom
enhancement/commoncontrollerroot

Conversation

@MatthewBlanchard
Copy link
Member

@MatthewBlanchard MatthewBlanchard commented Aug 2, 2025

This removes the PlayerController from the core and puts it in the template. The Decision classes associated with it will remain in core, because eventually I want to move to having all Controllers use Decisions.

This facilitates creating a common Controller root class in your own projects. For instance say you wanted a Controller which works with the new extra/StatusEffects and respects overrides of the current controller, right now you would have to either manually manage controller components which is prone to bugs as multiple effects might override the controller.

Instead with this you could create a Controller Modification that overrides the current controller and a base class all Controllers in your game inherit from to provide this behavior, and status effects and similar things can override whether a controller is player controlled at any given moment.

This is a breaking change, but the fix on the user's end is not so bad. It requires the following file in their modules/game/components with no other changes:

--- A controller component that stops to wait for input to receive its action.
--- @class PlayerController : Controller
--- @overload fun(): PlayerController
--- @type PlayerController
local PlayerController = prism.components.Controller:extend "PlayerController"

---@param level Level
---@param actor Actor
function PlayerController:act(level, actor)
   local actionDecision = level:yield(prism.decisions.ActionDecision(actor))
   --- @cast actionDecision ActionDecision

   return actionDecision.action
end

function PlayerController:isPlayerControlled() return true end

return PlayerController

@MatthewBlanchard
Copy link
Member Author

Might want to stage this to r2 honestly because it's a fairly big API change. I'm considering r1 though since it's really not too painful for the user to convert to.

@MatthewBlanchard MatthewBlanchard marked this pull request as draft November 29, 2025 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant