Beispiel #1
0
        public static bool Execute(ClientInfo sender, List <string> arguments)
        {
            World          world        = GameManager.Instance.World;
            EntityPlayer   entityPlayer = world.Players.dict[sender.entityId];
            Vector3        position     = entityPlayer.position;
            PrefabInstance prefab       = world.GetPOIAtPosition(position);

            // If no arguments just show POI info
            if (arguments.Count == 0)
            {
                if (prefab == null)
                {
                    ChatManager.Message(sender, "[FF0000]No POI found!");
                }
                else
                {
                    ChatManager.Message(sender, string.Format("[FFCC00]POI: [DDDDDD]{0}", prefab.name));
                }
                return(false);
            }

            // Fix everything around player
            int num  = World.toChunkXZ((int)position.x) - 1;
            int num2 = World.toChunkXZ((int)position.z) - 1;
            int num3 = num + 2;
            int num4 = num2 + 2;

            HashSetLong hashSetLong = new HashSetLong();

            for (int k = num; k <= num3; k++)
            {
                for (int l2 = num2; l2 <= num4; l2++)
                {
                    hashSetLong.Add(WorldChunkCache.MakeChunkKey(k, l2));
                }
            }

            ChunkCluster chunkCache = world.ChunkCache;
            ChunkProviderGenerateWorld chunkProviderGenerateWorld = world.ChunkCache.ChunkProvider as ChunkProviderGenerateWorld;

            foreach (long key in hashSetLong)
            {
                if (!chunkProviderGenerateWorld.GenerateSingleChunk(chunkCache, key, true))
                {
                    ChatManager.Message(sender, string.Format("Failed regenerating chunk at position {0}/{1}", WorldChunkCache.extractX(key) << 4, WorldChunkCache.extractZ(key) << 4));
                }
            }

            world.m_ChunkManager.ResendChunksToClients(hashSetLong);

            if (prefab != null)
            {
                prefab.Reset(world);
            }

            ChatManager.Message(sender, "[44FF44]Reseted");
            return(false);
        }
Beispiel #2
0
        internal static void PlayerSpawnedInWorld(ClientInfo player, RespawnType respawnReason, Vector3i _pos)
        {
            string   pId         = player.playerId;
            ModState playerState = VariableContainer.GetPlayerState(pId);
            World    world       = GameManager.Instance.World;

            if (respawnReason.Equals(RespawnType.Died))
            {
                if (playerState.Equals(ModState.RECONNECTING_TO_GAME) || playerState.Equals(ModState.IN_GAME) || playerState.Equals(ModState.START_GAME))
                {
                    if (playerState.Equals(ModState.RECONNECTING_TO_GAME))
                    {
                        Team.Member member = new Team.Member
                        {
                            entityId = player.entityId,
                            nick     = player.playerName,
                            pId      = pId
                        };

                        VariableContainer.SetPlayerState(pId, ModState.IN_GAME);
                        TeamMaker.AddPlayerToTeam(member, VariableContainer.GetPlayerLastTeam(pId));
                    }

                    // Has no items, teleport to team spawn and give items
                    Map     map   = VariableContainer.GetMap(VariableContainer.selectedMap);
                    Vector3 spawn = TeamMaker.GetPlayerTeam(pId).spawn;

                    Log.Out(string.Format("Spawn for {0} is {1}", player.playerName, spawn.ToString()));

                    // Find random spor around spawn
                    Vector3 destination = Vector3.zero;
                    //if (!world.GetRandomSpawnPositionMinMaxToPosition(spawn, 0, 2, 2, false, out destination, true))
                    // {
                    destination = spawn;
                    //}

                    player.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(destination, null, false));

                    // ReGen
                    // Rebuild terrain around spawn
                    if (!refubrishedCords.Contains(spawn))
                    {
                        // But only once
                        refubrishedCords.Add(spawn);

                        PrefabInstance prefab = GameManager.Instance.World.GetPOIAtPosition(spawn);

                        int num  = World.toChunkXZ((int)spawn.x) - 1;
                        int num2 = World.toChunkXZ((int)spawn.z) - 1;
                        int num3 = num + 2;
                        int num4 = num2 + 2;

                        HashSetLong hashSetLong = new HashSetLong();
                        for (int k = num; k <= num3; k++)
                        {
                            for (int l2 = num2; l2 <= num4; l2++)
                            {
                                hashSetLong.Add(WorldChunkCache.MakeChunkKey(k, l2));
                            }
                        }

                        ChunkCluster chunkCache = world.ChunkCache;
                        ChunkProviderGenerateWorld chunkProviderGenerateWorld = world.ChunkCache.ChunkProvider as ChunkProviderGenerateWorld;

                        foreach (long key in hashSetLong)
                        {
                            if (!chunkProviderGenerateWorld.GenerateSingleChunk(chunkCache, key, true))
                            {
                                ChatManager.Message(player, string.Format("[FF4136]Failed regenerating chunk at position [FF851B]{0}[FF4136]/[FF851B]{1}", WorldChunkCache.extractX(key) << 4, WorldChunkCache.extractZ(key) << 4));
                            }
                        }

                        world.m_ChunkManager.ResendChunksToClients(hashSetLong);

                        if (prefab != null)
                        {
                            prefab.Reset(world);
                        }
                    }

                    // Give items
                    ClassManager.ApplyClass(player);

                    if (VariableContainer.GetPlayerState(pId).Equals(ModState.START_GAME))
                    {
                        VariableContainer.SetPlayerState(pId, ModState.IN_GAME);
                    }
                    else
                    {
                        HandleDiedInGame(player);
                    }
                    return;
                }
                else
                {
                    VariableContainer.SetPlayerState(pId, ModState.IN_LOBBY);
                    player.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(VariableContainer.GetLobbyPosition(), null, false));
                    return;
                }
            }

            if (respawnReason.Equals(RespawnType.Teleport))
            {
                return;
            }

            if (VariableContainer.GetPlayerState(pId).Equals(ModState.RECONNECTING_TO_GAME))
            {
                // Have to kill reconected player
                Log.Out("Killing bc of reconnect: " + player.playerName);
                world.Players.dict[player.entityId].DamageEntity(new DamageSource(EnumDamageSource.Internal, EnumDamageTypes.Suicide), 99999, false, 1f);
                return;
            }

            if (VariableContainer.selectedMap == "null")
            {
                VariableContainer.SetPlayerState(pId, ModState.IN_LOBBY);
                player.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(VariableContainer.GetLobbyPosition(), null, false));
            }
        }