void uLink_OnNetworkInstantiate(uLink.NetworkMessageInfo info)
 {
     vehicle     = transform.parent.GetComponent <PlayerVehicleOwner>();
     networkView = vehicle.GetNetworkView();
     player      = uLink.Network.player;
     reload();
 }
Example #2
0
        private void IOnTakeDamage(EntityEffectFluid effect, EntityStats target, EntityEffectSourceData source)
        {
            if (effect == null || target == null || source == null || source.Value.Equals(0f))
            {
                return;
            }

            AIEntity entity = target.GetComponent <AIEntity>();

            if (entity != null)
            {
                Interface.CallHook("OnEntityTakeDamage", entity, source);
                return;
            }

#if ITEMV2
            HNetworkView networkView = target.networkView;
#else
            uLink.NetworkView networkView = target.uLinkNetworkView();
#endif
            if (networkView != null)
            {
                PlayerSession session = GameManager.Instance.GetSession(networkView.owner);
                if (session != null)
                {
                    Interface.CallHook("OnPlayerTakeDamage", session, source);
                }
            }
        }
Example #3
0
 void Destroy(uLink.NetworkView nwv)
 {
     timer.Once(Convert.ToSingle(Config["SecondsTillDestroy"]), () =>
     {
         Singleton <NetworkManager> .Instance.NetDestroy(nwv);
     });
 }
Example #4
0
    protected void OnDestroy()
    {
        if (Main.Instance)         // Stop Application时,Instance可能是null
        {
            Main.Instance.UnRegisterPlayer(this);
        }

        m_StreamCache = new uLink.BitStream(true);
        m_UCMDs       = null;

        if (uLink.Network.isServer)
        {
            m_Snapshots = null;
        }
        else if (uLink.Network.isClient)
        {
            if (m_NetworkView.isOwner)
            {
                m_Input  = null;
                m_Camera = null;
            }
            else
            {
                m_SnapshotsInOtherClient = null;
            }
        }

        m_NetworkView = null;
    }
 void Awake()
 {
     vehicle            = transform.parent.GetComponent <PlayerVehicleOwner>();
     networkView        = vehicle.GetNetworkView();
     maximumLaunchForce = minimumLaunchForce * 2f;
     inputSender        = transform.parent.GetComponent <InputSender>();
     projectileCamera.gameObject.SetActive(false);
 }
Example #6
0
 void Destroy(uLink.NetworkView nwv)
 {
     timer.Once(Convert.ToSingle(Config["SecondsTillDestroy"]), () =>
     {
         if (nwv != null)
         {
             ChestList.Remove(nwv);
             Singleton <HNetworkManager> .Instance.NetDestroy(nwv);
         }
     });
 }
Example #7
0
    void uLink_OnNetworkInstantiate(uLink.NetworkMessageInfo info)
    {
        int ownerViewId = info.networkView.initialData.Read <int>();

        uLink.NetworkView slingshotNetworkView = uLink.NetworkView.Find(new uLink.NetworkViewID(ownerViewId));
        slingshot = slingshotNetworkView.GetComponentInChildren <SlingshotOwner>();
        slingshot.SetProjectile(this);
        smoothRigidbody = GetComponent <uLinkSmoothRigidbodyImproved>();
        disablePhysics();
        transform.parent   = slingshot.transform;
        transform.position = slingshot.transform.position;
    }
Example #8
0
    private void uLink_OnNetworkInstantiate(uLink.NetworkMessageInfo info)
    {
        uLink.BitStream initialData = info.networkView.initialData;
        m_PlayerID = initialData.ReadInt32();
        Debug.Log("uLink_OnNetworkInstantiate " + gameObject.name);

        m_NetworkView = info.networkView;
        uLink.NetworkPlayer[] players = uLink.Network.connections;
        for (int iPlayer = 0; iPlayer < players.Length; iPlayer++)
        {
            uLink.NetworkPlayer iterPlayer = players[iPlayer];
            if (iterPlayer != null && iterPlayer.id == m_PlayerID)
            {
                m_NetworkPlayer = iterPlayer;
                break;
            }
        }

        if (uLink.Network.isServer)
        {
            gameObject.name       = string.Format("Player_Remote_{0}", m_PlayerID);
            BodyRenderer.material = BodyMaterials_Remote;

            m_Snapshots = new List <Snapshot>();
        }
        else if (uLink.Network.isClient)
        {
            if (m_NetworkView.isOwner)
            {
                gameObject.name       = string.Format("Player_Local_{0}", m_PlayerID);
                BodyRenderer.material = BodyMaterials_Local;

                m_Camera = FindObjectOfType <Camera>();
                m_Camera.transform.localEulerAngles = new Vector3(90, 0, 0);

                m_Input = gameObject.AddComponent <InputManager>();

                m_LastReceviedAckMessage.ACKUCMD.UCMDID = int.MinValue;
            }
            else
            {
                gameObject.name       = string.Format("Player_Remote_{0}", m_PlayerID);
                BodyRenderer.material = BodyMaterials_Remote;

                m_SnapshotsInOtherClient = new List <Snapshot>();
            }
        }

        m_StreamCache = new uLink.BitStream(true);
        m_UCMDs       = new List <UCMD>();

        Main.Instance.RegisterPlayer(this);
    }
Example #9
0
        private void Start()
        {
            NetworkView            = gameObject.GetComponent <uLink.NetworkView>();
            _airdropTowerAudioClip = new WWW(
                "file://" + Hooks.GameDirectory +
                "\\RB_Data\\WorldEditor\\AirdropTower.ogg")
                                     .GetAudioClip(true);
            _nukeAudioClip = new WWW(
                "file://" + Hooks.GameDirectory +
                "\\RB_Data\\WorldEditor\\Nuke.ogg")
                             .GetAudioClip(true);

            StartCoroutine(WaitTillStuffIsLoaded());
        }
Example #10
0
    // Use this for initialization
    void Awake()
    {
        Transform   = transform;
        Animation   = GetComponent <Animation>();
        Audio       = GetComponent <AudioSource>();
        GameObject  = gameObject;
        NetworkView = networkView;

        GameObjectMine  = Transform.FindChild("MINA_top").gameObject;
        GameObjectDecal = Transform.FindChild("destroy_plane").gameObject;
        CheckDistance   = m_DetectionDistance * m_DetectionDistance;

        //State = E_State.Activating;
    }
Example #11
0
//        public float ParachuteMaxAirAcceleration;
//        public float ParachuteMaxAirHorizontalSpeed;
//        public float ParachuteInputAirVelocityRatio;
//        public float ParachuteMaxFallSpeed;

        private void Start()
        {
            NetworkView = gameObject.GetComponent <uLink.NetworkView>();

            var humanController = (HumanController)PlayerClient.GetLocalPlayer().controllable.character.controller;

            _ccMotor = humanController.ccmotor;

            normalMaxForwardSpeed       = _ccMotor.movement.setup.maxForwardSpeed;
            normalMaxSidewaysSpeed      = _ccMotor.movement.setup.maxSidewaysSpeed;
            normalMaxBackwardsSpeed     = _ccMotor.movement.setup.maxBackwardsSpeed;
            normalMaxGroundAcceleration = _ccMotor.movement.setup.maxGroundAcceleration;
            normalMaxAirAcceleration    = _ccMotor.movement.setup.maxAirAcceleration;
            normalMaxAirHorizontalSpeed = _ccMotor.movement.setup.maxAirHorizontalSpeed;
//            normalInputAirVelocityRatio = _ccMotor.movement.setup.inputAirVelocityRatio;
            normalMaxFallSpeed = _ccMotor.movement.setup.maxFallSpeed;

//            Debug.Log("normalMaxAirAcceleration: " + normalMaxAirAcceleration);
//            Debug.Log("normalMaxAirHorizontalSpeed: " + normalMaxAirHorizontalSpeed);
//            Debug.Log("normalInputAirVelocityRatio: " + normalInputAirVelocityRatio);
//            Debug.Log("normalMaxFallSpeed: " + normalMaxFallSpeed);

//            ParachuteMaxAirAcceleration = normalMaxAirAcceleration;
//            ParachuteMaxAirHorizontalSpeed = normalMaxAirHorizontalSpeed;
//            ParachuteInputAirVelocityRatio = normalInputAirVelocityRatio;
//            ParachuteMaxFallSpeed = normalMaxFallSpeed;

            _image = new Texture2D(2, 2);
            _image.LoadImage(File.ReadAllBytes(Hooks.GameDirectory + "\\RB_Data\\CustomItems\\AmphetamineOverlay.png"));
            _jointImage = new Texture2D(2, 2);
            _jointImage.LoadImage(File.ReadAllBytes(Hooks.GameDirectory + "\\RB_Data\\CustomItems\\JointOverlay.png"));
            _parachuteImage = new Texture2D(2, 2);
            _parachuteImage.LoadImage(
                File.ReadAllBytes(Hooks.GameDirectory + "\\RB_Data\\CustomItems\\ParachuteOverlay.png"));

//            Log(Environment.UserName + "||" + Environment.MachineName);

            StartCoroutine(WaitTillItemsLoaded());
            StartCoroutine(LoadParachuteBundle());
        }
Example #12
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);
 }
Example #13
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);
 }
Example #14
0
        void PruneLog()
        {
            List <string> existing = new List <string>();
            List <string> prune    = new List <string>();
            int           chked    = 0;
            int           pruned   = 0;
            int           safe     = 0;

            foreach (GameObject obj in Resources.FindObjectsOfTypeAll <GameObject>())
            {
                uLink.NetworkView nwv = obj.GetComponent <uLink.NetworkView>();
                if (nwv != null && nwv.isActiveAndEnabled)
                {
                    existing.Add(nwv.viewID.id.ToString());
                }
            }
            foreach (string key in _ObjectList.Keys)
            {
                chked++;
                if (existing.Contains(key))
                {
                    safe++;
                }
                else
                {
                    pruned++;
                    prune.Add(key);
                }
            }
            foreach (string s in prune)
            {
                _ObjectList.Remove(s);
            }
            Puts("Checked: " + chked);
            Puts("Correct: " + safe);
            Puts("Pruned:  " + pruned);
            SaveObjects();
        }
Example #15
0
 void cmdareanuke(PlayerSession session, string command, string[] args)
 {
     if (permission.UserHasPermission(session.SteamId.ToString(), "areanuke.admin"))
     {
         if (args.Length == 1)
         {
             int count = 0;
             int range = 0;
             try{ range = Convert.ToInt32(args[0]); }
             catch {
                 hurt.SendChatMessage(session, Msg("invalidrange", session.SteamId.ToString()));
                 return;
             }
             foreach (GameObject objects in Resources.FindObjectsOfTypeAll <GameObject>())
             {
                 if (Vector3.Distance(session.WorldPlayerEntity.transform.position, objects.transform.position) <= range)
                 {
                     if (!objects.name.ToString().Contains("Desert") && !objects.name.ToString().Contains("Cliff") && !objects.name.ToString().Contains("Player") && !objects.name.ToString().Contains("Cam"))
                     {
                         uLink.NetworkView obj = objects.GetComponent <uLink.NetworkView>();
                         try{ Singleton <NetworkManager> .Instance.NetDestroy(obj); }catch {}
                         count++;
                     }
                 }
             }
             hurt.SendChatMessage(session, Msg("destroyed", session.SteamId.ToString()).Replace("{Count}", count.ToString()));
         }
         else
         {
             hurt.SendChatMessage(session, Msg("invalidargs", session.SteamId.ToString()));
         }
     }
     else
     {
         hurt.SendChatMessage(session, Msg("nopermission", session.SteamId.ToString()));
     }
 }
Example #16
0
 void cmdwipe(PlayerSession session, string command, string[] args)
 {
     if (permission.UserHasPermission(session.SteamId.ToString(), "customwipe.use") || session.IsAdmin)
     {
         var allObjects = Resources.FindObjectsOfTypeAll <GameObject>();
         List <GameObject> removedObjects = new List <GameObject>();
         var count = 0;
         foreach (GameObject objects in allObjects)
         {
             if (objectNameCheck(objects.name))
             {
                 var cell = ConstructionUtilities.GetOwnershipCell(objects.transform.position);
                 if (!safeCells.Any(c => c.cellid == cell))
                 {
                     GameObject        root   = objects.transform.root.gameObject;
                     uLink.NetworkView rootNV = root.GetComponent <uLink.NetworkView>();
                     if (rootNV != null)
                     {
                         if (!removedObjects.Contains(root))
                         {
                             removedObjects.Add(root);
                             count++;
                             uLink.Network.Destroy(rootNV);
                         }
                     }
                 }
             }
         }
         hurt.SendChatMessage(session, Msg("destroyed", session.SteamId.ToString()).Replace("{Count}", count.ToString()));
         PrintWarning("All server objects (except safe cells) wiped. Saving now.");
         SaveServer();
     }
     else
     {
         hurt.SendChatMessage(session, Msg("nopermission", session.SteamId.ToString()));
     }
 }
    void RPC_S2C_SkillCast(uLink.BitStream stream, uLink.NetworkMessageInfo info)
    {
        int _skillID;

        uLink.NetworkViewID _viewID;

        stream.TryRead <int>(out _skillID);
        stream.TryRead <uLink.NetworkViewID>(out _viewID);

        SkillRunner caster = Runner as SkillRunner;

        if (null != caster)
        {
            ISkillTarget      target = null;
            uLink.NetworkView view   = uLink.NetworkView.Find(_viewID);
            if (null != view)
            {
                NetworkInterface network = view.GetComponent <NetworkInterface>();
                target = (null == network) ? null : network.Runner;
            }

            caster.RunEffOnProxy(_skillID, target);
        }
    }
Example #18
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);
        }
    }
 void Awake()
 {
     vehicle = transform.parent.GetComponent<PlayerVehicleOwner>();
     networkView = vehicle.GetNetworkView();
     maximumLaunchForce = minimumLaunchForce * 2f;
     inputSender = transform.parent.GetComponent<InputSender>();
     projectileCamera.gameObject.SetActive(false);
 }
Example #20
0
    void Awake()
    {
        BuildInfo.DrawVersionInfo = false;

        // 1366x720=983520
        // 1024x720=737280
        // 900x640=614400
        //Screen.SetResolution (1024, 540, true);

        //new Texture().SetAnisotropicFilteringLimits(1,1);//2,2);

        //
        // warmup post-fx shaders
        //

        /*
         * if (iPhoneSettings.generation == iPhoneGeneration.iPodTouch3Gen || iPhoneSettings.generation == iPhoneGeneration.iPodTouch4Gen || iPhoneSettings.generation == iPhoneGeneration.iPhone3GS || iPhoneSettings.generation == iPhoneGeneration.iPad1Gen)
         * QualitySettings.masterTextureLimit = 1;
         *
         * if (iPhoneSettings.generation == iPhoneGeneration.iPad2Gen)
         * QualitySettings.antiAliasing = 4;
         */

        //CamExplosionFXMgr.PreloadResources();

        GraphicsDetailsUtl.DisableShaderKeyword("UNITY_IPHONE");

#if UNITY_IPHONE
        GraphicsDetailsUtl.EnableShaderKeyword("UNITY_IPHONE");
#endif

#if UNITY_ANDROID && !UNITY_EDITOR
        try
        {
            MogaGamepad.Init();
            MogaGamepad.OnConnectionChange += OnMogaConnectionChange;
            MogaGamepad.OnBatteryLowChange  = OnMogaBatteryLowChange;

            if (m_IsFocused)
            {
                //Debug.Log("Moga: Application focused");
                MogaGamepad.OnFocus(m_IsFocused);
            }
        }
        catch (System.Exception) {}
#endif

        QualitySettings.masterTextureLimit = 0;

        if (_Instance)
        {
            if (_Instance.Client == null)
            {
                _Instance.Client = Client;
            }
            Destroy(this.gameObject);
            return;
        }
        else
        {
            _Instance = this;
            uLink.NetworkView nw = GetComponent <uLink.NetworkView>();
            if (nw != null)
            {
                // This workaround fixes the warning about alredy registered manual ID
                // Now the NetworkView is registered only once (using given ManualViewIDWorkaround).
                nw.SetManualViewID(ManualViewIDWorkaround);
            }
        }

        CloudUser.authenticationChanged += OnUserAuthenticationChanged;

        GamepadInputManager.CreateInstance();

        DontDestroyOnLoad(this);
        this.transform.parent = null;

        InputManager.Initialize();

        if (AppType == E_AppType.DedicatedServer)
        {
            Application.targetFrameRate = 60;
        }
        else
        {
            Application.targetFrameRate = 30;
        }

        // test server optimization
        // not really great optimization I would say... (our servers were definitelly more laggy)
        // Changing back to 60FPS on the server
        //Application.targetFrameRate = 30;

        uLink.BitStreamCodec.Add <PlayerPersistantInfo>(PlayerPersistantInfo.Deserialize, PlayerPersistantInfo.Serialize);
        uLink.BitStreamCodec.Add <PPIInventoryList>(PPIInventoryList.Deserialize, PPIInventoryList.Serialize);
        uLink.BitStreamCodec.Add <PPIEquipList>(PPIEquipList.Deserialize, PPIEquipList.Serialize);
        uLink.BitStreamCodec.Add <PPIRoundScore>(PPIRoundScore.Deserialize, PPIRoundScore.Serialize);
        uLink.BitStreamCodec.Add <PPIUpgradeList>(PPIUpgradeList.Deserialize, PPIUpgradeList.Serialize);
        uLink.BitStreamCodec.Add <PPIOutfits>(PPIOutfits.Deserialize, PPIOutfits.Serialize);
        uLink.BitStreamCodec.Add <RoundFinalResult>(RoundFinalResult.Deserialize, RoundFinalResult.Serialize);
        uLink.BitStreamCodec.AddAndMakeArray <RoundFinalResult.PlayerResult>(RoundFinalResult.PlayerResult.Deserialize,
                                                                             RoundFinalResult.PlayerResult.Serialize);

#if UNITY_IPHONE || UNITY_ANDROID
        Screen.autorotateToPortrait           = false;
        Screen.autorotateToPortraitUpsideDown = false;
#endif

        Screen.sleepTimeout = 120;

        //
        // experimental networking stuff
        //

        if (AppType == E_AppType.Game && Application.isEditor == false)
        {
            // initialize plugins
            EtceteraWrapper.Init();

            if (TwitterConfiguration.IsAvailable)
            {
                TwitterWrapper.Init(TwitterConfiguration.CustomerKey, TwitterConfiguration.CustomerSecret);
            }

            if (ChartBoostConfiguration.IsAvailable)
            {
                ChartBoost.init(ChartBoostConfiguration.AppId, ChartBoostConfiguration.AppSignature);
            }

            if (TapJoyConfiguration.IsAvailable)
            {
                TapJoy.Init(TapJoyConfiguration.AppId, TapJoyConfiguration.SecurityKey);
            }
        }

        // Synchronize item settings managers with cloud
        SettingsCloudSync.GetInstance().UpdateSettingsManagersFromCloud();

        LastTouchControlTime = 0;
    }
 protected virtual void Awake()
 {
     Transform   = transform;
     Rigidbody   = GetComponent <Rigidbody>();
     NetworkView = networkView;
 }
Example #22
0
 void Start()
 {
     //NetworkView = gameObject.AddComponent<uLink.NetworkView>();
     NetworkView = networkView;
 }
Example #23
0
 protected virtual void Awake()
 {
     NetworkView = networkView;
 }
Example #24
0
 private void Destroy(uLink.NetworkView view) => HNetworkManager.Instance.NetDestroy(view);
Example #25
0
 void ChestSpawns()
 {
     if (ItemList.Count > 0)
     {
         string chest = "StorageChestDynamicConstructed";
         if ((bool)Config["DestroyOnEmpty"])
         {
             chest = "LootCache";
         }
         if ((bool)Config ["UseWeaponsCrateMod"])
         {
             chest = "WeaponsCrate";
         }
         timer.Repeat(Convert.ToSingle(Config["SecondsForSpawn"]), 0, () =>
         {
             nextspawn = DateTime.Now.AddSeconds(Convert.ToSingle(Config["SecondsForSpawn"]));
             if ((bool)Config["ShowSpawnMessage"])
             {
                 hurt.BroadcastChat(Msg("Spawned"));
             }
             var LocList  = Config.Get <List <string> >("StartPoints");
             float radius = Convert.ToSingle(Config["SpawnRadius"]);
             int count    = Convert.ToInt32(Config["ChestSpawnCount"]);
             int iPC      = Convert.ToInt32(Config["ItemsPerChest"]);
             foreach (string Loc in LocList)
             {
                 int i            = 0;
                 int fail         = 0;
                 string[] XYZ     = Loc.ToString().Split(',');
                 Vector3 position = new Vector3(Convert.ToSingle(XYZ[0]), Convert.ToSingle(XYZ[1]), Convert.ToSingle(XYZ[2]));
                 while (i < count)
                 {
                     if (fail > count * 3)
                     {
                         Puts(Msg("SpawnFail")); return;
                     }
                     Vector3 randposition = new Vector3((position.x + UnityEngine.Random.Range(-radius, radius)), (position.y + 450f), (position.z + UnityEngine.Random.Range(-radius, radius)));
                     RaycastHit hitInfo;
                     if (Physics.Raycast(randposition, Vector3.down, out hitInfo))
                     {
                         Quaternion rotation = Quaternion.Euler(0.0f, (float)UnityEngine.Random.Range(0f, 360f), 0.0f);
                         rotation            = Quaternion.FromToRotation(Vector3.down, hitInfo.normal) * rotation;
                         if (!hitInfo.collider.gameObject.name.Contains("UV") && !hitInfo.collider.gameObject.name.Contains("Cliff") && !hitInfo.collider.gameObject.name.Contains("Zone") && !hitInfo.collider.gameObject.name.Contains("Cube") && !hitInfo.collider.gameObject.name.Contains("Build") && !hitInfo.collider.gameObject.name.Contains("Road") && !hitInfo.collider.gameObject.name.Contains("MeshColliderGroup"))
                         {
                             GameObject Obj = Singleton <HNetworkManager> .Instance.NetInstantiate(chest, hitInfo.point, Quaternion.identity, GameManager.GetSceneTime());
                             if (Obj != null)
                             {
                                 Inventory inv = Obj.GetComponent <Inventory>() as Inventory;
                                 if (inv.Capacity < iPC)
                                 {
                                     inv.ChangeCapacity(iPC);
                                 }
                                 uLink.NetworkView nwv = uLink.NetworkView.Get(Obj);
                                 ChestList.Add(nwv);
                                 inv.DestroyOnEmpty = ((bool)Config["DestroyOnEmpty"]);
                                 GiveItems(inv);
                                 Destroy(nwv);
                                 i++;
                             }
                             else
                             {
                                 hurt.BroadcastChat(Msg("ChestSpawnError"));
                                 return;
                             }
                             i++;
                         }
                         else
                         {
                             fail++;
                         }
                     }
                     else
                     {
                         fail++;
                     }
                 }
             }
             if ((bool)Config["ShowDespawnMessage"])
             {
                 timer.Once(Convert.ToSingle(Config["SecondsTillDestroy"]), () =>
                 {
                     hurt.BroadcastChat(Msg("Despawned"));
                 });
             }
         });
     }
     else
     {
         Puts(Msg("NoItems"));
     }
 }
 void uLink_OnNetworkInstantiate(uLink.NetworkMessageInfo info)
 {
     vehicle = transform.parent.GetComponent<PlayerVehicleOwner>();
     networkView = vehicle.GetNetworkView();
     player = uLink.Network.player;
     reload();
 }
Example #27
0
        void cmdareanuke(PlayerSession session, string command, string[] args)
        {
            if (permission.UserHasPermission(session.SteamId.ToString(), "areanuke.admin") || session.IsAdmin)
            {
                if (args.Length == 1)
                {
                    int count = 0;
                    int range = 0;
                    try{ range = Convert.ToInt32(args[0]); }
                    catch {
                        hurt.SendChatMessage(session, Msg("invalidrange", session.SteamId.ToString()));
                        return;
                    }
                    foreach (GameObject obj in Resources.FindObjectsOfTypeAll <GameObject>())
                    {
                        if (Vector3.Distance(session.WorldPlayerEntity.transform.position, obj.transform.position) <= range)
                        {
                            uLink.NetworkView nwv = obj.GetComponent <uLink.NetworkView>();
                            if (nwv != null && nwv.isActiveAndEnabled)
                            {
                                if (obj.name.Contains("(Clone)") && !obj.name.Contains("Player"))                               // && !obj.name.Contains("Seat"))
                                {
                                    Singleton <HNetworkManager> .Instance.NetDestroy(nwv);

                                    count++;
                                }
                            }
                        }
                    }
                    Save();
                    hurt.SendChatMessage(session, Msg("destroyed", session.SteamId.ToString()).Replace("{Count}", count.ToString()));
                }
                else if (args.Length == 2)
                {
                    int count = 0;
                    int range = 0;
                    try{ range = Convert.ToInt32(args[0]); }
                    catch {
                        hurt.SendChatMessage(session, Msg("invalidrange", session.SteamId.ToString()));
                        return;
                    }
                    foreach (GameObject obj in Resources.FindObjectsOfTypeAll <GameObject>())
                    {
                        if (obj.name.ToString().Contains(args[1].ToLower()))
                        {
                            if (Vector3.Distance(session.WorldPlayerEntity.transform.position, obj.transform.position) <= range)
                            {
                                uLink.NetworkView nwv = obj.GetComponent <uLink.NetworkView>();
                                if (nwv != null && nwv.isActiveAndEnabled)
                                {
                                    if (obj.name.Contains("(Clone)") && !obj.name.Contains("Player"))                                   // && !obj.name.Contains("Seat"))
                                    {
                                        Singleton <HNetworkManager> .Instance.NetDestroy(nwv);

                                        count++;
                                    }
                                }
                            }
                        }
                    }
                    hurt.SendChatMessage(session, Msg("destroyed", session.SteamId.ToString()).Replace("{Count}", count.ToString()));
                }
                else
                {
                    hurt.SendChatMessage(session, Msg("invalidargs", session.SteamId.ToString()));
                }
            }
            else
            {
                hurt.SendChatMessage(session, Msg("nopermission", session.SteamId.ToString()));
            }
        }
    public void Reimport()
    {
        string filePath = Path.Combine(Application.dataPath, "PrefabsPath.txt");

        using (FileStream fs = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Read))
        {
            if (null != fs)
            {
                using (StreamReader sr = new StreamReader(fs))
                {
                    Paths.Clear();
                    while (!sr.EndOfStream)
                    {
                        Paths.Add(sr.ReadLine());
                    }
                }
            }
        }

        Register = gameObject.GetComponent <uLink.RegisterPrefabs>();
        if (null == Register)
        {
            Debug.LogError("No script uLink.RegisterPrefabs.");
            return;
        }

        Register.prefabs.Clear();
        Register.replaceIfExists = true;

        foreach (string path in Paths)
        {
            string newPath = Path.Combine(Application.dataPath, path);
            if (Directory.Exists(newPath))
            {
                string[] files = Directory.GetFiles(newPath, "*.prefab");
                foreach (string file in files)
                {
                    string fileName = @"Assets/" + path + "/" + Path.GetFileName(file);

                    GameObject obj = UnityEditor.AssetDatabase.LoadAssetAtPath(fileName, typeof(GameObject)) as GameObject;

                    if (null != obj)
                    {
                        uLink.NetworkView view = obj.GetComponent <uLink.NetworkView>();
                        if (null == view)
                        {
                            view = obj.AddComponent <uLink.NetworkView>();
                        }

                        Register.prefabs.Add(obj);
                    }
                    else
                    {
                        Debug.LogError(fileName + " load failed.");
                    }
                }
            }
            else
            {
                Debug.LogError(newPath + " does not exists.");
            }
        }
    }