void uLink_OnConnectedToServer()
    {
        if (networkView.viewID != uLink.NetworkViewID.unassigned)
        {
            return;
        }

        if (uLink.Network.isAuthoritativeServer && uLink.Network.isClient)
        {
            // TODO: warn if server is authoritative && this is not the server
            return;
        }

        Transform trans = transform;

        uLink.NetworkPlayer owner       = uLink.Network.player;
        uLink.NetworkViewID viewID      = uLink.Network.AllocateViewID();
        object[]            initialData = appendLoginData ? uLink.Network.loginData : new object[0];

        if (owner != uLink.NetworkPlayer.server)
        {
            uLink.Network.Instantiate(viewID, owner, othersPrefab, null, othersPrefab, trans.position, trans.rotation, 0, initialData);
        }
        else
        {
            uLink.Network.Instantiate(viewID, owner, othersPrefab, othersPrefab, null, trans.position, trans.rotation, 0, initialData);
        }

        networkView.SetViewID(viewID, owner);
        networkView.SetInitialData(initialData);
    }
    protected void MineDetected(NetworkViewID mineID, uLink.NetworkMessageInfo info)
    {
        uLink.NetworkView view = uLink.NetworkView.Find(mineID);
        if (view == null)
        {
            return;
        }

        Mine mine = view.GetComponent <Mine>();

        if (mine == null)
        {
            return;
        }

#if !DEADZONE_CLIENT
        if (Owner.IsServer)
        {
            ServerAnticheat.ReportMineDetected(Owner.NetworkView.owner, mine, info);
        }
#endif

        if (!mine.IsDetected)
        {
            mine.SetDetected(true);
        }

//		Debug.Log ("MineDetected(), Owner=" + Owner.name + ", mine=" + mine.name);
    }
Beispiel #3
0
    public void uLink_OnSerializeNetworkView(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        uLink.NetworkViewID prevPossesedID = PossessedCharacterViewID;
        stream.Serialize(ref PossessedCharacterViewID);
        stream.Serialize(ref _IsDoingMenuStuff);
        stream.Serialize(ref _Score);

        stream.Serialize(ref _IsSpectating);
        stream.Serialize(ref _Ping);

        if (stream.isReading)
        {
            if (Possession == null)
            {
                // see if possession id from network is not null
                // see if new possession object from that id is not null
                // then assign
                PlayerScript character = TryGetPlayerScriptFromNetworkViewID(PossessedCharacterViewID);
                if (character != null)
                {
                    Possession = character;
                }
            }
            else
            {
                // see if new possession id is different from current possession id
                // assign new possession, even if null
                if (prevPossesedID != PossessedCharacterViewID)
                {
                    Possession = TryGetPlayerScriptFromNetworkViewID(PossessedCharacterViewID);
                }
            }
        }
    }
Beispiel #4
0
    public void Local_HealthChange(float amount, uLink.NetworkViewID attackerID, uLink.NetworkMessageInfo info)
    {
        GameObject gameObject;

        object[] objArray;
        bool     flag;

        if (attackerID != uLink.NetworkViewID.unassigned)
        {
            uLink.NetworkView networkView  = uLink.NetworkView.Find(attackerID);
            uLink.NetworkView networkView1 = networkView;
            if (!networkView)
            {
                gameObject = null;
                objArray   = new object[] { amount, gameObject };
                flag       = InterpTimedEvent.Queue(this, "DMG", ref info, objArray);
                return;
            }
            gameObject = networkView1.gameObject;
            objArray   = new object[] { amount, gameObject };
            flag       = InterpTimedEvent.Queue(this, "DMG", ref info, objArray);
            return;
        }
        gameObject = null;
        objArray   = new object[] { amount, gameObject };
        flag       = InterpTimedEvent.Queue(this, "DMG", ref info, objArray);
    }
    protected void AgentDetected(NetworkViewID senderID, NetworkViewID agentID, bool detected, uLink.NetworkMessageInfo info)
    {
        uLink.NetworkView agentView = uLink.NetworkView.Find(agentID);
        if (!agentView)
        {
            return;
        }

        uLink.NetworkView senderView = uLink.NetworkView.Find(senderID);
        if (!senderView)
        {
            return;
        }

        AgentHuman agent  = agentView.GetComponent <AgentHuman>();
        AgentHuman sender = senderView.GetComponent <AgentHuman>();

#if !DEADZONE_CLIENT
        if (Owner.IsServer)
        {
            ServerAnticheat.ReportAgentDetected(Owner.NetworkView.owner, agent, sender, info);
        }
#endif

        if (sender && sender.IsAlive && agent && agent.IsAlive && sender.IsFriend(agent) == false)
        {
            agent.BlackBoard.IsDetected = detected;

//			Debug.Log ("AgentDetected(), detected=" + detected + ", Owner=" + Owner.name + ", sender=" + sender.name + ", agent=" + agent.name);
        }
    }
Beispiel #6
0
 private void ReceivePawnDeath()
 {
     if (Possession != null)
     {
         Possession.OnDeath      -= ReceivePawnDeath;
         Possession               = null;
         PossessedCharacterViewID = uLink.NetworkViewID.unassigned;
     }
 }
// ReSharper disable once UnusedMember.Local
    protected void OthersReceiveHit(int damage, Vector3 point, uLink.NetworkViewID instigatorPresenceViewID)
    {
		EffectsScript.ExplosionHit( point, Quaternion.LookRotation( Vector3.up ) );
        if (networkView.isMine)
        {
            DoDamageOwner(damage, point,
                PlayerPresence.TryGetPlayerPresenceFromNetworkViewID(instigatorPresenceViewID));
        }
    }
Beispiel #8
0
    protected void uLink_OnNetworkInstantiate(uLink.NetworkMessageInfo info)
    {
        this._parentViewID = info.networkView.initialData.ReadNetworkViewID();
        int num = info.networkView.initialData.ReadInt32();

        this._datablock = (HeldItemDataBlock)DatablockDictionary.GetByUniqueID(num);
        if (!this.CheckParent())
        {
            Debug.Log("No parent for item rep (yet)", this);
        }
    }
Beispiel #9
0
 protected void Client_OnKilledBy(uLink.NetworkViewID attackerViewID, uLink.NetworkMessageInfo info)
 {
     uLink.NetworkView networkView = uLink.NetworkView.Find(attackerViewID);
     if (networkView)
     {
         Character component = networkView.GetComponent <Character>();
         this.Client_OnKilledShared(component, component, ref info);
     }
     else
     {
         this.Client_OnKilledShared(false, null, ref info);
     }
 }
Beispiel #10
0
 protected void OnDestroy()
 {
     try
     {
         InterpTimedEvent.Remove(this, true);
         this.ClearMods();
     }
     finally
     {
         this._parentViewID = uLink.NetworkViewID.unassigned;
         this.ClearSignals();
         base.OnDestroy();
     }
 }
Beispiel #11
0
// ReSharper disable once UnusedMember.Local
    protected void RemoteReceiveUntargetedBy(uLink.NetworkViewID enemyPlayerScriptID, uLink.NetworkMessageInfo info)
    {
        try
        {
            var view  = uLink.NetworkView.Find(enemyPlayerScriptID);
            var enemy = (PlayerScript)view.observed;
            if (view.owner == info.sender)
            {
                Untargeted(enemy);
            }
        }
// ReSharper disable once EmptyGeneralCatchClause
        catch (Exception)
        {
            // nope lol
        }
    }
Beispiel #12
0
    // Token: 0x06002175 RID: 8565 RVA: 0x0007B318 File Offset: 0x00079518
    protected uLink.NetworkView _Creator(string prefabName, NetworkInstantiateArgs args, uLink.NetworkMessageInfo info)
    {
        global::NetInstance netInstance = this.Summon(this.proxyPrefab, false, ref args);

        if (!netInstance)
        {
            return(null);
        }
        Facepunch.NetworkView networkView = netInstance.networkView;
        if (!networkView)
        {
            return(null);
        }
        info = new uLink.NetworkMessageInfo(info, networkView);
        global::NetInstance currentNetInstance = global::NetMainPrefab._currentNetInstance;

        try
        {
            global::NetMainPrefab._currentNetInstance = netInstance;
            netInstance.info     = info;
            netInstance.prepared = true;
            global::NetInstance netInstance2 = netInstance;
            uLink.NetworkViewID viewID       = args.viewID;
            netInstance2.local = viewID.isMine;
            bool     didAppend = false;
            IDRemote appended  = null;
            if (netInstance.local)
            {
                IDRemote localAppend = this.localAppend;
                if (localAppend)
                {
                    appended  = global::NetMainPrefab.DoLocalAppend(localAppend, netInstance.idMain, this.GetLocalAppendTransform(netInstance.idMain));
                    didAppend = true;
                }
            }
            netInstance.zzz___onprecreate();
            this.StandardInitialization(didAppend, appended, netInstance, networkView, ref info);
            netInstance.zzz___onpostcreate();
        }
        finally
        {
            global::NetMainPrefab._currentNetInstance = currentNetInstance;
        }
        return(networkView);
    }
Beispiel #13
0
    public void Awake()
    {
        DontDestroyOnLoad(this);
        PossessedCharacterViewID = uLink.NetworkViewID.unassigned;
        LastGUIDebugPositions    = new WeakDictionary <PlayerScript, Vector2>();

        // Ladies and gentlemen, the great and powerful Unity
        wasMine = networkView.isMine;

        if (networkView.isMine)
        {
            Name = PlayerPrefs.GetString("username", "Anonymous");

            // TODO will obviously send messages to server twice if there are two local players, fix
            Relay.Instance.MessageLog.OnMessageEntered += ReceiveMessageEntered;
            Relay.Instance.MessageLog.OnCommandEntered += ReceiveCommandEntered;
        }
    }
    protected void Death(NetworkViewID attackerNVId, Vector3 pos, Vector3 impuls, short damage, short bodyPart)
    {
#if !DEADZONE_CLIENT
        if (Owner.IsServer)
        {
            ServerAnticheat.ReportPotentialCheatAttempt("Death", "should never be called on the server side", Owner.NetworkView.owner);
            return;
        }
#endif

        if (Owner.BlackBoard.DontUpdate)
        {
            return;
        }

        uLink.NetworkView View = (attackerNVId != uLink.NetworkViewID.unassigned) ? uLink.NetworkView.Find(attackerNVId) : null;

        Owner.Die(View ? View.GetComponent <AgentHuman>() : null, pos, impuls, damage, (E_BodyPart)bodyPart);
    }
Beispiel #15
0
    public void Local_HealthChange(float amount, uLink.NetworkViewID attackerID, uLink.NetworkMessageInfo info)
    {
        uLink.NetworkView networkView;
        GameObject        gameObject;

        if (attackerID != uLink.NetworkViewID.unassigned && (networkView = uLink.NetworkView.Find(attackerID)))
        {
            gameObject = networkView.gameObject;
        }
        else
        {
            gameObject = null;
        }
        global::InterpTimedEvent.Queue(this, "DMG", ref info, new object[]
        {
            amount,
            gameObject
        });
    }
Beispiel #16
0
    protected void OnClientDeath(ref Vector3 deathPosition, uLink.NetworkViewID attackerNetViewID, ref uLink.NetworkMessageInfo info)
    {
        Vector3 vector;
        Vector3 vector2;

        TransformHelpers.GetGroundInfo(deathPosition + new Vector3(0f, 0.25f, 0f), 10f, out vector, out vector2);
        deathPosition = vector;
        Quaternion rot = TransformHelpers.LookRotationForcedUp((Vector3)(this._myTransform.rotation * Vector3.forward), vector2);

        this._interp.SetGoals(deathPosition, rot, info.timestamp);
        if (attackerNetViewID.isMine)
        {
            this.DoClientDeath();
        }
        else
        {
            InterpTimedEvent.Queue(this, "DEATH", ref info);
        }
    }
Beispiel #17
0
 protected void SMSet(uLink.NetworkViewID masterViewID)
 {
     Facepunch.NetworkView context = Facepunch.NetworkView.Find(masterViewID);
     if (context != null)
     {
         StructureMaster component = context.GetComponent <StructureMaster>();
         if (component != null)
         {
             component.AppendStructureComponent(this);
         }
         else
         {
             Debug.LogWarning("No Master On GO", context);
         }
     }
     else
     {
         Debug.LogWarning("Couldnt find master view", this);
     }
 }
 protected void SMSet(uLink.NetworkViewID masterViewID)
 {
     Facepunch.NetworkView networkView = Facepunch.NetworkView.Find(masterViewID);
     if (networkView)
     {
         global::StructureMaster component = networkView.GetComponent <global::StructureMaster>();
         if (component)
         {
             component.AppendStructureComponent(this);
         }
         else
         {
             Debug.LogWarning("No Master On GO", networkView);
         }
     }
     else
     {
         Debug.LogWarning("Couldnt find master view", this);
     }
 }
Beispiel #19
0
    protected void uLink_OnNetworkInstantiate(uLink.NetworkMessageInfo info)
    {
        PosRot posRot = new PosRot();

        this.view = (Facepunch.NetworkView)info.networkView;
        uLink.BitStream bitStream = this.view.initialData;
        if (this.expectsInitialVelocity)
        {
            this.initialVelocity = bitStream.ReadVector3();
        }
        if (this.expectsOwner)
        {
            this.ownerViewID = bitStream.ReadNetworkViewID();
        }
        this.spawnTime      = info.timestamp;
        this.updateInterval = 1 / ((double)NetCull.sendRate * (double)Mathf.Max(1f, this.updateRate));
        this.hasInterp      = this._interp;
        if (this.hasInterp)
        {
            this._interp.running = false;
        }
        this.rigidbody.isKinematic = true;
        this.__hiding = this.spawnTime > Interpolation.time;
        if (!this.__hiding)
        {
            this.OnShow();
        }
        else
        {
            this.OnHide();
            if (this.hasInterp)
            {
                posRot.position = this.view.position;
                posRot.rotation = this.view.rotation;
                this._interp.SetGoals(posRot, this.spawnTime);
            }
            InterpTimedEvent.Queue(this, "_init", ref info);
        }
    }
Beispiel #20
0
 // TODO factor out
 public static PlayerPresence TryGetPlayerPresenceFromNetworkViewID(uLink.NetworkViewID viewID)
 {
     if (viewID == uLink.NetworkViewID.unassigned)
     {
         return(null);
     }
     uLink.NetworkView view = null;
     try
     {
         view = uLink.NetworkView.Find(viewID);
     }
     catch (Exception)
     {
         //Debug.Log(e);
     }
     if (view != null)
     {
         var presence = view.observed as PlayerPresence;
         return(presence);
     }
     return(null);
 }
Beispiel #21
0
 private PlayerScript TryGetPlayerScriptFromNetworkViewID(uLink.NetworkViewID viewID)
 {
     if (viewID == uLink.NetworkViewID.unassigned)
     {
         return(null);
     }
     uLink.NetworkView view = null;
     try
     {
         view = uLink.NetworkView.Find(viewID);
     }
     catch (Exception)
     {
         //Debug.Log(e);
     }
     if (view != null)
     {
         var character = view.observed as PlayerScript;
         return(character);
     }
     return(null);
 }
Beispiel #22
0
    protected void RPC_S2C_ApplyHpChange(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        float damage = stream.Read <float>();
        int   life   = stream.Read <int>();

        uLink.NetworkViewID viewID = stream.Read <uLink.NetworkViewID>();

        CommonInterface caster = null;

        uLink.NetworkView view = uLink.NetworkView.Find(viewID);
        if (null != view)
        {
            NetworkInterface network = view.GetComponent <NetworkInterface>();
            if (null != network && null != network.Runner)
            {
                caster = network.Runner;
            }
        }

        if (null != Runner)
        {
            Runner.NetworkApplyDamage(caster, damage, life);
        }
    }
Beispiel #23
0
 protected void ClientDeath(Vector3 deadPos, uLink.NetworkViewID attackerID, uLink.NetworkMessageInfo info)
 {
     this.OnClientDeath(ref deadPos, attackerID, ref info);
 }
    protected override GameObject ThrowItem(ItemRepresentation rep, IThrowableItem item, Vector3 origin, Vector3 forward, uLink.NetworkViewID owner)
    {
        forward.Normalize();
        Vector3 velocity = (Vector3)(forward * 20f);
        Vector3 position = origin + ((Vector3)(forward * 0.5f));

        return(this.SpawnThrowItem(owner, base.throwObjectPrefab, position, Quaternion.LookRotation(Vector3.up), velocity));
    }
        internal NetworkViewBase _FindNetworkView(NetworkViewID viewID)
        {
            NetworkViewBase nv;

            return(_enabledViews.TryGetValue(viewID, out nv) ? nv : null);
        }
 protected abstract void _ServerRemovePlayerFromGroup(NetworkPlayer player, NetworkGroup group, NetworkViewID viewID, GroupData data, int userSetCount);
        protected GroupData _AddPlayerToGroup(NetworkPlayer player, NetworkGroup group, NetworkViewID viewID)
        {
            var data = _groups.GetOrAdd(group, () => new GroupData(group));

            var userSet = data.users.GetOrAdd(player);

            if (!userSet.Add(viewID))
            {
                return(data);
            }

            if (viewID != NetworkViewID.unassigned)
            {
                data.views.Add(viewID);
            }

            _ServerAddPlayerToGroup(player, group, viewID, data, userSet.Count);
            return(data);
        }
Beispiel #28
0
    protected virtual GameObject ThrowItem(ItemRepresentation rep, IThrowableItem item, Vector3 origin, Vector3 forward, uLink.NetworkViewID owner)
    {
        Vector3    velocity = (Vector3)(forward * item.heldThrowStrength);
        Vector3    position = origin + ((Vector3)(forward * 1f));
        Quaternion rotation = Quaternion.LookRotation(Vector3.up);

        return(this.SpawnThrowItem(owner, this.throwObjectPrefab, position, rotation, velocity));
    }
Beispiel #29
0
 protected void uLink_OnNetworkInstantiate(uLink.NetworkMessageInfo info)
 {
     PosRot posRot = new PosRot();
     this.view = (Facepunch.NetworkView)info.networkView;
     uLink.BitStream bitStream = this.view.initialData;
     if (this.expectsInitialVelocity)
     {
         this.initialVelocity = bitStream.ReadVector3();
     }
     if (this.expectsOwner)
     {
         this.ownerViewID = bitStream.ReadNetworkViewID();
     }
     this.spawnTime = info.timestamp;
     this.updateInterval = 1 / ((double)NetCull.sendRate * (double)Mathf.Max(1f, this.updateRate));
     this.hasInterp = this._interp;
     if (this.hasInterp)
     {
         this._interp.running = false;
     }
     this.rigidbody.isKinematic = true;
     this.__hiding = this.spawnTime > Interpolation.time;
     if (!this.__hiding)
     {
         this.OnShow();
     }
     else
     {
         this.OnHide();
         if (this.hasInterp)
         {
             posRot.position = this.view.position;
             posRot.rotation = this.view.rotation;
             this._interp.SetGoals(posRot, this.spawnTime);
         }
         InterpTimedEvent.Queue(this, "_init", ref info);
     }
 }
Beispiel #30
0
 private void OCO_FOUND(uLink.NetworkViewID viewID, ref uLink.NetworkMessageInfo info)
 {
     this.SetIdle(false);
     this.__networkViewForControllable = base.networkView;
     this.__controllerDriverViewID = viewID;
     this.__controllerCreateMessageInfo = info;
     this.FreshInitializeController();
 }
Beispiel #31
0
 public static bool ContextOf(uLink.NetworkViewID networkViewID, out Contextual contextual)
 {
     return(GetMB(Facepunch.NetworkView.Find(networkViewID), out contextual));
 }
Beispiel #32
0
 internal void PrepareInstantiate(Facepunch.NetworkView view, ref uLink.NetworkMessageInfo info)
 {
     PlayerClient playerClient;
     this.__controllerCreateMessageInfo = info;
     this.__networkViewForControllable = view;
     if (this.classFlagsRootControllable || this.classFlagsStandaloneVessel)
     {
         this.__controllerDriverViewID = uLink.NetworkViewID.unassigned;
         if (this.classFlagsStandaloneVessel)
         {
             return;
         }
     }
     else if (this.classFlagsDependantVessel || this.classFlagsFreeVessel)
     {
         if (!PlayerClient.Find(view.owner, out playerClient))
         {
             this.__controllerDriverViewID = uLink.NetworkViewID.unassigned;
         }
         else
         {
             this.__controllerDriverViewID = playerClient.topControllable.networkViewID;
         }
         if (this.classFlagsFreeVessel)
         {
             return;
         }
         if (this.__controllerDriverViewID == uLink.NetworkViewID.unassigned)
         {
             UnityEngine.Debug.LogError("NOT RIGHT");
             return;
         }
     }
     this.FreshInitializeController();
 }
        protected GroupData _RemovePlayerFromGroup(NetworkPlayer player, NetworkGroup group, NetworkViewID viewID)
        {
            GroupData data;

            if (_groups.TryGetValue(group, out data))
            {
                HashSet <NetworkViewID> userSet;
                if (data.users.TryGetValue(player, out userSet))
                {
                    if (!userSet.Remove(viewID))
                    {
                        return(data);
                    }

                    if (userSet.Count == 0)
                    {
                        data.users.Remove(player);
                    }
                    if (viewID != NetworkViewID.unassigned)
                    {
                        data.views.Remove(viewID);
                    }

                    _ServerRemovePlayerFromGroup(player, group, viewID, data, userSet.Count);
                }

                if (data.users.Count == 0)
                {
                    _groups.Remove(group);
                }
                return(data);
            }

            return(null);
        }