コード例 #1
0
    static bool Prefix(MissionObjective __instance)
    {
        Debug.Log("A mission got CancelObjective we need to send it");

        int hashCode = ObjectiveNetworker_Reciever.getMissionHash(__instance);

        Message_ObjectiveSync objOutMessage = new Message_ObjectiveSync(PlayerManager.localUID, hashCode, ObjSyncType.EMissionCanceled);

        if (Networker.isHost && objOutMessage.objID != -1)
        {
            Debug.Log("Host sent objective CancelObjective " + __instance.objectiveID);
            ObjectiveNetworker_Reciever.ObjectiveHistory.Add(objOutMessage);
            NetworkSenderThread.Instance.SendPacketAsHostToAllClients(objOutMessage, Steamworks.EP2PSend.k_EP2PSendReliable);
        }
        else
        {
            bool shouldComplete = ObjectiveNetworker_Reciever.completeNextCancel;
            Debug.Log($"Should complete is {shouldComplete}.");
            ObjectiveNetworker_Reciever.completeNextCancel = false;
            return(shouldComplete);// clients should not send kill obj packets or have them complete
            //Debug.Log("Client sent objective CancelObjective " + __instance.objectiveID);
            // NetworkSenderThread.Instance.SendPacketToSpecificPlayer(Networker.hostID, objOutMessage, Steamworks.EP2PSend.k_EP2PSendUnreliable);
        }
        return(true);
    }
コード例 #2
0
    static bool Prefix(MissionObjective __instance)
    {
        Debug.Log("A mission got completed we need to send it");

        int hashCode = ObjectiveNetworker_Reciever.getMissionHash(__instance);

        Message_ObjectiveSync objOutMessage = new Message_ObjectiveSync(PlayerManager.localUID, hashCode, ObjSyncType.EMissionCompleted);

        if (Networker.isHost)
        {
            Debug.Log("Host sent objective complete " + __instance.objectiveID);
            ObjectiveNetworker_Reciever.completeNext = false;
            ObjectiveNetworker_Reciever.ObjectiveHistory.Add(objOutMessage);
            NetworkSenderThread.Instance.SendPacketAsHostToAllClients(objOutMessage, Steamworks.EP2PSend.k_EP2PSendReliable);
        }
        else
        {
            bool shouldComplete = ObjectiveNetworker_Reciever.completeNext;
            if (VTScenario.current.objectives.GetObjective(__instance.objectiveID).objectiveType == VTObjective.ObjectiveTypes.Fly_To ||
                VTScenario.current.objectives.GetObjective(__instance.objectiveID).objectiveType == VTObjective.ObjectiveTypes.Refuel ||
                VTScenario.current.objectives.GetObjective(__instance.objectiveID).objectiveType == VTObjective.ObjectiveTypes.Join ||
                VTScenario.current.objectives.GetObjective(__instance.objectiveID).objectiveType == VTObjective.ObjectiveTypes.Land)
            {
                if (shouldComplete == false)
                {
                    //we havent been told to do this by host send it.
                    NetworkSenderThread.Instance.SendPacketToSpecificPlayer(Networker.hostID, objOutMessage, Steamworks.EP2PSend.k_EP2PSendReliable);
                }
                return(true);
            }
            else
            {
                //    VTScenario.current.objectives.GetObjective(__instance.objectiveID).objectiveType == VTObjective.ObjectiveTypes.Conditional)


                Debug.Log($"Should complete is {shouldComplete}.");
                ObjectiveNetworker_Reciever.completeNext = false;
                return(shouldComplete);// clients should not send kill obj packets or have them complete
            }
            //NetworkSenderThread.Instance.SendPacketToSpecificPlayer(Networker.hostID, objOutMessage, Steamworks.EP2PSend.k_EP2PSendUnreliable);
        }
        return(true);
    }