Beispiel #1
0
        private void PopulateLOR(RoomTemplate roomTemplate)
        {
            localityOfRelevances = new LocalityOfRelevance[roomTemplate.lorCountX, roomTemplate.lorCountY, roomTemplate.lorCountZ];
            Vector3 lorIncrement = roomTemplate.sceneSize;

            lorIncrement.x /= roomTemplate.lorCountX;
            lorIncrement.y /= roomTemplate.lorCountY;
            lorIncrement.z /= roomTemplate.lorCountZ;

            Vector3 lorBufferedSize = lorIncrement + roomTemplate.padding;


            Vector3 start       = roomTemplate.centre + lorIncrement / 2 - new Vector3(roomTemplate.sceneSize.x / 2, roomTemplate.sceneSize.y / 2, roomTemplate.sceneSize.z / 2);
            Vector3 lorPosition = start;

            for (int x = 0; x < roomTemplate.lorCountX; x++)
            {
                lorPosition.y = start.y;
                for (int y = 0; y < roomTemplate.lorCountY; y++)
                {
                    lorPosition.z = start.z;
                    for (int z = 0; z < roomTemplate.lorCountZ; z++)
                    {
                        localityOfRelevances[x, y, z] = new LocalityOfRelevance(this, new Bounds(lorPosition, lorBufferedSize), x, y, z);
                        lorPosition.z += lorIncrement.z;
                    }
                    lorPosition.y += lorIncrement.y;
                }
                lorPosition.x += lorIncrement.x;
            }

            for (int x = 0; x < roomTemplate.lorCountX; x++)
            {
                for (int y = 0; y < roomTemplate.lorCountY; y++)
                {
                    for (int z = 0; z < roomTemplate.lorCountZ; z++)
                    {
                        for (int i = -1; i <= 1; i++)
                        {
                            for (int j = -1; j <= 1; j++)
                            {
                                for (int k = -1; k <= 1; k++)
                                {
                                    if (x + i >= 0 && x + i < roomTemplate.lorCountX &&
                                        y + j >= 0 && y + j < roomTemplate.lorCountY &&
                                        z + k >= 0 && z + k < roomTemplate.lorCountZ)
                                    {
                                        localityOfRelevances[x, y, z].adjacentLoRs.Add(localityOfRelevances[x + i, y + j, z + k]);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
 public void TransferObject(ServerNetworkEntity obj, LocalityOfRelevance target)
 {
     if (obj is PlayerEntity player)
     {
         TransferPlayer(player, target);
     }
     else
     {
         target?.AddObject(obj);
         RemoveObject(obj);
     }
 }
Beispiel #3
0
 private void TransferPlayer(PlayerEntity player, LocalityOfRelevance target)
 {
     target?.AddPlayer(player);
     RemovePlayer(player);
 }