示例#1
0
    public void RemovePlayerFromGame(ulong id)
    {
        Debug.LogError("REMOVING PLAYER");
        if (database == null)
        {
            Debug.LogError("Can't clear out player without a database");
            return;
        }
        if (!database.GetAuthorized())
        {
            return;
        }
        Player p = database.LookupPlayer(id);

        if (p == null)
        {
            Debug.LogError("Can't find player");
        }
        Debug.Log("Calling database method");
        database.RemovePlayer(p, true);
        MeshPacket packet = new MeshPacket();

        packet.SetPacketType(PacketType.KickPacket);
        packet.SetSourceObjectId((ushort)ReservedObjectIDs.Architecture);
        packet.SetSourcePlayerId(GetLocalPlayerID());
        packet.SetTargetObjectId((ushort)ReservedObjectIDs.Architecture);
        packet.SetTargetPlayerId(id);
        RoutePacketDirect(packet, id);

        MeshNetworkIdentity[] objectsToUnlock = database.QueryByOwner(id);
        for (int i = 0; i < objectsToUnlock.Length; i++)
        {
            if (objectsToUnlock[i].GetPrefabID() == (ushort)ReservedPrefabIDs.Player)
            {
                scheduler.ScheduleChange(objectsToUnlock[i], StateChange.Removal);
            }
            else
            {
                objectsToUnlock[i].SetLocked(false);
                objectsToUnlock[i].SetOwnerID(GetLocalPlayerID());
                scheduler.ScheduleChange(objectsToUnlock[i], StateChange.Change);
            }
        }
    }
示例#2
0
    public override void SetBeingUsed(bool used)
    {
        if (IsBeingUsed() != used)
        {
            if (GetIdentity() != null)
            {
                if (GetIdentity().IsLocallyOwned() == false)
                {
                    return;
                }
                base.SetBeingUsed(used);
                MeshPacket p = new MeshPacket();
                p.SetContents(new PropUpdate(used).GetSerializedBytes());
                p.SetTargetObjectId(GetIdentity().GetObjectID());
                p.SetTargetPlayerId((ulong)ReservedPlayerIDs.Broadcast);
                p.SetSourceObjectId(GetIdentity().GetObjectID());
                p.SetSourcePlayerId(GetIdentity().GetLocalPlayerID());

                p.SetPacketType(PacketType.GenericStateUpdate);
                GetIdentity().RoutePacket(p);
            }
        }
    }