Beispiel #1
0
 public void OnDestroy()
 {
     if (Network.isServer)
     {
         ExplosionTool.explode(base.transform.position, (float)ExplosiveStats.getRange(23007), ExplosiveStats.getDamage(23007));
         NetworkEffects.askEffect("Effects/grenade", base.transform.position + Vector3.up, Quaternion.Euler(-90f, 0f, 0f), -1f);
         NetworkEffects.askEffect("Effects/rubble", base.transform.position, Quaternion.Euler(-90f, 0f, 0f), -1f);
         NetworkSounds.askSound("Sounds/Projectiles/grenade", base.transform.position, 1f, UnityEngine.Random.Range(0.95f, 1.05f), 2f);
     }
 }
Beispiel #2
0
    public void destroyBarricade(Vector3 position)
    {
        int indexFromPositionServer;

        ClientItem[,] crateItems;
        Point2  region  = NetworkRegions.getRegion(position);
        bool    flag    = false;
        int     item    = -1;
        Vector3 vector3 = Vector3.zero;

        if (Network.isServer)
        {
            indexFromPositionServer = SpawnBarricades.getIndexFromPositionServer(region, position);
            if (SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id == 16019 || SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id == 16025 || SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id == 16023)
            {
                if (SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id != 16019)
                {
                    string[] strArrays = Packer.unpack(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].state, '\u005F');
                    crateItems = InteractionInterface.getCrateItems(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id, Sneaky.expose(strArrays[2]));
                }
                else
                {
                    crateItems = InteractionInterface.getCrateItems(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id, Sneaky.expose(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].state));
                }
                for (int i = 0; i < 2; i++)
                {
                    for (int j = 0; j < BarricadeStats.getCapacity(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id); j++)
                    {
                        if (!ItemStackable.getStackable(crateItems[i, j].id))
                        {
                            SpawnItems.drop(crateItems[i, j].id, crateItems[i, j].amount, crateItems[i, j].state, position);
                        }
                        else
                        {
                            for (int k = 0; k < crateItems[i, j].amount; k++)
                            {
                                SpawnItems.drop(crateItems[i, j].id, 1, crateItems[i, j].state, position);
                            }
                        }
                    }
                }
            }
            else if (ExplosiveStats.getDamage(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id) != 0)
            {
                flag = true;
                item = SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id;
                if (SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id != 16015)
                {
                    vector3 = position + Vector3.up;
                    NetworkEffects.askEffect("Effects/grenade", position, Quaternion.Euler(-90f, 0f, 0f), -1f);
                    NetworkSounds.askSoundMax("Sounds/Projectiles/grenade", position, 1f, UnityEngine.Random.Range(0.95f, 1.05f), 4f, 64f);
                }
                else
                {
                    vector3 = position + SpawnBarricades.regions[region.x, region.y].models[indexFromPositionServer].transform.up;
                    NetworkEffects.askEffect("Effects/bomb", position, Quaternion.Euler(-90f, 0f, 0f), -1f);
                    NetworkSounds.askSoundMax("Sounds/Projectiles/bomb", position, 1f, UnityEngine.Random.Range(0.95f, 1.05f), 4f, 64f);
                }
            }
            if (indexFromPositionServer != -1 && indexFromPositionServer < SpawnBarricades.regions[region.x, region.y].barricades.Count)
            {
                SpawnBarricades.regions[region.x, region.y].barricades.RemoveAt(indexFromPositionServer);
            }
        }
        indexFromPositionServer = SpawnBarricades.getIndexFromPositionClient(region, position);
        if (indexFromPositionServer != -1 && indexFromPositionServer < SpawnBarricades.regions[region.x, region.y].models.Count)
        {
            UnityEngine.Object.Destroy(SpawnBarricades.regions[region.x, region.y].models[indexFromPositionServer]);
            SpawnBarricades.regions[region.x, region.y].models.RemoveAt(indexFromPositionServer);
        }
        if (flag)
        {
            ExplosionTool.explode(vector3, (float)ExplosiveStats.getRange(item), ExplosiveStats.getDamage(item));
        }
    }
Beispiel #3
0
    public void Update()
    {
        if (this.real)
        {
            if (Network.isServer)
            {
                if (base.transform.position.y < Ocean.level - 1f && this.health != this.maxHealth)
                {
                    base.networkView.RPC("tellHealth", RPCMode.All, new object[] { this.maxHealth });
                }
                if ((this.wrecked || this.exploded) && this.headlights)
                {
                    base.networkView.RPC("tellHeadlights", RPCMode.All, new object[] { false });
                }
                if ((this.wrecked || this.exploded) && this.sirens)
                {
                    base.networkView.RPC("tellSirens", RPCMode.All, new object[] { false });
                }
                if (!this.wrecked)
                {
                    if (base.transform.position.y < Ocean.level - 1f)
                    {
                        this.wrecked = true;
                        base.networkView.RPC("tellWrecked", RPCMode.All, new object[] { true });
                    }
                    else if (this.health < 10)
                    {
                        this.wrecked = true;
                        base.networkView.RPC("tellWrecked", RPCMode.All, new object[] { true });
                    }

                    // Checking if NOW wrecked
                    if (this.wrecked)
                    {
                        this.ejectAll();
                        this.lastWrecked = Time.realtimeSinceStartup;
                    }
                    else if (this.lastSpeed != 0 && Time.realtimeSinceStartup - this.lastPump > 3f && this.fuel > 0)
                    {
                        this.lastPump = Time.realtimeSinceStartup;
                        this.burn(1);
                        if (this.fuel == 0)
                        {
                            base.networkView.RPC("tellHeadlights", RPCMode.All, new object[] { false });
                            base.networkView.RPC("tellSirens", RPCMode.All, new object[] { false });
                        }
                    }
                }
                else if (Time.realtimeSinceStartup - this.lastWrecked > 10f && !this.exploded && base.transform.position.y > Ocean.level - 1f)
                {
                    this.exploded = true;
                    base.networkView.RPC("tellExploded", RPCMode.All, new object[] { true });
                    ExplosionTool.explode(base.transform.position + base.transform.forward, 10f, 70);
                    NetworkEffects.askEffect("Effects/bomb", this.position, Quaternion.Euler(-90f, 0f, 0f), -1f);
                    NetworkSounds.askSoundMax("Sounds/Projectiles/bomb", this.position, 1f, UnityEngine.Random.Range(0.95f, 1.05f), 4f, 64f);
                    base.rigidbody.AddForce(new Vector3(0f, 20f, 0f), ForceMode.Impulse);
                    base.rigidbody.AddTorque(new Vector3((float)UnityEngine.Random.Range(-20, 20), 0f, 0f), ForceMode.Impulse);
                    base.Invoke("removeFromWorld", 30f);
                }

                if (this.lastSpeed == 0)
                {
                    this.lastPump = Time.realtimeSinceStartup + 1f;
                }
                if (this.passengers[0] == null && (double)(Time.realtimeSinceStartup - this.lastTick) > 0.2)
                {
                    this.lastTick = Time.realtimeSinceStartup;
                    if ((base.transform.position - this.lastPosition).sqrMagnitude > 1f)
                    {
                        this.lastPosition = this.position;
                        base.networkView.RPC("updatePosition", RPCMode.All, new object[] { base.transform.position, base.transform.rotation });
                    }
                }
            }
            if ((Movement.vehicle != this || !Movement.isDriving) && (!Network.isServer || this.passengers[0] != null))
            {
                base.rigidbody.MovePosition(Vector3.Lerp(base.transform.position, this.position, (float)NetworkInterpolation.INTERPOLATION_RATE * Time.deltaTime));
                base.rigidbody.MoveRotation(Quaternion.Lerp(base.transform.rotation, this.rotation, (float)NetworkInterpolation.INTERPOLATION_RATE * Time.deltaTime));
            }
            if (this.sirens)
            {
                if (Time.realtimeSinceStartup % 0.717f >= 0.3585f)
                {
                    base.transform.FindChild("siren").light.color = Color.blue;
                }
                else
                {
                    base.transform.FindChild("siren").light.color = Color.red;
                }
            }
            AudioSource audioSource = base.audio;
            float       single      = base.audio.volume;
            if (this.fuel <= 0)
            {
                fuel = 0;
            }
            else
            {
                fuel = 1;
            }
        }
    }