| |
|
| |
|
| | local CollectionService = game:GetService("CollectionService")
|
| | local ReplicatedStorage = game:GetService("ReplicatedStorage")
|
| |
|
| | local MutationConfig = require(ReplicatedStorage:WaitForChild("Shared"):WaitForChild("MutationConfig"))
|
| |
|
| | local function applyMutation(treeModel, hazardType)
|
| | local config = MutationConfig.Hazards[hazardType]
|
| | if not config then return end
|
| |
|
| |
|
| | treeModel:SetAttribute("Mutated", hazardType)
|
| |
|
| | for _, part in pairs(treeModel:GetDescendants()) do
|
| | if part:IsA("BasePart") and CollectionService:HasTag(part, "TreeSegment") then
|
| | part:SetAttribute("TreeType", config.ModifiedType)
|
| | part.Material = config.Material
|
| | part.Color = config.Color
|
| |
|
| |
|
| | if hazardType == "Toxic" then
|
| | local particles = Instance.new("ParticleEmitter")
|
| | particles.Color = ColorSequence.new(config.Color)
|
| | particles.Size = NumberSequence.new(0.5, 0)
|
| | particles.Rate = 5
|
| | particles.Parent = part
|
| | end
|
| | end
|
| | end
|
| | end
|
| |
|
| |
|
| | local function scanForMutations()
|
| | for _, hazardZone in pairs(CollectionService:GetTagged("HazardZone")) do
|
| | local hazardType = hazardZone:GetAttribute("HazardType")
|
| | local config = MutationConfig.Hazards[hazardType]
|
| |
|
| | if config then
|
| |
|
| | for _, tree in pairs(CollectionService:GetTagged("TreeModel")) do
|
| | if not tree:GetAttribute("Mutated") then
|
| | local distance = (tree.PrimaryPart.Position - hazardZone.Position).Magnitude
|
| | if distance <= config.Radius then
|
| | if math.random() <= config.MutationChance then
|
| | applyMutation(tree, hazardType)
|
| | end
|
| | end
|
| | end
|
| | end
|
| | end
|
| | end
|
| | end
|
| |
|
| |
|
| | task.delay(5, scanForMutations)
|
| |
|