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));
        }
    }