Beispiel #1
0
    private void Awake()
    {
        kplane = GetComponent <KinematicPlane>();
        actor  = GetComponent <Actor>();

        if (kplane != null)
        {
            kplane.enabled = false;
            Debug.Log("Dissabled kplane on " + gameObject.name);
        }
        else
        {
            Debug.Log("Could not find kplane on " + gameObject.name);
        }

        rb             = GetComponent <Rigidbody>();
        rb.isKinematic = true;

        FloatingOriginTransform originTransform = GetComponent <FloatingOriginTransform>();

        if (originTransform == null)
        {
            originTransform = gameObject.AddComponent <FloatingOriginTransform>();
        }

        originTransform.SetRigidbody(rb);

        Networker.RigidbodyUpdate += RigidbodyUpdate;
    }
    private void Reparent()
    {
        GameObject go = new GameObject();

        Transform childTf = go.transform;

        childTf.position = transform.position;
        childTf.rotation = transform.rotation;

        childRb               = go.AddComponent <Rigidbody>();
        childRb.isKinematic   = true;
        childRb.interpolation = RigidbodyInterpolation.Interpolate;

        FloatingOriginTransform fo = go.AddComponent <FloatingOriginTransform>();

        fo.SetRigidbody(childRb);



        Actor[] actors = GetComponentsInChildren <Actor>(true);
        foreach (Actor actor in actors)
        {
            actor.SetParentRigidbody(childRb);
            Debug.Log($"Set rigidbody on actor: {actor.gameObject.name}");
        }
        Gun[] guns = GetComponentsInChildren <Gun>(true);
        foreach (Gun gun in guns)
        {
            gun.SetParentRigidbody(childRb);
            Debug.Log($"Set rigidbody on gun: {gun.gameObject.name}");
        }
        CarrierCatapult[] cats = GetComponentsInChildren <CarrierCatapult>(true);
        foreach (CarrierCatapult cat in cats)
        {
            cat.parentRb = childRb;
            Debug.Log($"Set rigidbody on cat: {cat.gameObject.name}");
        }
        MovingPlatform[] platforms = GetComponentsInChildren <MovingPlatform>(true);
        foreach (MovingPlatform platform in platforms)
        {
            platform.SetParentRigidbody(childRb);
            Debug.Log($"Set rigidbody on platform: {platform.gameObject.name}");
        }
        //Runway[] runways = GetComponentsInChildren<Runway>();
        //foreach (Runway runway in runways)
        //{
        //    runway.parentActor = childRb;
        //}


        int childCount = tf.childCount;

        for (int i = 0; i < childCount; i++)
        {
            tf.GetChild(0).parent = childTf;
        }

        childTf.parent = transform;
    }
    void CreateComponents()
    {
        MyProfiler.BeginSample("Procedural Planet / ChunkRenderer / CreateComponents");

        meshFilter        = gameObject.AddComponent <MeshFilter>();
        floatingTransform = gameObject.AddComponent <FloatingOriginTransform>();
        meshRenderer      = gameObject.AddComponent <MeshRenderer>();
        meshCollider      = gameObject.AddComponent <MeshCollider>();

        MyProfiler.EndSample();
    }
Beispiel #4
0
    void Start()
    {
        ProceduralPlanets.main.AddPlanet(this);
        InitializeRootChildren();
        GeneratePlanetData();

        floatingOrigin = GetComponent <FloatingOriginTransform>();

        craters.cpuBuffer = new Vector4[100];
        craters.gpuBuffer = new ComputeBuffer(craters.cpuBuffer.Length, 4 * sizeof(float));
    }
    private void Awake()
    {
        rb = GetComponent <Rigidbody>();
        FloatingOriginTransform originTransform = GetComponent <FloatingOriginTransform>();

        if (originTransform == null)
        {
            originTransform = gameObject.AddComponent <FloatingOriginTransform>();
        }
        originTransform.SetRigidbody(rb);
        Networker.RigidbodyUpdate += RigidbodyUpdate;
    }
Beispiel #6
0
    // Use this for initialization
    void Start()
    {
        rigidbody        = GetComponent <Rigidbody>();
        floatingOrigin   = GetComponent <FloatingOriginTransform>();
        previousVelocity = CurrentVelocity;

        connectedThrusters    = GetComponentsInChildren <ThrusterObject>();
        shipRoot_centerOfMass = ShipRoot.InverseTransformPoint(rigidbody.worldCenterOfMass);;

        foreach (var thruster in connectedThrusters)
        {
            thruster.Initialize(shipRoot_centerOfMass);
        }
    }
Beispiel #7
0
    void Start()
    {
        floatingOrigin = GetComponent <FloatingOriginTransform>();

        physicMaterial = new PhysicMaterial()
        {
            frictionCombine = PhysicMaterialCombine.Minimum,
            bounceCombine   = PhysicMaterialCombine.Minimum,
        };

        foreach (var c in GetComponentsInChildren <Collider>())
        {
            c.sharedMaterial = physicMaterial;
        }

        MoveToClosestPlanetSurface();

        UpdatePosition(0.1f);         // spool up
    }
    void SpawnRandomAircraft(Vector3D pos, Vector3 dir)
    {
        if (mpMode && host == false)
        {
            return;
        }

        if (spawnableAircraft.Count > 0)
        {
            GameObject aircraft = spawnableAircraft[UnityEngine.Random.Range(0, spawnableAircraft.Count)].SpawnAircraft();

            FloatingOriginTransform floatingTransform = aircraft.AddComponent <FloatingOriginTransform>();
            if (floatingTransform != null)
            {
                floatingTransform.SetRigidbody(aircraft.GetComponent <Rigidbody>());
            }
            aircraft.GetComponent <Rigidbody>().interpolation = RigidbodyInterpolation.Interpolate;

            TrafficAI_Transport ai          = aircraft.AddComponent <TrafficAI_Transport>();
            GameObject          unitSpawner = new GameObject();
            ai.aircraft.unitSpawner = unitSpawner.AddComponent <UnitSpawner>();
            Traverse unitSpawnerTraverse = Traverse.Create(ai.aircraft.unitSpawner);
            unitSpawnerTraverse.Field("_spawned").SetValue(true);
            Traverse aircraftSpawnerTraverse = Traverse.Create(ai.aircraft);
            aircraftSpawnerTraverse.Field("taxiSpeed").SetValue(ai.aircraft.aiPilot.taxiSpeed);
            ai.Spawn(pos, dir);

            Debug.Log("Spawned " + aircraft.name + " as air traffic");
            activeAircraftAmmount++;

            if (mpMode)
            {
                Debug.Log("MP is enabled, networking this aircraft!");
                MPSetUpAircraft(ai.aircraft.actor);
            }
        }
        else
        {
            Debug.Log("No aircraft were available, cannot spawn a traffic aircraft.");
        }
    }
 public void Add(FloatingOriginTransform f)
 {
     fs.Add(f);
 }
 public void Remove(FloatingOriginTransform f)
 {
     floatingTransforms.Remove(f);
 }