Example #1
0
    private void LoadModelFormationData(ColliderGrid grid)
    {
        if (_currentGrid != grid)
        {
            if (_targetPoints.IsCreated)
            {
                _targetPoints.Dispose();
            }

            if (_randomOffsets.IsCreated)
            {
                _randomOffsets.Dispose();
            }
            if (_attachedToTarget.IsCreated)
            {
                _attachedToTarget.Dispose();
            }

            _targetPoints     = new NativeArray <float3>(grid.PointList.Count, Allocator.Persistent);
            _randomOffsets    = new NativeArray <float>(grid.PointList.Count, Allocator.Persistent);
            _attachedToTarget = new NativeArray <int>(_swarmData.Length, Allocator.Persistent, NativeArrayOptions.ClearMemory);

            for (int i = 0; i < grid.PointList.Count; i++)
            {
                _targetPoints[i]  = grid.PointList[i];
                _randomOffsets[i] = Mathf.PerlinNoise(_targetPoints[i].x, _targetPoints[i].y);
            }

            _currentGrid = grid;
        }
    }
Example #2
0
    private ColliderGroup CreateColliderGroup(ColliderGrid grid, ColliderCell cell, ColliderKey key)
    {
        ColliderGroup colliderGroup = Facepunch.Pool.Get <ColliderGroup>();

        colliderGroup.Initialize(grid, cell, key);
        return(colliderGroup);
    }
Example #3
0
    private ColliderGroup CreateColliderGroup(
        ColliderGrid grid,
        ColliderCell cell,
        ColliderKey key)
    {
        M0 m0 = Pool.Get <ColliderGroup>();

        ((ColliderGroup)m0).Initialize(grid, cell, key);
        return((ColliderGroup)m0);
    }
Example #4
0
 public void EnterPool()
 {
     this.Invalidated  = false;
     this.NeedsRefresh = false;
     this.Processing   = false;
     this.Preserving   = false;
     this.Colliders.Clear();
     this.TempColliders.Clear();
     this.Batches.Clear();
     this.TempBatches.Clear();
     this.TempInstances.Clear();
     this.grid = null;
     this.cell = null;
     this.key  = new ColliderKey();
 }
Example #5
0
    private void LoadSkinnedModelFormationData(ColliderGrid grid)
    {
        if (grid != _currentGrid)
        {
            LoadModelFormationData(grid);
            if (_boneWeights.IsCreated)
            {
                _boneInverseBaseRotations.Dispose();
                _boneWeights.Dispose();
            }

            _boneWeights = new NativeArray <BoneWeight>(grid.BoneWeightIndices.Count, Allocator.Persistent);
            _boneInverseBaseRotations = new NativeArray <Quaternion>(grid.BoneList.Count, Allocator.Persistent);

            Mesh          mesh              = grid._skinnedMeshRenderer.sharedMesh;
            BoneWeight [] weights           = mesh.boneWeights;
            List <int>    boneWeightIndices = grid.BoneWeightIndices;
            for (int i = 0; i < grid.BoneWeightIndices.Count; i++)
            {
                int index = boneWeightIndices[i];
                _boneWeights[i] = weights[index];
            }
            //get rid of the mesh so it stops rendering without stopping the animator
            grid._skinnedMeshRenderer.sharedMesh = null;

            for (int i = 0; i < grid.BoneList.Count; i++)
            {
                _boneInverseBaseRotations[i] = Quaternion.Inverse(grid.BoneList[i].rotation);
            }

            grid._animator.enabled = true;
        }
        else if (_bonePositions.IsCreated)
        {
            _boneRotations.Dispose();
            _bonePositions.Dispose();
        }

        _bonePositions = new NativeArray <float3>(grid.BoneList.Count, Allocator.TempJob);
        _boneRotations = new NativeArray <Quaternion>(grid.BoneList.Count, Allocator.TempJob);
        for (int i = 0; i < grid.BoneList.Count; i++)
        {
            var transform = grid.BoneList[i];

            _bonePositions[i] = transform.position;
            _boneRotations[i] = transform.rotation * _boneInverseBaseRotations[i];
        }
    }
Example #6
0
    public static IEnumerator StartServer(
        bool doLoad,
        string saveFileOverride,
        bool allowOutOfDateSaves)
    {
        float timeScale = Time.get_timeScale();

        if (Time.pausewhileloading)
        {
            Time.set_timeScale(0.0f);
        }
        RCon.Initialize();
        BaseEntity.Query.Server = new BaseEntity.Query.EntityTree(8096f);
        if (Object.op_Implicit((Object)SingletonComponent <WorldSetup> .Instance))
        {
            yield return((object)((MonoBehaviour)SingletonComponent <WorldSetup> .Instance).StartCoroutine(((WorldSetup)SingletonComponent <WorldSetup> .Instance).InitCoroutine()));
        }
        if (Object.op_Implicit((Object)SingletonComponent <DynamicNavMesh> .Instance) && ((Behaviour)SingletonComponent <DynamicNavMesh> .Instance).get_enabled() && !AiManager.nav_disable)
        {
            yield return((object)((MonoBehaviour)SingletonComponent <DynamicNavMesh> .Instance).StartCoroutine(((DynamicNavMesh)SingletonComponent <DynamicNavMesh> .Instance).UpdateNavMeshAndWait()));
        }
        if (Object.op_Implicit((Object)SingletonComponent <AiManager> .Instance) && ((Behaviour)SingletonComponent <AiManager> .Instance).get_enabled())
        {
            ((AiManager)SingletonComponent <AiManager> .Instance).Initialize();
            if (!AiManager.nav_disable && AI.npc_enable && Object.op_Inequality((Object)TerrainMeta.Path, (Object)null))
            {
                foreach (MonumentInfo monument in TerrainMeta.Path.Monuments)
                {
                    if (monument.HasNavmesh)
                    {
                        yield return((object)monument.StartCoroutine(monument.GetMonumentNavMesh().UpdateNavMeshAndWait()));
                    }
                }
            }
        }
        GameObject prefab = GameManager.server.CreatePrefab("assets/bundled/prefabs/system/server.prefab", true);

        Object.DontDestroyOnLoad((Object)prefab);
        ServerMgr serverMgr = (ServerMgr)prefab.GetComponent <ServerMgr>();

        serverMgr.Initialize(doLoad, saveFileOverride, allowOutOfDateSaves, false);
        yield return((object)CoroutineEx.waitForSecondsRealtime(0.1f));

        ColliderGrid.RefreshAll();
        yield return((object)CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntityLinks();
        yield return((object)CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntitySupports();
        yield return((object)CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntityConditionals();
        yield return((object)CoroutineEx.waitForSecondsRealtime(0.1f));

        ColliderGrid.RefreshAll();
        yield return((object)CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.GetSaveCache();
        yield return((object)CoroutineEx.waitForSecondsRealtime(0.1f));

        serverMgr.OpenConnection();
        if (Time.pausewhileloading)
        {
            Time.set_timeScale(timeScale);
        }
        Bootstrap.WriteToLog("Server startup complete");
    }
Example #7
0
 public ColliderCell(ColliderGrid grid, Vector3 position)
 {
     this.grid     = grid;
     this.position = position;
 }
Example #8
0
 public void Initialize(ColliderGrid grid, ColliderCell cell, ColliderKey key)
 {
     this.grid = grid;
     this.cell = cell;
     this.key  = key;
 }
Example #9
0
    public static IEnumerator StartServer(bool doLoad, string saveFileOverride, bool allowOutOfDateSaves)
    {
        float single = UnityEngine.Time.timeScale;

        if (ConVar.Time.pausewhileloading)
        {
            UnityEngine.Time.timeScale = 0f;
        }
        RCon.Initialize();
        BaseEntity.Query.Server = new BaseEntity.Query.EntityTree(8096f);
        if (SingletonComponent <WorldSetup> .Instance)
        {
            yield return(SingletonComponent <WorldSetup> .Instance.StartCoroutine(SingletonComponent <WorldSetup> .Instance.InitCoroutine()));
        }
        if (SingletonComponent <DynamicNavMesh> .Instance && SingletonComponent <DynamicNavMesh> .Instance.enabled && !AiManager.nav_disable)
        {
            yield return(SingletonComponent <DynamicNavMesh> .Instance.StartCoroutine(SingletonComponent <DynamicNavMesh> .Instance.UpdateNavMeshAndWait()));
        }
        if (SingletonComponent <AiManager> .Instance && SingletonComponent <AiManager> .Instance.enabled)
        {
            SingletonComponent <AiManager> .Instance.Initialize();

            if (!AiManager.nav_disable && AI.npc_enable && TerrainMeta.Path != null)
            {
                foreach (MonumentInfo monument in TerrainMeta.Path.Monuments)
                {
                    if (!monument.HasNavmesh)
                    {
                        continue;
                    }
                    yield return(monument.StartCoroutine(monument.GetMonumentNavMesh().UpdateNavMeshAndWait()));
                }
            }
        }
        GameObject gameObject = GameManager.server.CreatePrefab("assets/bundled/prefabs/system/server.prefab", true);

        UnityEngine.Object.DontDestroyOnLoad(gameObject);
        ServerMgr component = gameObject.GetComponent <ServerMgr>();

        component.Initialize(doLoad, saveFileOverride, allowOutOfDateSaves, false);
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        ColliderGrid.RefreshAll();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntityLinks();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntitySupports();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntityConditionals();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        ColliderGrid.RefreshAll();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.GetSaveCache();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        component.OpenConnection();
        if (ConVar.Time.pausewhileloading)
        {
            UnityEngine.Time.timeScale = single;
        }
        Bootstrap.WriteToLog("Server startup complete");
    }