A generalized replication system for jecs that allows for easy and fast replication of components.
Example in examples/replication.luau
for how to use it. Here are some explanations and basic types:
feces.init :: (Jecs.World) -> ()
feces.replicated :: Jecs.Component<{Player} | Player?>
-- feces.replicated is readonly
init()
should be obvious as to what it does, if the world is not set there will be warnings in the console.
replicated
is the component used to mark entities that should be replicated by simply adding it to an entity, or replicate specific components by pairing it with the type of component.
If a list of players or a single player is provided, the component will only replicate to those players. This value is not meant to change at runtime and could cause issues if changed.
feces.getPackets :: () -> (() -> (number?, Packet?))
feces.getFullPacket :: () -> Packet
getPackets()
returns an iterator to loop through all the packets at that frame
getFullPacket()
returns all public entities and components at this frame (useful for giving new players a payload on join)
feces.applyPackets :: (EntityChanges) -> ()
feces.filterPackets :: (EntityChanges, ...: component<any>) -> ({ entity<any> }, { component<any> })
applyPackets()
applies the packets to the world
filterPackets()
filters the packets to only the components you want to replicate
Either copy the code manually or use pesde:
pesde add neond00m/feces