DropletUtil
Internal utility functions for droplets
Types
WeightedArray<T>
type WeightedArray<T> = {{Weight: number,Value: T}}
A table of values with weights. The weights are used to calculate the probability
of a value being chosen. The weights do not need to add up to 1. See ProbabilityDistributor
for more information.
NumOrRange
NumOrRangeOrWeightedArray
ResourceTypeData
interface ResourceTypeData {Defaults: table}-
[Defaults]is a table of default values for the droplet. This can be left empty. The values in this table are used to fill in any missing values in the ResourceSpawnData when a droplet is spawned as well as overriding certain behaviors internally for things like magnetization. -
CollectionRadius- Distance from the player's center that the droplet must be to be collected -
MagnetizationRadius- Distance from the player at which the droplet starts moving towards them -
MustSettleBeforeCollect- If true, droplet must come to a complete stop before it can be claimed -
[SetupDroplet]is called when a new droplet is created. Use this to setup your visuals and any variables you need to keep track of. All parts within this should beAnchored = false, CanCollide = false, and Massless = true. The return value of this function can be accessed via Droplet:GetSetupData() -
[OnRenderUpdate]is called every frame that the droplet is within render range of the LocalPlayer's Camera. Use this to update the visuals of your droplet. The return value, if one is given, must be a CFrame and is used for offsetting the droplet. -
[OnDropletTimeout]is called when the droplet times out. Use this to perform/cleanup any visual effects you may have. -
[OnClientClaim]is called when the server acknowledges that the droplet has been claimed. -
[OnClientCollect]is called when the droplet hits the player and is considered collected. It should be used for collection effects and other client side things. -
[OnServerCollect]is called once the server is informed by a client that the droplet has been collected. This is where you should perform any server side logic like actually giving things like Money or Exp.
ResourceSpawnData
interface ResourceSpawnData {ResourceType: string--
The registered name of the resource type
Metadata: any?--
The metadata of the droplet
EjectionHorizontalVelocity: NumOrRangeOrWeightedArray?--
The horizontal velocity of the droplets when they are ejected (perpendicular to ejection direction)
EjectionVerticalVelocity: NumOrRangeOrWeightedArray?--
The vertical velocity of the droplets when they are ejected (along ejection direction)
}Special Behaviors
Any index that takes a NumOrRangeOrWeightedArray will be parsed and calculated
ahead of time internally so that the client and server are synced. For example,
if you pass in a NumberRange for Value, the server will calculate a random
decimal number between the min and max, this number would then be accessed by
Droplet:GetValue() on the client.
CollectorMode
type CollectorMode = "MultiCollector" | "SingleCollector"The behavior of how the droplet is claimed.
-
MultiCollector- Many players can collect this droplet, each has their own individual instance -
SingleCollector- Only one player can collect this droplet
Properties
Enums
DEFAULT_COLLECTOR_MODE
This item only works when running on the server. ServerDropletUtil.DEFAULT_COLLECTOR_MODE: CollectorModeThe default collector mode for droplets
DEFAULT_COUNT
This item only works when running on the server. ServerDropletUtil.DEFAULT_COUNT: NumOrRangeOrWeightedArrayThe default number of droplets to spawn
DEFAULT_LIFETIME
This item only works when running on the server. ServerDropletUtil.DEFAULT_LIFETIME: NumOrRangeOrWeightedArrayThe default lifetime for droplets
DEFAULT_EJECTION_DURATION
This item only works when running on the server. ServerDropletUtil.DEFAULT_EJECTION_DURATION: numberThe default ejection duration for droplets.
DEFAULT_COLLECTION_RADIUS
This item only works when running on the client. ClientDropletUtil.DEFAULT_COLLECTION_RADIUS: numberThe default radius within which droplets are marked for collection.
MAX_MAGNETIZATION_RADIUS
This item only works when running on the client. ClientDropletUtil.MAX_MAGNETIZATION_RADIUS: numberThe radius within which droplets are allowed to magnetize towards players. Beyond this radius, droplets will not magnetize and will just be instantly collected. This is to prevent wildly swinging droplets that gain tons of acceleration from far away.
RENDER_RADIUS
This item only works when running on the client. ClientDropletUtil.RENDER_RADIUS: numberThe radius within which droplets will have their render functions called
PLAYER_MASS
This item only works when running on the client. ClientDropletUtil.PLAYER_MASS: numberThe default player mass for gravitational calculations