public void SpawnPet(UnturnedPlayer player, PlayerPet pet) { foreach (var activePet in GetPlayerActivePets(player.Id).ToArray()) { InvokeKillPet(activePet); } var point = player.Position; AnimalManager.spawnAnimal(pet.AnimalId, point, player.Player.transform.rotation); // remove animal spawn AnimalManager.packs.RemoveAll(x => x.spawns.Exists(y => y.point == point)); // I know it's crap and but that's the simplest way atm, please pr if you know better var animals = new List <Animal>(); AnimalManager.getAnimalsInRadius(player.Position, 1, animals); pet.Animal = animals.FirstOrDefault(x => x.asset.id == pet.AnimalId); pet.Player = player.Player; ActivePets.Add(pet); OnPetSpawned.TryInvoke(pet); }
public void SpawnPet(UnturnedPlayer player, PlayerPet pet) { foreach (var activePet in GetPlayerActivePets(player.Id).ToArray()) { KillPet(activePet); } pet.Animal = AnimalsHelper.SpawnAnimal(pet.AnimalId, player.Position, (byte)player.Rotation); pet.Player = player.Player; ActivePets.Add(pet); OnPetSpawned.TryInvoke(pet); }