<commit_before>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;

public class CustomFlatRideLoader : MonoBehaviour
{

    private List<BuildableObject> _sceneryObjects = new List<BuildableObject>();

    public string Path;
    public string Identifier;
    public FlatRide FlatRideComponent;


    public GameObject LoadAsset(string PrefabName)
    {
        try
        {

            GameObject asset = new GameObject();

            char dsc = System.IO.Path.DirectorySeparatorChar;

            using (WWW www = new WWW("file://" + Path + dsc + "assetbundle" + dsc + "flatrides"))
            {
                if (www.error != null)
                    throw new Exception("Loading had an error:" + www.error);

                AssetBundle bundle = www.assetBundle;


                try
                {
                    asset = Instantiate(bundle.LoadAsset(PrefabName)) as GameObject;
                    bundle.Unload(false);

                   
                    return asset;

                }

                catch (Exception e)
                {
                    Debug.Log(e);

                    LogException(e);
                    bundle.Unload(false);
                    return null;
                }



            }


        }
        catch (Exception e)
        {
            LogException(e);
            return null;
        }

    }
    public void SetWaypoints(GameObject asset, List<int> connections)
    {

        Waypoints points = asset.GetComponent<Waypoints>();
        foreach (Transform T in asset.transform.FindChild("WayPoints").transform)
        {
            Waypoint p = new Waypoint();

            if (T.name.StartsWith("Outer"))
            {
                p.isOuter = true;
            }
            else if (T.name.StartsWith("Point"))
            {
                p.isOuter = false;
            }
            else
            { return; }

            p.localPosition = T.localPosition;
            points.waypoints.Add(p);
            int currentIndex = points.waypoints.IndexOf(p);
            for (int i = 0; i < connections.Count; i += 2) // Loop with for.
            {
                if (connections[i] == currentIndex)
                {
                    points.waypoints[currentIndex].connectedTo.Add(connections[i + 1]);
                }
            }
            for (int i = 1; i < connections.Count; i += 2) // Loop with for.
            {
                if (connections[i] == currentIndex)
                {
                    points.waypoints[currentIndex].connectedTo.Add(connections[i - 1]);
                }
            }
            
        }
    }
    public void BasicFlatRideSettings(FlatRide FlatRideScript, string DisplayName, float price, float excitement, float intensity, float nausea, int x, int Z)
    {
        _sceneryObjects.Add(FlatRideScript);
        AssetManager.Instance.registerObject(FlatRideScript);
        FlatRideScript.fenceGO = AssetManager.Instance.rideFenceGO;
        FlatRideScript.entranceGO = AssetManager.Instance.rideEntranceGO;
        FlatRideScript.exitGO = AssetManager.Instance.rideExitGO;
        FlatRideScript.entranceExitBuilderGO = AssetManager.Instance.flatRideEntranceExitBuilderGO;
        FlatRideScript.price = price;
        FlatRideScript.excitementRating = excitement;
        FlatRideScript.intensityRating = intensity;
        FlatRideScript.nauseaRating = nausea;
        FlatRideScript.setDisplayName(DisplayName);
        FlatRideScript.xSize = x;
        FlatRideScript.zSize = Z;
       

        
    }
    public void AddRestraints(GameObject asset, Vector3 closeAngle)
    {
        RestraintRotationController controller = asset.AddComponent<RestraintRotationController>();<commit_msg>Update CustomFlatRideLoader.cs<commit_after>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;

public class CustomFlatRideLoader : MonoBehaviour
{

    private List<BuildableObject> _sceneryObjects = new List<BuildableObject>();

    public string Path;
    public string Identifier;
    public FlatRide FlatRideComponent;


    public GameObject LoadAsset(string PrefabName)
    {
        try
        {

            GameObject asset = new GameObject();

            char dsc = System.IO.Path.DirectorySeparatorChar;

            using (WWW www = new WWW("file://" + Path + dsc + "assetbundle" + dsc + "flatrides"))
            {
                if (www.error != null)
                    throw new Exception("Loading had an error:" + www.error);

                AssetBundle bundle = www.assetBundle;


                try
                {
                    asset = Instantiate(bundle.LoadAsset(PrefabName)) as GameObject;
                    bundle.Unload(false);

                   
                    return asset;

                }

                catch (Exception e)
                {
                    Debug.Log(e);

                    LogException(e);
                    bundle.Unload(false);
                    return null;
                }



            }


        }
        catch (Exception e)
        {
            LogException(e);
            return null;
        }

    }
    public void SetWaypoints(GameObject asset, List<int> connections)
    {

        Waypoints points = asset.GetComponent<Waypoints>();
        foreach (Transform T in asset.transform.FindChild("WayPoints").transform)
        {
            Waypoint p = new Waypoint();

            if (T.name.StartsWith("Outer"))
            {
                p.isOuter = true;
            }
            else if (T.name.StartsWith("Point"))
            {
                p.isOuter = false;
            }
            else
            { return; }

            p.localPosition = T.localPosition;
            points.waypoints.Add(p);
            int currentIndex = points.waypoints.IndexOf(p);
            for (int i = 0; i < connections.Count; i += 2) // Loop with for.
            {
                if (connections[i] == currentIndex)
                {
                    points.waypoints[currentIndex].connectedTo.Add(connections[i + 1]);
                }
            }
            for (int i = 1; i < connections.Count; i += 2) // Loop with for.
            {
                if (connections[i] == currentIndex)
                {
                    points.waypoints[currentIndex].connectedTo.Add(connections[i - 1]);
                }
            }
            
        }
    }
        public void BasicFlatRideSettings(FlatRide FlatRideScript, string DisplayName, float price, float excitement, float intensity, float nausea, int x, int Z)
    {
        _sceneryObjects.Add(FlatRideScript);
        AssetManager.Instance.registerObject(FlatRideScript);
        FlatRideScript.fenceGO = AssetManager.Instance.rideFenceGO;
        FlatRideScript.entranceGO = AssetManager.Instance.attractionEntranceGO;
        FlatRideScript.exitGO = AssetManager.Instance.attractionExitGO;
        FlatRideScript.entranceExitBuilderGO = AssetManager.Instance.flatRideEntranceExitBuilderGO;
        FlatRideScript.price = price;
        FlatRideScript.categoryTag = "Attractions/Flat Ride";
        FlatRideScript.excitementRating = excitement;
        FlatRideScript.intensityRating = intensity;
        FlatRideScript.nauseaRating = nausea;
        FlatRideScript.setDisplayName(DisplayName);
        FlatRideScript.xSize = x;
        FlatRideScript.zSize = Z;
       

        
    }
    public void AddRestraints(GameObject asset, Vector3 closeAngle)
    {
        RestraintRotationController controller = asset.AddComponent<RestraintRotationController>();
{'fraction_non_alphanumeric': 0.08620465479131452, 'fraction_numerical': 0.0018203094526069432, 'mean_word_length': 1.668054110301769, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2476979', 'n_tokens_mistral': 2158, 'n_tokens_neox': 1983, 'n_words': 407}