Пример #1
0
 private static void OnResourcesLoaded()
 {
     foreach (BaseTraitMap map in Bundling.LoadAll <BaseTraitMap>())
     {
         if (map != null)
         {
             try
             {
                 Binder.BindMap(map);
             }
             catch (Exception exception)
             {
                 UnityEngine.Debug.LogError(exception, map);
             }
         }
     }
     DatablockDictionary.Initialize();
     foreach (NetMainPrefab prefab in Bundling.LoadAll <NetMainPrefab>())
     {
         try
         {
             prefab.Register(true);
         }
         catch (Exception exception2)
         {
             UnityEngine.Debug.LogException(exception2, prefab);
         }
     }
     foreach (uLinkNetworkView view in Bundling.LoadAll <uLinkNetworkView>())
     {
         try
         {
             NetCull.RegisterNetAutoPrefab(view);
         }
         catch (Exception exception3)
         {
             UnityEngine.Debug.LogException(exception3, view);
         }
     }
     NGC.Register(NGCConfiguration.Load());
 }
Пример #2
0
 private void TryNetCullDestroy()
 {
     try
     {
         if (this.IsDeployableObject())
         {
             if (this.GetObject <DeployableObject>() != null)
             {
                 NetCull.Destroy(this.GetObject <DeployableObject>().gameObject);
             }
         }
         else if (this.IsStructureMaster())
         {
             if (this.GetObject <StructureMaster>() != null)
             {
                 NetCull.Destroy(this.GetObject <StructureMaster>().networkViewID);
             }
         }
     }
     catch { }
 }
Пример #3
0
        /// <summary>
        /// Drops this item from the inventory.
        /// </summary>
        public ItemPickup Drop()
        {
            if (!IsEmpty())
            {
                IInventoryItem item = GetItemRef();
                if (item == null)
                {
                    return(null);
                }

                CharacterItemDropPrefabTrait trait = new Character().GetTrait <CharacterItemDropPrefabTrait>();

                ItemPickup dropped  = null;
                Vector3    position = internalInv.transform.localPosition;
                // Try making the positions random, instead of letting the objects stuck into together.
                position.x = position.x + UnityEngine.Random.Range(0f, 0.85f);
                position.y = position.y + UnityEngine.Random.Range(0.75f, 1f);
                position.z = position.z + UnityEngine.Random.Range(0f, 0.85f);

                Vector3    arg      = new Vector3(UnityEngine.Random.Range(0.75f, 1.3f), UnityEngine.Random.Range(0.75f, 1.3f), UnityEngine.Random.Range(0.75f, 1.3f));
                Quaternion rotation = new Quaternion(0f, 0f, 0f, 1f);
                GameObject go       = NetCull.InstantiateDynamicWithArgs <Vector3>(trait.prefab, position, rotation, arg);
                dropped = go.GetComponent <ItemPickup>();
                if (!dropped.SetPickupItem(item))
                {
                    //Debug.LogError($"Could not make item pickup for {item}", inventory);
                    NetCull.Destroy(go);
                    //internalInv.RemoveItem(item);
                    //internalInv.MarkSlotDirty(Slot);
                    return(null);
                }

                internalInv.RemoveItem(item);
                //internalInv.MarkSlotDirty(Slot);
                return(dropped);
                //DropHelper.DropItem(this.internalInv, this.Slot);
            }

            return(null);
        }
Пример #4
0
        private object Spawn(string prefab, Vector3 location, Quaternion rotation, int rep)
        {
            object result = null;

            for (int i = 0; i < rep; i++)
            {
                if (prefab == ":player_soldier")
                {
                    result = NetCull.InstantiateDynamic(uLink.NetworkPlayer.server, prefab, location, rotation);
                }
                else if (prefab.Contains("C130"))
                {
                    result = NetCull.InstantiateClassic(prefab, location, rotation, 0);
                }
                else
                {
                    GameObject gameObject = NetCull.InstantiateStatic(prefab, location, rotation);
                    result = gameObject;
                    StructureComponent component = gameObject.GetComponent <StructureComponent>();
                    if (component != null)
                    {
                        result = new Entity(component);
                    }
                    else
                    {
                        DeployableObject component2 = gameObject.GetComponent <DeployableObject>();
                        if (component2 != null)
                        {
                            component2.ownerID   = 0uL;
                            component2.creatorID = 0uL;
                            component2.CacheCreator();
                            component2.CreatorSet();
                            result = new Entity(component2);
                        }
                    }
                }
            }
            return(result);
        }
Пример #5
0
        int CleanAllDeployables(string name, bool all)
        {
            int  destroyed     = 0;
            bool shoulddestroy = true;

            foreach (DeployableObject deployable in UnityEngine.Resources.FindObjectsOfTypeAll <DeployableObject>())
            {
                if (deployable.gameObject.name == name)
                {
                    if (!all && deployable._carrier != null)
                    {
                        continue;
                    }
                    if (shouldDestroy(deployable.transform.position, all))
                    {
                        NetCull.Destroy(deployable.gameObject);
                        destroyed++;
                    }
                }
            }
            return(destroyed);
        }
Пример #6
0
        public static void OnShoot(ShootEvent se)
        {
            if (RustPP.Data.Globals.UserIsLogged(se.Player))
            {
                RustPP.Data.Entities.User user = RustPP.Data.Globals.GetInternalUser(se.Player);
                if (user.SpawningPrefab)
                {
                    UnityEngine.Quaternion rotation = se.Player.Character.rotation;

                    /*Controllable controllable = se.Player.Character.controllable;
                     * if (user.PrefabName == ":player_soldier")
                     * {
                     *  ServerManagement.Get().EraseCharactersForClient(se.Player.PlayerClient, true, se.Player.NetUser);
                     * }*/
                    NetCull.InstantiateDynamic(user.PrefabName, se.EndPos, rotation);

                    /*if(user.PrefabName == ":player_soldier")
                     * {
                     *  se.Player.PlayerClient = ServerManagement.Get().CreatePlayerClientForUser(se.Player.NetUser);
                     * }*/
                }
            }
        }
    private bool ValidatePrefab()
    {
        GameObject gameObject;
        Type       type;

        if (string.IsNullOrEmpty(this._sleepingAvatarPrefab))
        {
            return(false);
        }
        NetCull.PrefabSearch prefabSearch = NetCull.LoadPrefab(this._sleepingAvatarPrefab, out gameObject);
        if ((int)prefabSearch != 1)
        {
            Debug.LogError(string.Format("sleeping avatar prefab named \"{0}\" resulted in {1} which was not {2}(required)", this.prefab, prefabSearch, NetCull.PrefabSearch.NGC));
            return(false);
        }
        IDMain component = gameObject.GetComponent <IDMain>();

        if (!(component is SleepingAvatar))
        {
            Debug.LogError(string.Format("Theres no Sleeping avatar on prefab \"{0}\"", this.prefab), gameObject);
            return(false);
        }
        this._hasInventory = component.GetLocal <Inventory>();
        TakeDamage local = component.GetLocal <TakeDamage>();

        this._hasTakeDamage = local;
        if (!this._hasTakeDamage)
        {
            type = null;
        }
        else
        {
            type = local.GetType();
        }
        this._takeDamageType = type;
        return(true);
    }
Пример #8
0
 public void DestroyObject(GameObject go)
 {
     Contract.Requires(go != null);
     NetCull.Destroy(go);
 }
Пример #9
0
 public void NewObject()
 {
     DeployableObject = NetCull.InstantiateStatic(";deploy_wood_box", origin + h, character.rotation).GetComponent <DeployableObject>();
     DeployableObject.SetupCreator(character.controllable);
 }
Пример #10
0
        void cmdChatBan(NetUser netuser, string command, string[] args)
        {
            if (!hasAccess(netuser, "canairdrop"))
            {
                SendReply(netuser, notAllowed); return;
            }

            // CALL 1 AIRDROP
            if (args.Length == 0)
            {
                SendReply(netuser, calledAirdrop); SupplyDropZone.CallAirDrop(); return;
            }


            // CANCEL ALL AIRDROPS
            if (args.Length == 1 && args[0].ToString() == "cancel")
            {
                int planenumber = 0;
                foreach (SupplyDropPlane plane in UnityEngine.Resources.FindObjectsOfTypeAll <SupplyDropPlane>())
                {
                    if (plane.gameObject.name == "C130")
                    {
                        continue;
                    }
                    planenumber++;
                    plane.NetDestroy();
                }
                SendReply(netuser, string.Format(cancelledAirdrop, planenumber.ToString()));
                return;
            }

            // DESTROY ALL SUPPLY CRATES
            if (args.Length == 1 && args[0].ToString() == "destroy")
            {
                int cratenumber = 0;
                foreach (SupplyCrate crate in UnityEngine.Resources.FindObjectsOfTypeAll <SupplyCrate>())
                {
                    if (crate.gameObject.name == "SupplyCrate")
                    {
                        continue;
                    }
                    cratenumber++;
                    NetCull.Destroy(crate.gameObject);
                }
                SendReply(netuser, string.Format(destroyedCrates, cratenumber.ToString()));
                return;
            }

            // CALL MASS AIRDROP
            int number;

            if (args.Length == 1 && int.TryParse(args[0], out number))
            {
                SendReply(netuser, string.Format(massAirdrop, number.ToString()));
                for (int i = 0; i < number; i++)
                {
                    SupplyDropZone.CallAirDrop();
                }
                return;
            }

            // CALL AN AIRDROP ON POSITION
            float x;
            float z;

            if (args.Length > 1 && float.TryParse(args[0], out x))
            {
                if (args.Length == 2)
                {
                    float.TryParse(args[1], out z);
                }
                else
                {
                    float.TryParse(args[2], out z);
                }

                if (z != default(float))
                {
                    cachedPos = new Vector3(x, 0f, z);
                    SupplyDropZone.CallAirDropAt(cachedPos);
                    SendReply(netuser, string.Format(airdropPos, cachedPos.ToString()));
                }
                return;
            }

            // CALL AN AIRDROP TO A PLAYER POSITION
            NetUser targetuser = rust.FindPlayer(args[0]);

            if (targetuser != null)
            {
                cachedPos = targetuser.playerClient.lastKnownPosition;
                if (cachedPos != default(Vector3))
                {
                    SupplyDropZone.CallAirDropAt(cachedPos);
                    SendReply(netuser, string.Format(airdropPlayer, cachedPos.ToString(), targetuser.playerClient.userName.ToString()));
                }
                return;
            }


            SendReply(netuser, wrongarguments);
        }
Пример #11
0
 public void InvGetNetworkUpdate()
 {
     uLink.BitStream stream = new uLink.BitStream(false);
     FougeritePlayer.Inventory.InternalInventory.GenerateInvBitStream(ref stream, false);
     NetCull.RPC(FougeritePlayer.Inventory.InternalInventory, "GNUP", FougeritePlayer.NetworkPlayer, stream.GetDataByteArray());
 }
Пример #12
0
 /// <summary>
 /// Kicks this player from the game
 /// </summary>
 /// <param name="reason"></param>
 public void Kick(string reason)
 {
     ServerManagement.Get().networkView.RPC("KP", netUser.networkPlayer, reason);
     NetCull.CloseConnection(netUser.networkPlayer, true);
 }
Пример #13
0
 protected void RS(float duration)
 {
     NetCull.ResynchronizeClock((double)duration);
 }
Пример #14
0
 public static void Disconnect(string reason, bool sendReasonToServer = true)
 {
     NetCull.Disconnect();
     //NetCull.DisconnectImmediate();
 }
Пример #15
0
 public void DestroyObject(GameObject go)
 {
     NetCull.Destroy(go);
 }
Пример #16
0
 /// <summary>
 /// Kicks the player from the game
 /// </summary>
 /// <param name="reason"></param>
 public void Kick(string reason)
 {
     Rust.Notice.Popup(netUser.networkPlayer, "", reason, 10f);
     NetCull.CloseConnection(netUser.networkPlayer, false);
 }
Пример #17
0
 void NewObject()
 {
     lastObject = NetCull.InstantiateStatic(";deploy_wood_box", nextForward + heightAdjusment, character.rotation).GetComponent <DeployableObject>();
     lastObject.SetupCreator(character.controllable);
 }