示例#1
0
        public float ScoreIntroSpawnPosition(Vector2 desiredSpawnPosition, int x, int z)
        {
            float num  = -0.01f * Vector2.Distance(new Vector2(x, z), desiredSpawnPosition);
            int   num2 = m_subsystemTerrain.Terrain.CalculateTopmostCellHeight(x, z);

            if (num2 < 64 || num2 > 85)
            {
                num -= 5f;
            }
            if (m_subsystemTerrain.Terrain.GetSeasonalTemperature(x, z) < 8)
            {
                num -= 5f;
            }
            int cellContents = m_subsystemTerrain.Terrain.GetCellContents(x, num2, z);

            if (BlocksManager.Blocks[cellContents].IsTransparent)
            {
                num -= 5f;
            }
            for (int i = x - 1; i <= x + 1; i++)
            {
                for (int j = z - 1; j <= z + 1; j++)
                {
                    if (m_subsystemTerrain.Terrain.GetCellContents(i, num2 + 2, j) != 0)
                    {
                        num -= 1f;
                    }
                }
            }
            Vector2 vector  = ComponentIntro.FindOceanDirection(m_subsystemTerrain.TerrainContentsGenerator, new Vector2(x, z));
            Vector3 vector2 = new Vector3(x, (float)num2 + 1.5f, z);

            for (int k = -1; k <= 1; k++)
            {
                Vector3 end = vector2 + new Vector3(30f * vector.X, 5f * (float)k, 30f * vector.Y);
                TerrainRaycastResult?terrainRaycastResult = m_subsystemTerrain.Raycast(vector2, end, useInteractionBoxes: false, skipAirBlocks: true, (int value, float distance) => Terrain.ExtractContents(value) != 0);
                if (terrainRaycastResult.HasValue)
                {
                    CellFace cellFace      = terrainRaycastResult.Value.CellFace;
                    int      cellContents2 = m_subsystemTerrain.Terrain.GetCellContents(cellFace.X, cellFace.Y, cellFace.Z);
                    if (cellContents2 != 18 && cellContents2 != 0)
                    {
                        num -= 2f;
                    }
                }
            }
            return(num);
        }
示例#2
0
        public void SpawnPlayer(Vector3 position, SpawnMode spawnMode)
        {
            ComponentMount componentMount = null;

            if (spawnMode != SpawnMode.Respawn && CheckIsPointInWater(Terrain.ToCell(position)))
            {
                Entity entity = DatabaseManager.CreateEntity(m_project, "Boat", throwIfNotFound: true);
                entity.FindComponent <ComponentBody>(throwOnError: true).Position = position;
                entity.FindComponent <ComponentBody>(throwOnError: true).Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, MathUtils.DegToRad(45f));
                componentMount = entity.FindComponent <ComponentMount>(throwOnError: true);
                m_project.AddEntity(entity);
                position.Y += entity.FindComponent <ComponentBody>(throwOnError: true).BoxSize.Y;
            }
            string value  = "";
            string value2 = "";
            string value3 = "";
            string value4 = "";

            if (spawnMode != SpawnMode.Respawn)
            {
                if (PlayerClass == PlayerClass.Female)
                {
                    if (CharacterSkinsManager.IsBuiltIn(CharacterSkinName) && CharacterSkinName.Contains("2"))
                    {
                        value  = "";
                        value2 = MakeClothingValue(37, 2);
                        value3 = MakeClothingValue(16, 14);
                        value4 = MakeClothingValue(26, 6) + ";" + MakeClothingValue(27, 0);
                    }
                    else if (CharacterSkinsManager.IsBuiltIn(CharacterSkinName) && CharacterSkinName.Contains("3"))
                    {
                        value  = MakeClothingValue(31, 0);
                        value2 = MakeClothingValue(13, 7) + ";" + MakeClothingValue(5, 0);
                        value3 = MakeClothingValue(17, 15);
                        value4 = MakeClothingValue(29, 0);
                    }
                    else if (CharacterSkinsManager.IsBuiltIn(CharacterSkinName) && CharacterSkinName.Contains("4"))
                    {
                        value  = MakeClothingValue(30, 7);
                        value2 = MakeClothingValue(14, 6);
                        value3 = MakeClothingValue(25, 7);
                        value4 = MakeClothingValue(26, 6) + ";" + MakeClothingValue(8, 0);
                    }
                    else
                    {
                        value  = MakeClothingValue(30, 12);
                        value2 = MakeClothingValue(37, 3) + ";" + MakeClothingValue(1, 3);
                        value3 = MakeClothingValue(0, 12);
                        value4 = MakeClothingValue(26, 6) + ";" + MakeClothingValue(29, 0);
                    }
                }
                else if (CharacterSkinsManager.IsBuiltIn(CharacterSkinName) && CharacterSkinName.Contains("2"))
                {
                    value  = "";
                    value2 = MakeClothingValue(13, 0) + ";" + MakeClothingValue(5, 0);
                    value3 = MakeClothingValue(25, 8);
                    value4 = MakeClothingValue(26, 6) + ";" + MakeClothingValue(29, 0);
                }
                else if (CharacterSkinsManager.IsBuiltIn(CharacterSkinName) && CharacterSkinName.Contains("3"))
                {
                    value  = MakeClothingValue(32, 0);
                    value2 = MakeClothingValue(37, 5);
                    value3 = MakeClothingValue(0, 15);
                    value4 = MakeClothingValue(26, 6) + ";" + MakeClothingValue(8, 0);
                }
                else if (CharacterSkinsManager.IsBuiltIn(CharacterSkinName) && CharacterSkinName.Contains("4"))
                {
                    value  = MakeClothingValue(31, 0);
                    value2 = MakeClothingValue(15, 14);
                    value3 = MakeClothingValue(0, 0);
                    value4 = MakeClothingValue(26, 6) + ";" + MakeClothingValue(8, 0);
                }
                else
                {
                    value  = MakeClothingValue(32, 0);
                    value2 = MakeClothingValue(37, 0) + ";" + MakeClothingValue(1, 9);
                    value3 = MakeClothingValue(0, 12);
                    value4 = MakeClothingValue(26, 6) + ";" + MakeClothingValue(29, 0);
                }
            }
            ValuesDictionary overrides = new ValuesDictionary
            {
                {
                    "Player",
                    new ValuesDictionary
                    {
                        {
                            "PlayerIndex",
                            PlayerIndex
                        }
                    }
                },
                {
                    "Intro",
                    new ValuesDictionary
                    {
                        {
                            "PlayIntro",
                            spawnMode == SpawnMode.InitialIntro
                        }
                    }
                },
                {
                    "Clothing",
                    new ValuesDictionary
                    {
                        {
                            "Clothes",
                            new ValuesDictionary
                            {
                                {
                                    "Feet",
                                    value4
                                },
                                {
                                    "Legs",
                                    value3
                                },
                                {
                                    "Torso",
                                    value2
                                },
                                {
                                    "Head",
                                    value
                                }
                            }
                        }
                    }
                }
            };
            Vector2 v = ComponentIntro.FindOceanDirection(m_subsystemTerrain.TerrainContentsGenerator, position.XZ);
            string  entityTemplateName = (PlayerClass == PlayerClass.Male) ? "MalePlayer" : "FemalePlayer";
            Entity  entity2            = DatabaseManager.CreateEntity(m_project, entityTemplateName, overrides, throwIfNotFound: true);

            entity2.FindComponent <ComponentBody>(throwOnError: true).Position = position;
            entity2.FindComponent <ComponentBody>(throwOnError: true).Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, Vector2.Angle(v, -Vector2.UnitY));
            m_project.AddEntity(entity2);
            if (componentMount != null)
            {
                entity2.FindComponent <ComponentRider>(throwOnError: true).StartMounting(componentMount);
            }
            LastSpawnTime = m_subsystemGameInfo.TotalElapsedGameTime;
            int num = ++SpawnsCount;
        }