SHARE
TWEET

Untitled

a guest May 26th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --SynapseX Decompiler
  2.  
  3. local PetRenderingService = {}
  4. local Services = require(game.ReplicatedStorage.Assets.Modules.Services)
  5. local rs = Services:GetService("RunService")
  6. local ts = Services:GetService("TweenService")
  7. local SoundService = require(game.ReplicatedStorage.Assets.Modules.SoundService)
  8. local ShinyModifier = Services:GetService("Library")("ShinyModifier")
  9. local Pet = require(script.PetClass)
  10. PetRenderingService.PetClass = Pet
  11. local pets = {}
  12. local player = game.Players.LocalPlayer
  13. local v2 = Vector2.new
  14. local v2_dot = v2().Dot
  15. local function toV2(vec)
  16.     return v2(vec.X, vec.Z)
  17. end
  18. function PetRenderingService:CreatePet(plr, model, guid)
  19.     local origin = plr.Character.PrimaryPart.Position - Vector3.new(0, 2.5, 0)
  20.     if model.Shiny.Value == true then
  21.         ShinyModifier:Modify(model)
  22.     end
  23.     local pet = Pet.new(plr, model, guid)
  24.     pets[pet] = true
  25.     self:UpdateOffsets(plr)
  26.     pet:Spawn(origin)
  27.     if model.Name == "Beta TV" and not model.Decore.Screen:FindFirstChild("TVManager") then
  28.         spawn(function()
  29.             require(script.TVManager)(model)
  30.         end)
  31.     end
  32. end
  33. function PetRenderingService:RemovePet(plr, guid)
  34.     for pet in next, pets, nil do
  35.         if pet.Owner == plr and pet.GUID == guid then
  36.             pet:Destroy()
  37.             pets[pet] = nil
  38.             return
  39.         end
  40.     end
  41. end
  42. function PetRenderingService:UpdateOffsets(plr)
  43.     local theirs = {}
  44.     for pet in next, pets, nil do
  45.         if pet.Owner == plr then
  46.             theirs[#theirs + 1] = pet
  47.         end
  48.     end
  49.     local number = #theirs
  50.     local random = Random.new()
  51.     local angle = math.pi * 2 / number
  52.     for i = 1, number do
  53.         local pet = theirs[i]
  54.         pet.Offset = CFrame.Angles(0, angle * i + random:NextNumber(-angle * 0.3, angle * 0.3), 0) * Vector3.new(0, -2.5, pet.Radius)
  55.     end
  56. end
  57. local function levelUp(pet, level)
  58.     local glow = script.Glow:Clone()
  59.     glow.Parent = pet.PrimaryPart
  60.     glow:Emit(100)
  61.     local gui = script.LevelUp:Clone()
  62.     gui.Icon.ImageTransparency = 1
  63.     gui.Icon.Size = UDim2.new()
  64.     gui.Amount.TextTransparency = 1
  65.     gui.Amount.TextStrokeTransparency = 1
  66.     gui.Amount.Text = level
  67.     gui.Parent = pet.PrimaryPart
  68.     SoundService:Play({
  69.         Parent = pet.PrimaryPart,
  70.         Name = "LevelUp",
  71.         Volume = 0.25
  72.     })
  73.     local icon = gui:FindFirstChild("Icon")
  74.     if icon then
  75.         ts:Create(icon, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {
  76.             Rotation = 720,
  77.             ImageTransparency = 0,
  78.             Size = UDim2.new(1, 0, 1, 0)
  79.         }):Play()
  80.     end
  81.     wait(0.5)
  82.     local amt = gui:FindFirstChild("Amount")
  83.     if amt then
  84.         ts:Create(gui.Amount, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {TextTransparency = 0, TextStrokeTransparency = 0.5}):Play()
  85.         delay(1.5, function()
  86.             ts:Create(gui.Amount, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {TextTransparency = 1, TextStrokeTransparency = 1}):Play()
  87.             ts:Create(gui.Icon, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {ImageTransparency = 1}):Play()
  88.         end)
  89.     end
  90.     delay(2, function()
  91.         gui:Destroy()
  92.     end)
  93.     delay(5, function()
  94.         glow:Destroy()
  95.     end)
  96. end
  97. local function displayXP(pet, amount)
  98.     local xp = script.XP:Clone()
  99.     xp.Parent = pet.PrimaryPart
  100.     if amount == "MAXED" then
  101.         xp.Amount.Text = "MAX LEVEL!"
  102.     else
  103.         xp.Amount.Text = "+" .. amount
  104.     end
  105.     local del = math.random(75, 150) / 100
  106.     ts:Create(xp, TweenInfo.new(del, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0), {
  107.         StudsOffset = Vector3.new(0, 5, 0)
  108.     }):Play()
  109.     delay(del, function()
  110.         ts:Create(xp.Amount, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {TextTransparency = 1, TextStrokeTransparency = 1}):Play()
  111.         ts:Create(xp.Icon, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0), {ImageTransparency = 1}):Play()
  112.         wait(0.5)
  113.         xp:Destroy()
  114.     end)
  115. end
  116. function PetRenderingService:Initialize(Network)
  117.     for _, b in pairs(game.Workspace.Pets:GetChildren()) do
  118.         local owner = b.Owner.Value
  119.         local guid = b.GUID.Value
  120.         if owner and owner.Parent then
  121.             PetRenderingService:CreatePet(owner, b, guid)
  122.         else
  123.             b:Destroy()
  124.         end
  125.     end
  126.     Network:Bind("SpawnPet", function(plr, model, guid)
  127.         PetRenderingService:CreatePet(plr, model, guid)
  128.         self:UpdateOffsets(plr)
  129.     end)
  130.     Network:Bind("DespawnPet", function(plr, guid)
  131.         PetRenderingService:RemovePet(plr, guid)
  132.         self:UpdateOffsets(plr)
  133.     end)
  134.     Network:Bind("LevelPetUp", function(guid, level)
  135.         for pet in next, pets, nil do
  136.             if pet.Owner == player and pet.GUID == guid then
  137.                 levelUp(pet.Model, level)
  138.                 return
  139.             end
  140.         end
  141.     end)
  142.     Network:Bind("DisplayPetXP", function(xpTable)
  143.         for i = 1, #xpTable do
  144.             for pet in next, pets, nil do
  145.                 if pet.Owner == player and pet.GUID == xpTable[i][1] then
  146.                     displayXP(pet.Model, xpTable[i][2])
  147.                     break
  148.                 end
  149.             end
  150.         end
  151.     end)
  152.     rs:BindToRenderStep("PetRendering", Enum.RenderPriority.Character.Value + 1, function(dt)
  153.         for pet in next, pets, nil do
  154.             if not pet.Owner.Parent then
  155.                 pet:Destroy()
  156.                 pets[pet] = nil
  157.             else
  158.                 pet:Update()
  159.             end
  160.         end
  161.     end)
  162. end
  163. game.Players.PlayerRemoving:Connect(function(Player)
  164.     for pet in next, pets, nil do
  165.         if pet.Owner == Player then
  166.             pet:Destroy()
  167.             pets[pet] = nil
  168.         end
  169.     end
  170. end)
  171. return PetRenderingService
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top