cw_factory_garbage_plastic entity
Entity defined in entities/entities/cw_factory_garbage_plastic
Shared definition of the cw_factory_garbage_plastic entity, a spawnable garbage recycler that turns plastic junk
items into plastic items, with its settings, network vars and think logic.
ENT.GARBAGE_ITEMS lists the accepted items (empty_tin_can, empty_plastic_bottle and empty_jug),
ENT.METAL_GARBAGE_COUNT_START (8) is the garbage needed for a cycle and ENT.WORK_TIME (20) its length in
seconds. ENT:Think absorbs accepted cw_item entities above an idle recycler, each counting twice its weight,
drains the count during a cycle and calls ENT:EndWork when the time is up. The single-file
cw_factory_garbage_plastic.lua next to this folder defines the same class and is loaded after it.
Summary
Methods
plastic item at the product position.Methods
ENT:CanGarbageUsed(item)
server gamemodes/cwhl2rp/schema/entities/entities/cw_factory_garbage_plastic/init.lua:51Returns whether the recycler accepts an item as garbage.
Parameters
- item Item The item to check
Returns
- Boolean Whether the item's unique ID is in
ENT.GARBAGE_ITEMS
ENT:Draw()
client gamemodes/cwhl2rp/schema/entities/entities/cw_factory_garbage_plastic/cl_init.lua:72Draws the recycler and its indicator screen with the status, garbage count and progress bars.
While the local player holds the toolgun, a marker also shows the product position.
ENT:Eject()
server gamemodes/cwhl2rp/schema/entities/entities/cw_factory_garbage_plastic/init.lua:101Moves the collected garbage into the eject storage entity and empties the recycler.
The storage is found by the creation ID set with SetEjectStorage. Does nothing while working or
paused, when the storage does not exist or without the Storage plugin. Items that would push a known
container over its weight limit are dropped on top of it instead.
ENT:EndWork()
server gamemodes/cwhl2rp/schema/entities/entities/cw_factory_garbage_plastic/init.lua:166Finishes the cycle: stops the work sounds, uses up the collected garbage and spawns a plastic item at the
product position.
ENT:GetSearchPos()
server gamemodes/cwhl2rp/schema/entities/entities/cw_factory_garbage_plastic/init.lua:61Returns the corners of the box above the recycler that garbage is collected from.
Returns
- List<Vector> The minimum and maximum corners, as passed to
ents.FindInBox
ENT:Initialize()
shared gamemodes/cwhl2rp/schema/entities/entities/cw_factory_garbage_plastic/init.lua:13On the server
Sets up the recycler model, physics and empty garbage state.
On the client
Creates the render target and material for the indicator screen.
Defined in
ENT:OnRemove()
server gamemodes/cwhl2rp/schema/entities/entities/cw_factory_garbage_plastic/init.lua:190Stops the recycler's work sound.
ENT:SetupDataTables()
shared gamemodes/cwhl2rp/schema/entities/entities/cw_factory_garbage_plastic/shared.lua:39Declares the product position, garbage count, working state, work timing, eject storage and stop time network vars.
ENT:SpawnFunction(ply, trace)
server gamemodes/cwhl2rp/schema/entities/entities/cw_factory_garbage_plastic/init.lua:40Spawns a plastic recycler 25 units off the aimed surface.
Parameters
- ply
- trace
Returns
- Entity The spawned recycler
ENT:StartWork()
server gamemodes/cwhl2rp/schema/entities/entities/cw_factory_garbage_plastic/init.lua:76Starts a recycling cycle, or resumes a stopped one where it left off.
A new cycle only starts once the garbage count is at least ENT.METAL_GARBAGE_COUNT_START
and lasts ENT.WORK_TIME seconds.
ENT:StopWork()
server gamemodes/cwhl2rp/schema/entities/entities/cw_factory_garbage_plastic/init.lua:149Pauses the current cycle, remembering the time left, and stops the work sounds.
ENT:Think()
shared gamemodes/cwhl2rp/schema/entities/entities/cw_factory_garbage_plastic/shared.lua:53Collects garbage, plays the work sounds and advances the recycling cycle every tick on the server.
Garbage cw_item entities inside ENT:GetSearchPos are taken while the recycler is idle and not full.
During a cycle the garbage count drains step by step and ENT:EndWork runs when the time is up.
ENT:Use(activator)
server gamemodes/cwhl2rp/schema/entities/entities/cw_factory_garbage_plastic/init.lua:185Does nothing; the recycler is operated through its entity menu options.
Parameters
- activator