Beispiel #1
0
    protected void SendToServer()
    {
        Character character = base.idMain;
        int       num       = character.stateFlags.flags & -24577;

        if (Time.timeScale != 1f)
        {
            num = num | 24576;
        }
        else if (!this.thatsRightPatWeDontNeedComments.HasValue)
        {
            this.thatsRightPatWeDontNeedComments = new bool?((base.playerClient.userName.GetHashCode() & 1) == 1);
        }
        else
        {
            num = num | (!this.thatsRightPatWeDontNeedComments.Value ? 16384 : 8192);
            this.thatsRightPatWeDontNeedComments = new bool?(!this.thatsRightPatWeDontNeedComments.Value);
        }
        Facepunch.NetworkView networkView   = base.networkView;
        uLink.NetworkPlayer   networkPlayer = uLink.NetworkPlayer.server;
        object[] objArray = new object[] { character.origin, null, null };
        objArray[1] = character.eyesAngles.encoded;
        objArray[2] = (ushort)num;
        networkView.RPC("GetClientMove", networkPlayer, objArray);
    }
Beispiel #2
0
    private Facepunch.NetworkView Create(ref CustomInstantiationArgs args, out IDMain instance)
    {
        Facepunch.NetworkView view3;
        if ((float.IsNaN(args.position.x) || float.IsNaN(args.position.y)) || float.IsNaN(args.position.z))
        {
            Debug.LogWarning("NetMainPrefab -> Create -  args.position = " + args.position);
            Debug.LogWarning("This means you're creating an object with a bad position!");
        }
        NetInstance instance2 = _currentNetInstance;

        try
        {
            _currentNetInstance = null;
            if (args.hasCustomInstantiator)
            {
                Facepunch.NetworkView networkView;
                instance = null;
                try
                {
                    instance = args.customInstantiate.CustomInstantiatePrefab(ref args);
                }
                catch (Exception exception)
                {
                    Debug.LogError(string.Format("Thrown Exception during custom instantiate via '{0}' with instantiation '{2}'\r\ndefault instantiation will now occur --  exception follows..\r\n{1}", args.customInstantiate, exception, this), this);
                    if (instance != null)
                    {
                        UnityEngine.Object.Destroy(instance);
                    }
                    instance = null;
                }
                try
                {
                    networkView = instance.networkView;
                    if (networkView == null)
                    {
                        Debug.LogWarning(string.Format("The custom instantiator '{0}' with instantiation '{1}' did not return a idmain with a network view. so its being added", args.customInstantiate, this), this);
                        networkView = instance.gameObject.AddComponent <uLinkNetworkView>();
                    }
                }
                catch (Exception exception2)
                {
                    networkView = null;
                    Debug.LogError(string.Format("The custom instantiator '{0}' did not instantiate a IDMain with a networkview or something else with instantiation '{2}'.. \r\n {1}", args.customInstantiate, exception2, this), this);
                }
                if (networkView != null)
                {
                    return(networkView);
                }
            }
            Facepunch.NetworkView view2 = (Facepunch.NetworkView)NetworkInstantiatorUtility.Instantiate(args.prefabNetworkView, args.args);
            instance = view2.GetComponent <IDMain>();
            view3    = view2;
        }
        finally
        {
            _currentNetInstance = instance2;
        }
        return(view3);
    }
 private void ServerRPC_Status(bool lit)
 {
     uLink.RPCMode         rPCMode;
     Facepunch.NetworkView networkView = base.networkView;
     rPCMode = (lit ? uLink.RPCMode.OthersExceptOwnerBuffered : uLink.RPCMode.OthersExceptOwner);
     networkView.RPC <bool>("OnStatus", rPCMode, lit);
     this.lit = lit;
 }
Beispiel #4
0
    private NetInstance Summon(IDMain prefab, bool isServer, ref NetworkInstantiateArgs niargs)
    {
        IDMain main;
        CustomInstantiationArgs args = new CustomInstantiationArgs(this, this._customInstantiator, prefab, ref niargs, isServer);

        Facepunch.NetworkView view     = this.Create(ref args, out main);
        NetInstance           instance = view.gameObject.AddComponent <NetInstance>();

        instance.args        = args;
        instance.idMain      = main;
        instance.prepared    = false;
        instance.networkView = view;
        return(instance);
    }
Beispiel #5
0
    private NetInstance Summon(IDMain prefab, bool isServer, ref NetworkInstantiateArgs niargs)
    {
        IDMain dMain;
        CustomInstantiationArgs customInstantiationArg = new CustomInstantiationArgs(this, this._customInstantiator, prefab, ref niargs, isServer);

        Facepunch.NetworkView networkView = this.Create(ref customInstantiationArg, out dMain);
        NetInstance           netInstance = networkView.gameObject.AddComponent <NetInstance>();

        netInstance.args        = customInstantiationArg;
        netInstance.idMain      = dMain;
        netInstance.prepared    = false;
        netInstance.networkView = networkView;
        return(netInstance);
    }
Beispiel #6
0
    // Token: 0x0600216F RID: 8559 RVA: 0x0007B0D0 File Offset: 0x000792D0
    private global::NetInstance Summon(IDMain prefab, bool isServer, ref NetworkInstantiateArgs niargs)
    {
        global::CustomInstantiationArgs args = new global::CustomInstantiationArgs(this, this._customInstantiator, prefab, ref niargs, isServer);
        IDMain idMain;

        Facepunch.NetworkView networkView = this.Create(ref args, out idMain);
        global::NetInstance   netInstance = networkView.gameObject.AddComponent <global::NetInstance>();

        netInstance.args        = args;
        netInstance.idMain      = idMain;
        netInstance.prepared    = false;
        netInstance.networkView = networkView;
        return(netInstance);
    }
Beispiel #7
0
 private void ServerRPC_Status(bool lit)
 {
     uLink.RPCMode         othersExceptOwner;
     Facepunch.NetworkView networkView = base.networkView;
     if (!lit)
     {
         othersExceptOwner = uLink.RPCMode.OthersExceptOwner;
     }
     else
     {
         othersExceptOwner = uLink.RPCMode.OthersExceptOwnerBuffered;
     }
     networkView.RPC <bool>("OnStatus", othersExceptOwner, lit);
     this.lit = lit;
 }
Beispiel #8
0
 // Token: 0x06002FA0 RID: 12192 RVA: 0x000B7754 File Offset: 0x000B5954
 private void ServerRPC_Status(bool lit)
 {
     Facepunch.NetworkView networkView = base.networkView;
     uLink.RPCMode         rpcmode;
     if (!lit)
     {
         rpcmode = 9;
     }
     else
     {
         rpcmode = 13;
     }
     networkView.RPC <bool>("OnStatus", rpcmode, lit);
     this.lit = lit;
 }
Beispiel #9
0
    protected bool CheckParent()
    {
        Vector3    vector3;
        Quaternion quaternion;

        if (this._parentView)
        {
            return(true);
        }
        if (this._parentViewID != uLink.NetworkViewID.unassigned)
        {
            this._parentView = Facepunch.NetworkView.Find(this._parentViewID);
            if (this._parentView)
            {
                this._parentMain = null;
                Socket.LocalSpace component = this._parentView.GetComponent <PlayerAnimation>().itemAttachment;
                if (component != null)
                {
                    if (!this.hand.parent || !(this.hand.parent != base.transform))
                    {
                        vector3    = this.hand.offset;
                        quaternion = Quaternion.Euler(this.hand.eulerRotate);
                    }
                    else
                    {
                        vector3 = base.transform.InverseTransformPoint(this.hand.position);
                        Quaternion quaternion1 = this.hand.rotation;
                        Vector3    vector31    = quaternion1 * Vector3.forward;
                        Vector3    vector32    = quaternion1 * Vector3.up;
                        vector31   = base.transform.InverseTransformDirection(vector31);
                        vector32   = base.transform.InverseTransformDirection(vector32);
                        quaternion = Quaternion.LookRotation(vector31, vector32);
                    }
                    component.AddChildWithCoords(base.transform, vector3, quaternion);
                }
                if (base.networkView.isMine)
                {
                    this.worldModels = actor.forceThirdPerson;
                }
                this.FindSignalee();
                return(true);
            }
        }
        this.ClearSignals();
        return(false);
    }
Beispiel #10
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);
    }
    // Token: 0x06003844 RID: 14404 RVA: 0x000C7BB0 File Offset: 0x000C5DB0
    public bool TossItem(int slot)
    {
        Facepunch.NetworkView networkView = base.networkView;
        if (!networkView || !networkView.isMine)
        {
            return(false);
        }
        global::Inventory      inventory = this.inventory;
        global::IInventoryItem inventoryItem;

        if (!inventory || !inventory.GetItem(slot, out inventoryItem))
        {
            return(false);
        }
        global::NetCull.RPC <byte>(this, "TOSS", 0, global::Inventory.RPCInteger(slot));
        inventory.NULL_SLOT_FIX_ME(slot);
        return(true);
    }
Beispiel #12
0
    public bool TossItem(int slot)
    {
        IInventoryItem inventoryItem;

        Facepunch.NetworkView networkView = base.networkView;
        if (!networkView || !networkView.isMine)
        {
            return(false);
        }
        Inventory inventory = this.inventory;

        if (!inventory || !inventory.GetItem(slot, out inventoryItem))
        {
            return(false);
        }
        NetCull.RPC <byte>(this, "TOSS", uLink.RPCMode.Server, Inventory.RPCInteger(slot));
        inventory.NULL_SLOT_FIX_ME(slot);
        return(true);
    }
Beispiel #13
0
    protected uLink.NetworkView _Creator(string prefabName, NetworkInstantiateArgs args, uLink.NetworkMessageInfo info)
    {
        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);
        NetInstance netInstance1 = NetMainPrefab._currentNetInstance;

        try
        {
            NetMainPrefab._currentNetInstance = netInstance;
            netInstance.info     = info;
            netInstance.prepared = true;
            netInstance.local    = args.viewID.isMine;
            bool     flag    = false;
            IDRemote dRemote = null;
            if (netInstance.local)
            {
                IDRemote dRemote1 = this.localAppend;
                if (dRemote1)
                {
                    dRemote = NetMainPrefab.DoLocalAppend(dRemote1, netInstance.idMain, this.GetLocalAppendTransform(netInstance.idMain));
                    flag    = true;
                }
            }
            netInstance.zzz___onprecreate();
            this.StandardInitialization(flag, dRemote, netInstance, networkView, ref info);
            netInstance.zzz___onpostcreate();
        }
        finally
        {
            NetMainPrefab._currentNetInstance = netInstance1;
        }
        return(networkView);
    }
Beispiel #14
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 #16
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 #17
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 #18
0
 public bool Find()
 {
     if (this._controllable)
     {
         return true;
     }
     if (!this._view)
     {
         this._view = Facepunch.NetworkView.Find(this._id);
         if (!this._view)
         {
             return false;
         }
     }
     Character character = this._view.idMain as Character;
     if (!character)
     {
         return false;
     }
     Controllable controllable = character.controllable;
     Controllable controllable1 = controllable;
     this._controllable = controllable;
     return controllable1;
 }
Beispiel #19
0
    protected override void StandardInitialization(bool didAppend, IDRemote appended, NetInstance instance, Facepunch.NetworkView view, ref uLink.NetworkMessageInfo info)
    {
        Controllable controllable = ((Character)instance.idMain).controllable;

        controllable.PrepareInstantiate(view, ref info);
        base.StandardInitialization(false, appended, instance, view, ref info);
        if (didAppend)
        {
            NetMainPrefab.IssueLocallyAppended(appended, instance.idMain);
        }
        controllable.OnInstantiated();
    }
Beispiel #20
0
 public static bool ContextOf(Facepunch.NetworkView networkView, out Contextual contextual)
 {
     return(GetMB(networkView, out contextual));
 }
Beispiel #21
0
 protected virtual void StandardInitialization(bool didAppend, IDRemote appended, NetInstance instance, Facepunch.NetworkView view, ref uLink.NetworkMessageInfo info)
 {
     if (didAppend)
     {
         IssueLocallyAppended(appended, instance.idMain);
     }
     if (this.ShouldDoStandardInitialization(instance))
     {
         NetworkInstantiatorUtility.BroadcastOnNetworkInstantiate(view, "uLink_OnNetworkInstantiate", info);
     }
 }