Hooks that can be overriden on the DREAMS metatable
SERVER
DREAMS:ThinkSelf
()
SERVER
Called before any player think, allows for updating ent positions & dream variables
DREAMS:EntityTakeDamage
(ply, attacker, inflictor, dmg)
SERVER
Called when the player takes damage from anything, including things outside of Dreams
Return true
to block
return Dreams.Meta.EntityTakeDamage(self, ply, attacker, inflictor, dmg)
- Will prevent anything but players in dreams from hurting other dreaming players
CLIENT
DREAMS:Draw
(ply: LocalPlayer)
CLIENT
Called during RenderScene after SetupFog and CalcView, provides a 3D camera space. Draw other clientside models or effects here
Dreams.Meta.Draw(self, ply, DEBUG)
- Automatically draws the room the player is in and other players
- DEBUG will draw the bounding boxes of all solids if set to 1, Face normals if set to 2, and Face Normals and the Bounding Boxes if set to 3
DREAMS:DrawHUD
(ply: LocalPlayer, w, h)
CLIENT
Called during RenderScene after all other render hooks and provides a 2D camera space
Dreams.Meta.DrawHUD(self, ply, w, h)
DREAMS:HUDShouldDraw
(ply: LocalPlayer, HUDElement: str)
CLIENT
Allows you to prevent default HUD elements from being rendered. See GM:HUDShouldDraw
Return false
to prevent drawing the element
DREAMS:CalcView
(ply: LocalPlayer, view: table)
CLIENT
Calculates the players view position by edting the table, see Structures/CamData
Dreams.Meta.CalcView(self, ply, view) --(no return necessary)
- Calculates the players view at their position with the default height (64 hmu)
DREAMS:RenderScene
(ply: LocalPlayer)
CLIENT
Draws Dreams in it’s entirety. You can do more advanced post processing effects here
function DREAMS:RenderScene(ply)
local view = {
origin = origin,
angles = angles,
fov = fov,
}
if not self:SetupFog(ply) then render.FogMode(MATERIAL_FOG_NONE) end
self:CalcView(ply, view)
cam.Start3D(view.origin, view.angles, view.fov, 0, 0, ScrW(), ScrH())
self:Draw(ply)
cam.End3D()
cam.Start2D()
self:DrawHUD(ply, ScrW(), ScrH())
cam.End2D()
return true
end
DREAMS:SetupFog
(ply: LocalPlayer)
CLIENT
Works like GM:SetupWorldFog(), use render.Fog* functions and return true
to finish setting up fog
DREAMS:EntityEmitSound
(tbl)
CLIENT
Allows manipulation of clientside sounds while dreaming. Return false
to prevent
See GM:EntityEmitSound
Due to EmitSounds limitations, not all sounds can be accessed or prevented, which is extremely unfortunate
return Dreams.Meta.EntityEmitSound(self, tbl)
- Will prevent all sounds except those emitted from LocalPlayer()
SHARED
DREAMS:Think
(ply)
SHARED
Called once for every player on Server and the LocalPlayer on Client during the Think hook
DREAMS:Start
(ply)
SHARED
Called when a player starts a dream on Server or the LocalPlayer on Client. Responsible for player setup serverside
Dreams.Meta.Start(self, ply)
- Setups the player’s positioning in the real world so the player can be networked. You would normally want to call this unless you know what your doing
DREAMS:End
(ply)
SHARED
Called when a player ends a dream on Server or the LocalPlayer on Client.
DREAMS:SwitchWeapon
(ply, old, new)
SHARED
PREDICTED
Return true
to prevent the player from switching their weapon. Switching to nothing will still call this hook
Dreams.Meta.SwitchWeapon(self, ply, old, new)
- Prevents the player from switching to anything except nothing
DREAMS:SetupDataTables
()
SHARED
If defined, will automatically create a DREAMS.NetEntity for easy networking.
Will be available right before DREAMS:Init() and re-created if cleaned up
Use self:NetworkVar(type, slot, name) to create Get(name) & Set(name) functions
Int Slot 31 is reserved to mark the dreams_entity to the associated dream
Move Hooks
DREAMS:StartMove
(ply, mv, cmd)
SHARED
PREDICTED
Called at the start of a move command, setup the players velocity and process their input here.
Must return true
See GM:SetupMove
- StartMove can be replaced with DREAMS.StartMoveFly ex.
DREAMS.StartMove = DREAMS.StartMoveFly
either for debugging or for gameplay - Dreams.Meta.StartMove can be called with extra parameters
jump
andgrav
to override DREAMS default valuesDREAMS:DoMove
(ply, mv)
SHARED
PREDICTED
Called to setup the origin of a move command, all collisions are done here.
DREAMS:FinishMove
(ply, mv)
SHARED
PREDICTED
Called to set movement data to the player