Beispiel #1
0
        private static void Framework_playerSpawnDelegate(int playerId)
        {
            ServerRoundPlayer serverRoundPlayer =
                instant.serverRoundPlayerManager.ResolveServerRoundPlayer(playerId);

            if (serverRoundPlayer.NetworkPlayer.isCarbonPlayer && serverRoundPlayer.SpawnData.ClassType != PlayerClass.ArmyInfantryOfficer)
            {
                if (!posCache.ContainsKey(playerId))
                {
                    return;
                }
                Vector3 vector = posCache[playerId];
                vector = vector.ReplaceY(200f);
                Ray        ray = new Ray(vector, Vector3.down);
                RaycastHit raycastHit2;
                bool       flag2 = Physics.Raycast(ray, out raycastHit2, 500f, instant.commonGlobalVariables.layers.walkable);
                if (flag2)
                {
                    vector = vector.ReplaceY(raycastHit2.point.y);
                    serverRoundPlayer.PlayerBase.Teleport(vector);
                }
                serverRoundPlayer.PlayerBase.Teleport(vector);
                posCache.Remove(playerId);
            }
            else if (wayPoint.ContainsKey(serverRoundPlayer.NetworkPlayerID) && serverRoundPlayer.SpawnData.ClassType == PlayerClass.ArmyInfantryOfficer)
            {
                playerToBot[playerId].ForEach((int id) => {
                    Framework.removeCarbonPlayer(id);
                });
                playerToBot.Remove(playerId);
                players.Add(serverRoundPlayer);
            }
            else if (serverRoundPlayer.SpawnData.ClassType == PlayerClass.ArmyInfantryOfficer)
            {
                players.Add(serverRoundPlayer);
                Queue <Vector3> queue   = new Queue <Vector3>();
                Vector3         basePos = serverRoundPlayer.PlayerBase.transform.position;
                wayPoint.Add(serverRoundPlayer.NetworkPlayerID, queue);
                for (int i = 0; i < maxBot; i++)
                {
                    basePos.z += 1;
                    queue.Enqueue(basePos);
                }
            }
            else if (wayPoint.ContainsKey(serverRoundPlayer.NetworkPlayerID))
            {
                playerToBot[playerId].ForEach((int id) => {
                    Framework.removeCarbonPlayer(id);
                });
                wayPoint.Remove(serverRoundPlayer.NetworkPlayerID);
            }
        }
Beispiel #2
0
 private static void Framework_roundEndDelegate(GameDetails detail)
 {
     playerToBot.ToDfList().ForEach((KeyValuePair <int, List <int> > pair) =>
     {
         pair.Value.ForEach((int id) =>
         {
             Framework.removeCarbonPlayer(id);
         });
         playerToBot.Remove(pair.Key);
         ServerRoundPlayer serverRoundPlayer =
             instant.serverRoundPlayerManager.ResolveServerRoundPlayer(pair.Key);
         wayPoint.Remove(serverRoundPlayer.NetworkPlayerID);
     });
 }
Beispiel #3
0
            public void activeAction(PlayerActions playerAction, Vector3 look, MeleeStrikeType meleeStrike)
            {
                ServerRoundPlayer player = instant.serverRoundPlayerManager.ResolveServerRoundPlayer(networkPlayer.id);

                if (player == null)
                {
                    return;
                }
                OwnerPacketToServer ownerPacketToServer = ComponentReferenceManager.genericObjectPools.ownerPacketToServer.Obtain();
                byte    spawnInstance = player.PlayerBase.PlayerStartData.SpawnInstance;
                Vector2 axis          = new Vector2();;

                axis.x = look.x;
                axis.y = look.z;
                ownerPacketToServer.Instance       = new byte?(spawnInstance);
                ownerPacketToServer.OwnerPosition  = new Vector3?(player.PlayerTransform.position);
                ownerPacketToServer.OwnerInputAxis = new Vector2?(axis);
                ownerPacketToServer.OwnerRotationY = new float?(look.y);
                ownerPacketToServer.Swimming       = player.PlayerBase.State.Has(20);
                double networkTime = uLinkNetworkConnectionsCollection.networkTime;

                ownerPacketToServer.PacketTimestamp = new double?(networkTime);
                EnumCollection <PlayerActions> enumCollection = ComponentReferenceManager.genericObjectPools.playerActionsEnumCollection.Obtain();

                enumCollection.Add((int)playerAction);
                ownerPacketToServer.CameraForward    = new Vector3?(player.PlayerTransform.forward);
                ownerPacketToServer.CameraPosition   = new Vector3(0.3f, 1.5f, -1.0f);
                ownerPacketToServer.ActionCollection = enumCollection;
                player.uLinkStrictPlatformerCreator.HandleOwnerPacketToServer(ownerPacketToServer);
                if (playerAction == PlayerActions.FireFirearm)
                {
                    ServerPacketToProxy proxy = new ServerPacketToProxy();
                    proxy.PlayerID         = (ushort)networkPlayer.id;
                    proxy.Timestamp        = networkTime;
                    proxy.ActionCollection = enumCollection;
                    proxy.State            = player.ServerPlayerBase.State;
                    CharacterServerNetworkUpdateableObjectRPCHandler.Instance.RegisterPacket(networkPlayer, proxy, true);
                }
                if (meleeStrike != MeleeStrikeType.None)
                {
                    PlayerMeleeStrikePacket playerMeleeStrikePacket = ComponentReferenceManager.genericObjectPools.playerMeleeStrikePacket.Obtain();
                    playerMeleeStrikePacket.AttackTime        = uLinkNetworkConnectionsCollection.networkTime;
                    playerMeleeStrikePacket.AttackingPlayerID = player.NetworkPlayerID;
                    playerMeleeStrikePacket.AttackingPlayerMeleeWeaponDamageDealerTypeID = player.WeaponHolder.ActiveWeaponDetails.damageDealerTypeID;
                    playerMeleeStrikePacket.MeleeStrikeType = meleeStrike;
                    instant.meleeStrikeManager.MeleeAttackStrike(playerMeleeStrikePacket);
                }
            }
Beispiel #4
0
            public void teleport(Vector3 position)
            {
                ServerRoundPlayer serverRoundPlayer = instant.serverRoundPlayerManager.ResolveServerRoundPlayer(networkPlayer.id);

                if (serverRoundPlayer != null)
                {
                    serverRoundPlayer.PlayerBase.UpdateRotation(90);
                    position = position.ReplaceY(200f);
                    Ray        ray = new Ray(position, Vector3.down);
                    RaycastHit raycastHit2;
                    bool       flag2 = Physics.Raycast(ray, out raycastHit2, 500f, instant.commonGlobalVariables.layers.walkable);
                    if (flag2)
                    {
                        position = position.ReplaceY(raycastHit2.point.y);
                        serverRoundPlayer.PlayerBase.Teleport(position);
                    }
                }
            }
Beispiel #5
0
        private static void Framework_playerSpawnDelegate(int playerId)
        {
            ServerRoundPlayer serverRoundPlayer =
                instant.serverRoundPlayerManager.ResolveServerRoundPlayer(playerId);

            if (serverRoundPlayer.NetworkPlayer.isCarbonPlayer && serverRoundPlayer.SpawnData.ClassType == PlayerClass.ArmyLineInfantry)
            {
                FactionCountry faction = serverRoundPlayer.SpawnData.Faction;
                if (!posList.ContainsKey(faction))
                {
                    return;
                }
                Vector3 vector = posList[faction].Dequeue();
                Framework.CarbonPlayer player = Framework.getCarbonPlayer(playerId);
                player.teleport(vector);
                vector.x = 0;
                vector.z = 0;
                Framework.getCarbonPlayer(playerId).activeAction(PlayerActions.FireFirearm, vector, MeleeStrikeType.None);
            }
        }
Beispiel #6
0
        private static void Framework_playerDeadDelegate(ulong steamId)
        {
            int playerId = Framework.getPlayerId(steamId);

            if (playerId == -1)
            {
                return;
            }
            if (!playerToBot.ContainsKey(playerId))
            {
                return;
            }
            playerToBot[playerId].ForEach((int id) => {
                Framework.removeCarbonPlayer(id);
            });
            playerToBot.Remove(playerId);
            ServerRoundPlayer serverRoundPlayer =
                instant.serverRoundPlayerManager.ResolveServerRoundPlayer(playerId);

            wayPoint.Remove(serverRoundPlayer.NetworkPlayerID);
        }
Beispiel #7
0
        private static string Framework_playerCommandDelegate(string modName, object[] arguments, ulong steamID, out bool success)
        {
            if (modName != "targetBot" || !enabled)
            {
                success = false;
                return(null);
            }
            ServerRoundPlayer serverRoundPlayer = instant.serverRoundPlayerManager.ResolveServerRoundPlayer(Framework.getPlayerId(steamID));
            string            command           = (string)arguments[0];

            switch (command)
            {
            case "add":
                try {
                    spawnTarget(
                        serverRoundPlayer.SpawnData.Faction,
                        serverRoundPlayer.PlayerTransform.position,
                        serverRoundPlayer.PlayerTransform.forward,
                        Convert.ToInt32(arguments[1]),
                        Convert.ToInt32(arguments[2])
                        );
                    success = true;
                    return("下一轮增援到达后,靶标就会出现");
                } catch (Exception e) {
                    logger.Log(e.StackTrace);
                    success = false;
                    return("调用出错,请联系服务器管理员获取错误堆栈");
                }

            case "clear":
                clearTarget();
                success = true;
                return("开始清理");

            default:
                success = false;
                return(string.Format("不合法的操作符: %s", command));
            }
        }