// Token: 0x060039EC RID: 14828 RVA: 0x001BA558 File Offset: 0x001B8958
 private bool fire(bool mode, out ERefillWaterType newWaterType)
 {
     newWaterType = ERefillWaterType.EMPTY;
     if (base.channel.isOwner)
     {
         Ray         ray         = new Ray(base.player.look.aim.position, base.player.look.aim.forward);
         RaycastInfo raycastInfo = DamageTool.raycast(ray, 3f, RayMasks.DAMAGE_CLIENT);
         if (!(raycastInfo.transform != null))
         {
             return(false);
         }
         InteractableRainBarrel     component  = raycastInfo.transform.GetComponent <InteractableRainBarrel>();
         InteractableTank           component2 = raycastInfo.transform.GetComponent <InteractableTank>();
         InteractableObjectResource component3 = raycastInfo.transform.GetComponent <InteractableObjectResource>();
         WaterVolume waterVolume;
         if (WaterUtility.isPointUnderwater(raycastInfo.point, out waterVolume))
         {
             if (mode)
             {
                 return(false);
             }
             if (this.waterType != ERefillWaterType.EMPTY)
             {
                 return(false);
             }
             if (waterVolume == null)
             {
                 newWaterType = ERefillWaterType.SALTY;
             }
             else
             {
                 newWaterType = waterVolume.waterType;
             }
         }
         else if (component != null)
         {
             if (mode)
             {
                 if (this.waterType != ERefillWaterType.CLEAN)
                 {
                     return(false);
                 }
                 if (component.isFull)
                 {
                     return(false);
                 }
                 newWaterType = ERefillWaterType.EMPTY;
             }
             else
             {
                 if (this.waterType == ERefillWaterType.CLEAN)
                 {
                     return(false);
                 }
                 if (!component.isFull)
                 {
                     return(false);
                 }
                 newWaterType = ERefillWaterType.CLEAN;
             }
         }
         else if (component2 != null)
         {
             if (component2.source != ETankSource.WATER)
             {
                 return(false);
             }
             if (mode)
             {
                 if (this.waterType != ERefillWaterType.CLEAN)
                 {
                     return(false);
                 }
                 if (component2.amount == component2.capacity)
                 {
                     return(false);
                 }
                 newWaterType = ERefillWaterType.EMPTY;
             }
             else
             {
                 if (this.waterType == ERefillWaterType.CLEAN)
                 {
                     return(false);
                 }
                 if (component2.amount == 0)
                 {
                     return(false);
                 }
                 newWaterType = ERefillWaterType.CLEAN;
             }
         }
         else
         {
             if (!(component3 != null))
             {
                 return(false);
             }
             if (component3.objectAsset.interactability != EObjectInteractability.WATER)
             {
                 return(false);
             }
             if (mode)
             {
                 if (this.waterType == ERefillWaterType.EMPTY)
                 {
                     return(false);
                 }
                 if (component3.amount == component3.capacity)
                 {
                     return(false);
                 }
                 newWaterType = ERefillWaterType.EMPTY;
             }
             else
             {
                 if (this.waterType == ERefillWaterType.CLEAN || this.waterType == ERefillWaterType.DIRTY)
                 {
                     return(false);
                 }
                 if (component3.amount == 0)
                 {
                     return(false);
                 }
                 newWaterType = ERefillWaterType.DIRTY;
             }
         }
         base.player.input.sendRaycast(raycastInfo);
     }
     if (Provider.isServer)
     {
         if (!base.player.input.hasInputs())
         {
             return(false);
         }
         InputInfo input = base.player.input.getInput(true);
         if (input == null)
         {
             return(false);
         }
         if ((input.point - base.player.look.aim.position).sqrMagnitude > 49f)
         {
             return(false);
         }
         WaterVolume waterVolume2;
         if (WaterUtility.isPointUnderwater(input.point, out waterVolume2))
         {
             if (mode)
             {
                 return(false);
             }
             if (this.waterType != ERefillWaterType.EMPTY)
             {
                 return(false);
             }
             if (waterVolume2 == null)
             {
                 newWaterType = ERefillWaterType.SALTY;
             }
             else
             {
                 newWaterType = waterVolume2.waterType;
             }
         }
         else if (input.type == ERaycastInfoType.BARRICADE)
         {
             if (input.transform == null || !input.transform.CompareTag("Barricade"))
             {
                 return(false);
             }
             InteractableRainBarrel component4 = input.transform.GetComponent <InteractableRainBarrel>();
             InteractableTank       component5 = input.transform.GetComponent <InteractableTank>();
             if (component4 != null)
             {
                 if (mode)
                 {
                     if (this.waterType != ERefillWaterType.CLEAN)
                     {
                         return(false);
                     }
                     if (component4.isFull)
                     {
                         return(false);
                     }
                     BarricadeManager.updateRainBarrel(component4.transform, true, true);
                     newWaterType = ERefillWaterType.EMPTY;
                 }
                 else
                 {
                     if (this.waterType == ERefillWaterType.CLEAN)
                     {
                         return(false);
                     }
                     if (!component4.isFull)
                     {
                         return(false);
                     }
                     BarricadeManager.updateRainBarrel(component4.transform, false, true);
                     newWaterType = ERefillWaterType.CLEAN;
                 }
             }
             else
             {
                 if (!(component5 != null))
                 {
                     return(false);
                 }
                 if (component5.source != ETankSource.WATER)
                 {
                     return(false);
                 }
                 if (mode)
                 {
                     if (this.waterType != ERefillWaterType.CLEAN)
                     {
                         return(false);
                     }
                     if (component5.amount == component5.capacity)
                     {
                         return(false);
                     }
                     BarricadeManager.updateTank(input.transform, (ushort)((byte)(component5.amount + 1)));
                     newWaterType = ERefillWaterType.EMPTY;
                 }
                 else
                 {
                     if (this.waterType == ERefillWaterType.CLEAN)
                     {
                         return(false);
                     }
                     if (component5.amount == 0)
                     {
                         return(false);
                     }
                     BarricadeManager.updateTank(input.transform, (ushort)((byte)(component5.amount - 1)));
                     newWaterType = ERefillWaterType.CLEAN;
                 }
             }
         }
         else if (input.type == ERaycastInfoType.OBJECT)
         {
             if (input.transform == null)
             {
                 return(false);
             }
             InteractableObjectResource component6 = input.transform.GetComponent <InteractableObjectResource>();
             if (component6 == null || component6.objectAsset.interactability != EObjectInteractability.WATER)
             {
                 return(false);
             }
             if (mode)
             {
                 if (this.waterType == ERefillWaterType.EMPTY)
                 {
                     return(false);
                 }
                 if (component6.amount == component6.capacity)
                 {
                     return(false);
                 }
                 ObjectManager.updateObjectResource(component6.transform, (ushort)((byte)(component6.amount + 1)), true);
                 newWaterType = ERefillWaterType.EMPTY;
             }
             else
             {
                 if (this.waterType == ERefillWaterType.CLEAN || this.waterType == ERefillWaterType.DIRTY)
                 {
                     return(false);
                 }
                 if (component6.amount == 0)
                 {
                     return(false);
                 }
                 ObjectManager.updateObjectResource(component6.transform, (ushort)((byte)(component6.amount - 1)), true);
                 newWaterType = ERefillWaterType.DIRTY;
             }
         }
     }
     return(true);
 }
Example #2
0
 public void sendRaycast(RaycastInfo info)
 {
     if (this.isRaycastInvalid(info))
     {
         return;
     }
     if (Provider.isServer)
     {
         InputInfo inputInfo = new InputInfo();
         inputInfo.animal    = info.animal;
         inputInfo.direction = info.direction;
         inputInfo.limb      = info.limb;
         inputInfo.material  = info.material;
         inputInfo.normal    = info.normal;
         inputInfo.player    = info.player;
         inputInfo.point     = info.point;
         inputInfo.transform = info.transform;
         inputInfo.vehicle   = info.vehicle;
         inputInfo.zombie    = info.zombie;
         inputInfo.section   = info.section;
         if (inputInfo.player != null)
         {
             inputInfo.type = ERaycastInfoType.PLAYER;
         }
         else if (inputInfo.zombie != null)
         {
             inputInfo.type = ERaycastInfoType.ZOMBIE;
         }
         else if (inputInfo.animal != null)
         {
             inputInfo.type = ERaycastInfoType.ANIMAL;
         }
         else if (inputInfo.vehicle != null)
         {
             inputInfo.type = ERaycastInfoType.VEHICLE;
         }
         else if (inputInfo.transform != null)
         {
             if (inputInfo.transform.CompareTag("Barricade"))
             {
                 inputInfo.type = ERaycastInfoType.BARRICADE;
             }
             else if (info.transform.CompareTag("Structure"))
             {
                 inputInfo.type = ERaycastInfoType.STRUCTURE;
             }
             else if (info.transform.CompareTag("Resource"))
             {
                 inputInfo.type = ERaycastInfoType.RESOURCE;
             }
             else if (inputInfo.transform.CompareTag("Small") || inputInfo.transform.CompareTag("Medium") || inputInfo.transform.CompareTag("Large"))
             {
                 inputInfo.type = ERaycastInfoType.OBJECT;
             }
             else if (info.transform.CompareTag("Ground") || info.transform.CompareTag("Environment"))
             {
                 inputInfo.type = ERaycastInfoType.NONE;
             }
             else
             {
                 inputInfo = null;
             }
         }
         else
         {
             inputInfo = null;
         }
         if (inputInfo != null)
         {
             this.inputs.Enqueue(inputInfo);
         }
     }
     else
     {
         PlayerInputPacket playerInputPacket = this.clientsidePackets[this.clientsidePackets.Count - 1];
         if (playerInputPacket.clientsideInputs == null)
         {
             playerInputPacket.clientsideInputs = new List <RaycastInfo>();
         }
         playerInputPacket.clientsideInputs.Add(info);
     }
 }
Example #3
0
        public virtual void read(SteamChannel channel)
        {
            this.sequence = (int)channel.read(Types.INT32_TYPE);
            this.recov    = (int)channel.read(Types.INT32_TYPE);
            this.keys     = (ushort)channel.read(Types.UINT16_TYPE);
            byte b = (byte)channel.read(Types.BYTE_TYPE);

            if (b > 0)
            {
                this.serversideInputs = new Queue <InputInfo>((int)b);
                for (byte b2 = 0; b2 < b; b2 += 1)
                {
                    InputInfo inputInfo = new InputInfo();
                    inputInfo.type = (ERaycastInfoType)((byte)channel.read(Types.BYTE_TYPE));
                    switch (inputInfo.type)
                    {
                    case ERaycastInfoType.NONE:
                        inputInfo.point    = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.normal   = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.material = (EPhysicsMaterial)((byte)channel.read(Types.BYTE_TYPE));
                        break;

                    case ERaycastInfoType.SKIP:
                        inputInfo = null;
                        break;

                    case ERaycastInfoType.OBJECT:
                    {
                        inputInfo.point     = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.direction = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.normal    = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.material  = (EPhysicsMaterial)((byte)channel.read(Types.BYTE_TYPE));
                        inputInfo.section   = (byte)channel.read(Types.BYTE_TYPE);
                        byte        x       = (byte)channel.read(Types.BYTE_TYPE);
                        byte        y       = (byte)channel.read(Types.BYTE_TYPE);
                        ushort      index   = (ushort)channel.read(Types.UINT16_TYPE);
                        LevelObject @object = ObjectManager.getObject(x, y, index);
                        if (@object != null && @object.transform != null && (inputInfo.point - @object.transform.position).sqrMagnitude < 256f)
                        {
                            inputInfo.transform = @object.transform;
                        }
                        else
                        {
                            inputInfo.type = ERaycastInfoType.NONE;
                        }
                        break;
                    }

                    case ERaycastInfoType.PLAYER:
                    {
                        inputInfo.point     = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.direction = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.normal    = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.limb      = (ELimb)((byte)channel.read(Types.BYTE_TYPE));
                        CSteamID steamID = (CSteamID)channel.read(Types.STEAM_ID_TYPE);
                        Player   player  = PlayerTool.getPlayer(steamID);
                        if (player != null && (inputInfo.point - player.transform.position).sqrMagnitude < 256f)
                        {
                            inputInfo.material  = EPhysicsMaterial.FLESH_DYNAMIC;
                            inputInfo.player    = player;
                            inputInfo.transform = player.transform;
                        }
                        else
                        {
                            inputInfo = null;
                        }
                        break;
                    }

                    case ERaycastInfoType.ZOMBIE:
                    {
                        inputInfo.point     = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.direction = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.normal    = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.limb      = (ELimb)((byte)channel.read(Types.BYTE_TYPE));
                        ushort id     = (ushort)channel.read(Types.UINT16_TYPE);
                        Zombie zombie = ZombieManager.getZombie(inputInfo.point, id);
                        if (zombie != null && (inputInfo.point - zombie.transform.position).sqrMagnitude < 256f)
                        {
                            if (zombie.isRadioactive)
                            {
                                inputInfo.material = EPhysicsMaterial.ALIEN_DYNAMIC;
                            }
                            else
                            {
                                inputInfo.material = EPhysicsMaterial.FLESH_DYNAMIC;
                            }
                            inputInfo.zombie    = zombie;
                            inputInfo.transform = zombie.transform;
                        }
                        else
                        {
                            inputInfo = null;
                        }
                        break;
                    }

                    case ERaycastInfoType.ANIMAL:
                    {
                        inputInfo.point     = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.direction = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.normal    = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.limb      = (ELimb)((byte)channel.read(Types.BYTE_TYPE));
                        ushort index2 = (ushort)channel.read(Types.UINT16_TYPE);
                        Animal animal = AnimalManager.getAnimal(index2);
                        if (animal != null && (inputInfo.point - animal.transform.position).sqrMagnitude < 256f)
                        {
                            inputInfo.material  = EPhysicsMaterial.FLESH_DYNAMIC;
                            inputInfo.animal    = animal;
                            inputInfo.transform = animal.transform;
                        }
                        else
                        {
                            inputInfo = null;
                        }
                        break;
                    }

                    case ERaycastInfoType.VEHICLE:
                    {
                        inputInfo.point    = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.normal   = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.material = (EPhysicsMaterial)((byte)channel.read(Types.BYTE_TYPE));
                        uint instanceID             = (uint)channel.read(Types.UINT32_TYPE);
                        InteractableVehicle vehicle = VehicleManager.getVehicle(instanceID);
                        if (vehicle != null && (vehicle == channel.owner.player.movement.getVehicle() || (inputInfo.point - vehicle.transform.position).sqrMagnitude < 4096f))
                        {
                            inputInfo.vehicle   = vehicle;
                            inputInfo.transform = vehicle.transform;
                        }
                        else
                        {
                            inputInfo = null;
                        }
                        break;
                    }

                    case ERaycastInfoType.BARRICADE:
                    {
                        inputInfo.point    = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.normal   = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.material = (EPhysicsMaterial)((byte)channel.read(Types.BYTE_TYPE));
                        byte            x2    = (byte)channel.read(Types.BYTE_TYPE);
                        byte            y2    = (byte)channel.read(Types.BYTE_TYPE);
                        ushort          plant = (ushort)channel.read(Types.UINT16_TYPE);
                        ushort          num   = (ushort)channel.read(Types.UINT16_TYPE);
                        BarricadeRegion barricadeRegion;
                        if (BarricadeManager.tryGetRegion(x2, y2, plant, out barricadeRegion) && (int)num < barricadeRegion.drops.Count)
                        {
                            Transform model = barricadeRegion.drops[(int)num].model;
                            if (model != null && (inputInfo.point - model.transform.position).sqrMagnitude < 256f)
                            {
                                inputInfo.transform = model;
                            }
                            else
                            {
                                inputInfo = null;
                            }
                        }
                        else
                        {
                            inputInfo = null;
                        }
                        break;
                    }

                    case ERaycastInfoType.STRUCTURE:
                    {
                        inputInfo.point     = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.direction = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.normal    = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.material  = (EPhysicsMaterial)((byte)channel.read(Types.BYTE_TYPE));
                        byte            x3   = (byte)channel.read(Types.BYTE_TYPE);
                        byte            y3   = (byte)channel.read(Types.BYTE_TYPE);
                        ushort          num2 = (ushort)channel.read(Types.UINT16_TYPE);
                        StructureRegion structureRegion;
                        if (StructureManager.tryGetRegion(x3, y3, out structureRegion) && (int)num2 < structureRegion.drops.Count)
                        {
                            Transform model2 = structureRegion.drops[(int)num2].model;
                            if (model2 != null && (inputInfo.point - model2.transform.position).sqrMagnitude < 256f)
                            {
                                inputInfo.transform = model2;
                            }
                            else
                            {
                                inputInfo = null;
                            }
                        }
                        else
                        {
                            inputInfo = null;
                        }
                        break;
                    }

                    case ERaycastInfoType.RESOURCE:
                    {
                        inputInfo.point     = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.direction = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.normal    = (Vector3)channel.read(Types.VECTOR3_TYPE);
                        inputInfo.material  = (EPhysicsMaterial)((byte)channel.read(Types.BYTE_TYPE));
                        byte      x4       = (byte)channel.read(Types.BYTE_TYPE);
                        byte      y4       = (byte)channel.read(Types.BYTE_TYPE);
                        ushort    index3   = (ushort)channel.read(Types.UINT16_TYPE);
                        Transform resource = ResourceManager.getResource(x4, y4, index3);
                        if (resource != null && (inputInfo.point - resource.transform.position).sqrMagnitude < 256f)
                        {
                            inputInfo.transform = resource;
                        }
                        else
                        {
                            inputInfo = null;
                        }
                        break;
                    }
                    }
                    if (inputInfo != null)
                    {
                        this.serversideInputs.Enqueue(inputInfo);
                    }
                }
            }
        }
Example #4
0
 private bool fire(bool mode)
 {
     if (base.channel.isOwner)
     {
         Ray ray;
         ray..ctor(base.player.look.aim.position, base.player.look.aim.forward);
         RaycastInfo raycastInfo = DamageTool.raycast(ray, 3f, RayMasks.DAMAGE_CLIENT);
         if (raycastInfo.vehicle != null)
         {
             if (mode)
             {
                 if (this.fuel == 0)
                 {
                     return(false);
                 }
                 if (!raycastInfo.vehicle.isRefillable)
                 {
                     return(false);
                 }
             }
             else
             {
                 if (this.fuel == ((ItemFuelAsset)base.player.equipment.asset).fuel)
                 {
                     return(false);
                 }
                 if (!raycastInfo.vehicle.isSiphonable)
                 {
                     return(false);
                 }
             }
         }
         else
         {
             if (!(raycastInfo.transform != null))
             {
                 return(false);
             }
             InteractableGenerator      component  = raycastInfo.transform.GetComponent <InteractableGenerator>();
             InteractableOil            component2 = raycastInfo.transform.GetComponent <InteractableOil>();
             InteractableTank           component3 = raycastInfo.transform.GetComponent <InteractableTank>();
             InteractableObjectResource component4 = raycastInfo.transform.GetComponent <InteractableObjectResource>();
             if (component != null)
             {
                 if (mode)
                 {
                     if (this.fuel == 0)
                     {
                         return(false);
                     }
                     if (!component.isRefillable)
                     {
                         return(false);
                     }
                 }
                 else
                 {
                     if (this.fuel == ((ItemFuelAsset)base.player.equipment.asset).fuel)
                     {
                         return(false);
                     }
                     if (!component.isSiphonable)
                     {
                         return(false);
                     }
                 }
             }
             else if (!(component2 != null))
             {
                 if (component3 != null)
                 {
                     if (component3.source != ETankSource.FUEL)
                     {
                         return(false);
                     }
                     if (mode)
                     {
                         if (this.fuel == 0)
                         {
                             return(false);
                         }
                         if (!component3.isRefillable)
                         {
                             return(false);
                         }
                     }
                     else
                     {
                         if (this.fuel == ((ItemFuelAsset)base.player.equipment.asset).fuel)
                         {
                             return(false);
                         }
                         if (!component3.isSiphonable)
                         {
                             return(false);
                         }
                     }
                 }
                 else
                 {
                     if (!(component4 != null))
                     {
                         return(false);
                     }
                     if (component4.objectAsset.interactability != EObjectInteractability.FUEL)
                     {
                         return(false);
                     }
                     if (mode)
                     {
                         if (this.fuel == 0)
                         {
                             return(false);
                         }
                         if (component4.amount == component4.capacity)
                         {
                             return(false);
                         }
                     }
                     else
                     {
                         if (this.fuel == ((ItemFuelAsset)base.player.equipment.asset).fuel)
                         {
                             return(false);
                         }
                         if (component4.amount == 0)
                         {
                             return(false);
                         }
                     }
                 }
             }
         }
         base.player.input.sendRaycast(raycastInfo);
     }
     if (Provider.isServer)
     {
         if (!base.player.input.hasInputs())
         {
             return(false);
         }
         InputInfo input = base.player.input.getInput(true);
         if (input == null)
         {
             return(false);
         }
         if ((input.point - base.player.look.aim.position).sqrMagnitude > 49f)
         {
             return(false);
         }
         if (input.type == ERaycastInfoType.VEHICLE)
         {
             if (input.vehicle == null)
             {
                 return(false);
             }
             if (mode)
             {
                 if (this.fuel == 0)
                 {
                     return(false);
                 }
                 if (!input.vehicle.isRefillable)
                 {
                     return(false);
                 }
                 ushort num = (ushort)Mathf.Min((int)this.fuel, (int)(input.vehicle.asset.fuel - input.vehicle.fuel));
                 input.vehicle.askFillFuel(num);
                 this.fuel -= num;
             }
             else
             {
                 if (this.fuel == ((ItemFuelAsset)base.player.equipment.asset).fuel)
                 {
                     return(false);
                 }
                 if (!input.vehicle.isSiphonable)
                 {
                     return(false);
                 }
                 ushort num2 = (ushort)Mathf.Min((int)input.vehicle.fuel, (int)(((ItemFuelAsset)base.player.equipment.asset).fuel - this.fuel));
                 input.vehicle.askBurnFuel(num2);
                 VehicleManager.sendVehicleFuel(input.vehicle, input.vehicle.fuel);
                 this.fuel += num2;
             }
         }
         else if (input.type == ERaycastInfoType.BARRICADE)
         {
             if (input.transform == null || !input.transform.CompareTag("Barricade"))
             {
                 return(false);
             }
             InteractableGenerator component5 = input.transform.GetComponent <InteractableGenerator>();
             InteractableOil       component6 = input.transform.GetComponent <InteractableOil>();
             InteractableTank      component7 = input.transform.GetComponent <InteractableTank>();
             if (component5 != null)
             {
                 if (mode)
                 {
                     if (this.fuel == 0)
                     {
                         return(false);
                     }
                     if (!component5.isRefillable)
                     {
                         return(false);
                     }
                     ushort num3 = (ushort)Mathf.Min((int)this.fuel, (int)(component5.capacity - component5.fuel));
                     component5.askFill(num3);
                     BarricadeManager.sendFuel(input.transform, component5.fuel);
                     this.fuel -= num3;
                 }
                 else
                 {
                     if (this.fuel == ((ItemFuelAsset)base.player.equipment.asset).fuel)
                     {
                         return(false);
                     }
                     if (!component5.isSiphonable)
                     {
                         return(false);
                     }
                     ushort num4 = (ushort)Mathf.Min((int)component5.fuel, (int)(((ItemFuelAsset)base.player.equipment.asset).fuel - this.fuel));
                     component5.askBurn(num4);
                     BarricadeManager.sendFuel(input.transform, component5.fuel);
                     this.fuel += num4;
                 }
             }
             else if (component6 != null)
             {
                 if (mode)
                 {
                     if (this.fuel == 0)
                     {
                         return(false);
                     }
                     if (!component6.isRefillable)
                     {
                         return(false);
                     }
                     ushort num5 = (ushort)Mathf.Min((int)this.fuel, (int)(component6.capacity - component6.fuel));
                     component6.askFill(num5);
                     BarricadeManager.sendOil(input.transform, component6.fuel);
                     this.fuel -= num5;
                 }
                 else
                 {
                     if (this.fuel == ((ItemFuelAsset)base.player.equipment.asset).fuel)
                     {
                         return(false);
                     }
                     if (!component6.isSiphonable)
                     {
                         return(false);
                     }
                     ushort num6 = (ushort)Mathf.Min((int)component6.fuel, (int)(((ItemFuelAsset)base.player.equipment.asset).fuel - this.fuel));
                     component6.askBurn(num6);
                     BarricadeManager.sendOil(input.transform, component6.fuel);
                     this.fuel += num6;
                 }
             }
             else
             {
                 if (!(component7 != null))
                 {
                     return(false);
                 }
                 if (component7.source != ETankSource.FUEL)
                 {
                     return(false);
                 }
                 if (mode)
                 {
                     if (this.fuel == 0)
                     {
                         return(false);
                     }
                     if (!component7.isRefillable)
                     {
                         return(false);
                     }
                     ushort num7 = (ushort)Mathf.Min((int)this.fuel, (int)(component7.capacity - component7.amount));
                     BarricadeManager.updateTank(input.transform, component7.amount + num7);
                     this.fuel -= num7;
                 }
                 else
                 {
                     if (this.fuel == ((ItemFuelAsset)base.player.equipment.asset).fuel)
                     {
                         return(false);
                     }
                     if (!component7.isSiphonable)
                     {
                         return(false);
                     }
                     ushort num8 = (ushort)Mathf.Min((int)component7.amount, (int)(((ItemFuelAsset)base.player.equipment.asset).fuel - this.fuel));
                     BarricadeManager.updateTank(input.transform, component7.amount - num8);
                     this.fuel += num8;
                 }
             }
         }
         else if (input.type == ERaycastInfoType.OBJECT)
         {
             if (input.transform == null)
             {
                 return(false);
             }
             InteractableObjectResource component8 = input.transform.GetComponent <InteractableObjectResource>();
             if (component8 == null || component8.objectAsset.interactability != EObjectInteractability.FUEL)
             {
                 return(false);
             }
             if (mode)
             {
                 if (this.fuel == 0)
                 {
                     return(false);
                 }
                 if (!component8.isRefillable)
                 {
                     return(false);
                 }
                 ushort num9 = (ushort)Mathf.Min((int)this.fuel, (int)(component8.capacity - component8.amount));
                 ObjectManager.updateObjectResource(component8.transform, component8.amount + num9, true);
                 this.fuel -= num9;
             }
             else
             {
                 if (this.fuel == ((ItemFuelAsset)base.player.equipment.asset).fuel)
                 {
                     return(false);
                 }
                 if (!component8.isSiphonable)
                 {
                     return(false);
                 }
                 ushort num10 = (ushort)Mathf.Min((int)component8.amount, (int)(((ItemFuelAsset)base.player.equipment.asset).fuel - this.fuel));
                 ObjectManager.updateObjectResource(component8.transform, component8.amount - num10, true);
                 this.fuel += num10;
             }
         }
     }
     return(true);
 }
Example #5
0
        private void fire()
        {
            float num = (float)base.player.equipment.quality / 100f;

            if (Provider.isServer)
            {
                AlertTool.alert(base.transform.position, ((ItemMeleeAsset)base.player.equipment.asset).alertRadius);
                if (Provider.modeConfigData.Items.Has_Durability && base.player.equipment.quality > 0 && Random.value < ((ItemWeaponAsset)base.player.equipment.asset).durability)
                {
                    if (base.player.equipment.quality > ((ItemWeaponAsset)base.player.equipment.asset).wear)
                    {
                        PlayerEquipment equipment = base.player.equipment;
                        equipment.quality -= ((ItemWeaponAsset)base.player.equipment.asset).wear;
                    }
                    else
                    {
                        base.player.equipment.quality = 0;
                    }
                    base.player.equipment.sendUpdateQuality();
                }
            }
            if (base.channel.isOwner)
            {
                int num2;
                if (Provider.provider.statisticsService.userStatisticsService.getStatistic("Accuracy_Shot", out num2))
                {
                    Provider.provider.statisticsService.userStatisticsService.setStatistic("Accuracy_Shot", num2 + 1);
                }
                Ray ray;
                ray..ctor(base.player.look.aim.position, base.player.look.aim.forward);
                RaycastInfo raycastInfo = DamageTool.raycast(ray, ((ItemWeaponAsset)base.player.equipment.asset).range, RayMasks.DAMAGE_CLIENT);
                if (raycastInfo.player != null && ((ItemMeleeAsset)base.player.equipment.asset).playerDamageMultiplier.damage > 1f && !base.player.quests.isMemberOfSameGroupAs(raycastInfo.player) && Provider.isPvP)
                {
                    if (Provider.provider.statisticsService.userStatisticsService.getStatistic("Accuracy_Hit", out num2))
                    {
                        Provider.provider.statisticsService.userStatisticsService.setStatistic("Accuracy_Hit", num2 + 1);
                    }
                    if (raycastInfo.limb == ELimb.SKULL && Provider.provider.statisticsService.userStatisticsService.getStatistic("Headshots", out num2))
                    {
                        Provider.provider.statisticsService.userStatisticsService.setStatistic("Headshots", num2 + 1);
                    }
                    PlayerUI.hitmark(0, raycastInfo.point, false, (raycastInfo.limb != ELimb.SKULL) ? EPlayerHit.ENTITIY : EPlayerHit.CRITICAL);
                }
                else if ((raycastInfo.zombie != null && ((ItemMeleeAsset)base.player.equipment.asset).zombieDamageMultiplier.damage > 1f) || (raycastInfo.animal != null && ((ItemMeleeAsset)base.player.equipment.asset).animalDamageMultiplier.damage > 1f))
                {
                    if (Provider.provider.statisticsService.userStatisticsService.getStatistic("Accuracy_Hit", out num2))
                    {
                        Provider.provider.statisticsService.userStatisticsService.setStatistic("Accuracy_Hit", num2 + 1);
                    }
                    if (raycastInfo.limb == ELimb.SKULL && Provider.provider.statisticsService.userStatisticsService.getStatistic("Headshots", out num2))
                    {
                        Provider.provider.statisticsService.userStatisticsService.setStatistic("Headshots", num2 + 1);
                    }
                    PlayerUI.hitmark(0, raycastInfo.point, false, (raycastInfo.limb != ELimb.SKULL) ? EPlayerHit.ENTITIY : EPlayerHit.CRITICAL);
                }
                else if (raycastInfo.vehicle != null && ((ItemMeleeAsset)base.player.equipment.asset).vehicleDamage > 1f)
                {
                    if (((ItemMeleeAsset)base.player.equipment.asset).isRepair)
                    {
                        if (!raycastInfo.vehicle.isExploded && !raycastInfo.vehicle.isRepaired)
                        {
                            if (Provider.provider.statisticsService.userStatisticsService.getStatistic("Accuracy_Hit", out num2))
                            {
                                Provider.provider.statisticsService.userStatisticsService.setStatistic("Accuracy_Hit", num2 + 1);
                            }
                            PlayerUI.hitmark(0, raycastInfo.point, false, EPlayerHit.BUILD);
                        }
                    }
                    else if (!raycastInfo.vehicle.isDead && raycastInfo.vehicle.asset != null && (raycastInfo.vehicle.asset.isVulnerable || ((ItemWeaponAsset)base.player.equipment.asset).isInvulnerable))
                    {
                        if (Provider.provider.statisticsService.userStatisticsService.getStatistic("Accuracy_Hit", out num2))
                        {
                            Provider.provider.statisticsService.userStatisticsService.setStatistic("Accuracy_Hit", num2 + 1);
                        }
                        PlayerUI.hitmark(0, raycastInfo.point, false, EPlayerHit.BUILD);
                    }
                }
                else if (raycastInfo.transform != null && raycastInfo.transform.CompareTag("Barricade") && ((ItemMeleeAsset)base.player.equipment.asset).barricadeDamage > 1f)
                {
                    InteractableDoorHinge component = raycastInfo.transform.GetComponent <InteractableDoorHinge>();
                    if (component != null)
                    {
                        raycastInfo.transform = component.transform.parent.parent;
                    }
                    ushort id;
                    if (ushort.TryParse(raycastInfo.transform.name, out id))
                    {
                        ItemBarricadeAsset itemBarricadeAsset = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, id);
                        if (itemBarricadeAsset != null)
                        {
                            if (((ItemMeleeAsset)base.player.equipment.asset).isRepair)
                            {
                                Interactable2HP component2 = raycastInfo.transform.GetComponent <Interactable2HP>();
                                if (component2 != null && itemBarricadeAsset.isRepairable && component2.hp < 100)
                                {
                                    if (Provider.provider.statisticsService.userStatisticsService.getStatistic("Accuracy_Hit", out num2))
                                    {
                                        Provider.provider.statisticsService.userStatisticsService.setStatistic("Accuracy_Hit", num2 + 1);
                                    }
                                    PlayerUI.hitmark(0, raycastInfo.point, false, EPlayerHit.BUILD);
                                }
                            }
                            else if (itemBarricadeAsset.isVulnerable || ((ItemWeaponAsset)base.player.equipment.asset).isInvulnerable)
                            {
                                if (Provider.provider.statisticsService.userStatisticsService.getStatistic("Accuracy_Hit", out num2))
                                {
                                    Provider.provider.statisticsService.userStatisticsService.setStatistic("Accuracy_Hit", num2 + 1);
                                }
                                PlayerUI.hitmark(0, raycastInfo.point, false, EPlayerHit.BUILD);
                            }
                        }
                    }
                }
                else if (raycastInfo.transform != null && raycastInfo.transform.CompareTag("Structure") && ((ItemMeleeAsset)base.player.equipment.asset).structureDamage > 1f)
                {
                    ushort id2;
                    if (ushort.TryParse(raycastInfo.transform.name, out id2))
                    {
                        ItemStructureAsset itemStructureAsset = (ItemStructureAsset)Assets.find(EAssetType.ITEM, id2);
                        if (itemStructureAsset != null)
                        {
                            if (((ItemMeleeAsset)base.player.equipment.asset).isRepair)
                            {
                                Interactable2HP component3 = raycastInfo.transform.GetComponent <Interactable2HP>();
                                if (component3 != null && itemStructureAsset.isRepairable && component3.hp < 100)
                                {
                                    if (Provider.provider.statisticsService.userStatisticsService.getStatistic("Accuracy_Hit", out num2))
                                    {
                                        Provider.provider.statisticsService.userStatisticsService.setStatistic("Accuracy_Hit", num2 + 1);
                                    }
                                    PlayerUI.hitmark(0, raycastInfo.point, false, EPlayerHit.BUILD);
                                }
                            }
                            else if (itemStructureAsset.isVulnerable || ((ItemWeaponAsset)base.player.equipment.asset).isInvulnerable)
                            {
                                if (Provider.provider.statisticsService.userStatisticsService.getStatistic("Accuracy_Hit", out num2))
                                {
                                    Provider.provider.statisticsService.userStatisticsService.setStatistic("Accuracy_Hit", num2 + 1);
                                }
                                PlayerUI.hitmark(0, raycastInfo.point, false, EPlayerHit.BUILD);
                            }
                        }
                    }
                }
                else if (raycastInfo.transform != null && raycastInfo.transform.CompareTag("Resource") && ((ItemMeleeAsset)base.player.equipment.asset).resourceDamage > 1f)
                {
                    byte   x;
                    byte   y;
                    ushort index;
                    if (ResourceManager.tryGetRegion(raycastInfo.transform, out x, out y, out index))
                    {
                        ResourceSpawnpoint resourceSpawnpoint = ResourceManager.getResourceSpawnpoint(x, y, index);
                        if (resourceSpawnpoint != null && !resourceSpawnpoint.isDead && resourceSpawnpoint.asset.bladeID == ((ItemWeaponAsset)base.player.equipment.asset).bladeID)
                        {
                            if (Provider.provider.statisticsService.userStatisticsService.getStatistic("Accuracy_Hit", out num2))
                            {
                                Provider.provider.statisticsService.userStatisticsService.setStatistic("Accuracy_Hit", num2 + 1);
                            }
                            PlayerUI.hitmark(0, raycastInfo.point, false, EPlayerHit.BUILD);
                        }
                    }
                }
                else if (raycastInfo.transform != null && ((ItemMeleeAsset)base.player.equipment.asset).objectDamage > 1f)
                {
                    InteractableObjectRubble component4 = raycastInfo.transform.GetComponent <InteractableObjectRubble>();
                    if (component4 != null)
                    {
                        raycastInfo.section = component4.getSection(raycastInfo.collider.transform);
                        if (!component4.isSectionDead(raycastInfo.section) && (component4.asset.rubbleIsVulnerable || ((ItemWeaponAsset)base.player.equipment.asset).isInvulnerable))
                        {
                            if (Provider.provider.statisticsService.userStatisticsService.getStatistic("Accuracy_Hit", out num2))
                            {
                                Provider.provider.statisticsService.userStatisticsService.setStatistic("Accuracy_Hit", num2 + 1);
                            }
                            PlayerUI.hitmark(0, raycastInfo.point, false, EPlayerHit.BUILD);
                        }
                    }
                }
                base.player.input.sendRaycast(raycastInfo);
            }
            if (Provider.isServer)
            {
                if (!base.player.input.hasInputs())
                {
                    return;
                }
                InputInfo input = base.player.input.getInput(true);
                if (input == null)
                {
                    return;
                }
                if ((input.point - base.player.look.aim.position).sqrMagnitude > Mathf.Pow(((ItemMeleeAsset)base.player.equipment.asset).range + 4f, 2f))
                {
                    return;
                }
                if (!((ItemMeleeAsset)base.player.equipment.asset).isRepair)
                {
                    DamageTool.impact(input.point, input.normal, input.material, input.type != ERaycastInfoType.NONE && input.type != ERaycastInfoType.OBJECT);
                }
                EPlayerKill eplayerKill = EPlayerKill.NONE;
                uint        num3        = 0u;
                float       num4        = 1f;
                num4 *= 1f + base.channel.owner.player.skills.mastery(0, 0) * 0.5f;
                num4 *= ((this.swingMode != ESwingMode.STRONG) ? 1f : ((ItemMeleeAsset)base.player.equipment.asset).strength);
                num4 *= ((num >= 0.5f) ? 1f : (0.5f + num));
                if (input.type == ERaycastInfoType.PLAYER)
                {
                    if (input.player != null && !base.player.quests.isMemberOfSameGroupAs(input.player) && Provider.isPvP)
                    {
                        DamageTool.damage(input.player, EDeathCause.MELEE, input.limb, base.channel.owner.playerID.steamID, input.direction, ((ItemMeleeAsset)base.player.equipment.asset).playerDamageMultiplier, num4, true, out eplayerKill);
                    }
                }
                else if (input.type == ERaycastInfoType.ZOMBIE)
                {
                    if (input.zombie != null)
                    {
                        DamageTool.damage(input.zombie, input.limb, input.direction, ((ItemMeleeAsset)base.player.equipment.asset).zombieDamageMultiplier, num4, true, out eplayerKill, out num3);
                        if (base.player.movement.nav != 255)
                        {
                            input.zombie.alert(base.transform.position, true);
                        }
                    }
                }
                else if (input.type == ERaycastInfoType.ANIMAL)
                {
                    if (input.animal != null)
                    {
                        DamageTool.damage(input.animal, input.limb, input.direction, ((ItemMeleeAsset)base.player.equipment.asset).animalDamageMultiplier, num4, out eplayerKill, out num3);
                        input.animal.alertPoint(base.transform.position, true);
                    }
                }
                else if (input.type == ERaycastInfoType.VEHICLE)
                {
                    if (input.vehicle != null && input.vehicle.asset != null && (input.vehicle.asset.isVulnerable || ((ItemWeaponAsset)base.player.equipment.asset).isInvulnerable || ((ItemMeleeAsset)base.player.equipment.asset).isRepair))
                    {
                        if (((ItemMeleeAsset)base.player.equipment.asset).isRepair)
                        {
                            num4 *= 1f + base.channel.owner.player.skills.mastery(2, 6);
                        }
                        DamageTool.damage(input.vehicle, true, input.point, ((ItemMeleeAsset)base.player.equipment.asset).isRepair, ((ItemMeleeAsset)base.player.equipment.asset).vehicleDamage, num4, true, out eplayerKill);
                    }
                }
                else if (input.type == ERaycastInfoType.BARRICADE)
                {
                    ushort id3;
                    if (input.transform != null && input.transform.CompareTag("Barricade") && ushort.TryParse(input.transform.name, out id3))
                    {
                        ItemBarricadeAsset itemBarricadeAsset2 = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, id3);
                        if (itemBarricadeAsset2 != null)
                        {
                            if (((ItemMeleeAsset)base.player.equipment.asset).isRepair)
                            {
                                if (itemBarricadeAsset2.isRepairable)
                                {
                                    num4 *= 1f + base.channel.owner.player.skills.mastery(2, 6);
                                    DamageTool.damage(input.transform, true, ((ItemMeleeAsset)base.player.equipment.asset).barricadeDamage, num4, out eplayerKill);
                                }
                            }
                            else if (itemBarricadeAsset2.isVulnerable || ((ItemWeaponAsset)base.player.equipment.asset).isInvulnerable)
                            {
                                DamageTool.damage(input.transform, false, ((ItemMeleeAsset)base.player.equipment.asset).barricadeDamage, num4, out eplayerKill);
                            }
                        }
                    }
                }
                else if (input.type == ERaycastInfoType.STRUCTURE)
                {
                    ushort id4;
                    if (input.transform != null && input.transform.CompareTag("Structure") && ushort.TryParse(input.transform.name, out id4))
                    {
                        ItemStructureAsset itemStructureAsset2 = (ItemStructureAsset)Assets.find(EAssetType.ITEM, id4);
                        if (itemStructureAsset2 != null)
                        {
                            if (((ItemMeleeAsset)base.player.equipment.asset).isRepair)
                            {
                                if (itemStructureAsset2.isRepairable)
                                {
                                    num4 *= 1f + base.channel.owner.player.skills.mastery(2, 6);
                                    DamageTool.damage(input.transform, true, input.direction, ((ItemMeleeAsset)base.player.equipment.asset).structureDamage, num4, out eplayerKill);
                                }
                            }
                            else if (itemStructureAsset2.isVulnerable || ((ItemWeaponAsset)base.player.equipment.asset).isInvulnerable)
                            {
                                DamageTool.damage(input.transform, false, input.direction, ((ItemMeleeAsset)base.player.equipment.asset).structureDamage, num4, out eplayerKill);
                            }
                        }
                    }
                }
                else if (input.type == ERaycastInfoType.RESOURCE)
                {
                    if (input.transform != null && input.transform.CompareTag("Resource"))
                    {
                        num4 *= 1f + base.channel.owner.player.skills.mastery(2, 2) * 0.5f;
                        byte   x2;
                        byte   y2;
                        ushort index2;
                        if (ResourceManager.tryGetRegion(input.transform, out x2, out y2, out index2))
                        {
                            ResourceSpawnpoint resourceSpawnpoint2 = ResourceManager.getResourceSpawnpoint(x2, y2, index2);
                            if (resourceSpawnpoint2 != null && !resourceSpawnpoint2.isDead && resourceSpawnpoint2.asset.bladeID == ((ItemWeaponAsset)base.player.equipment.asset).bladeID)
                            {
                                DamageTool.damage(input.transform, input.direction, ((ItemMeleeAsset)base.player.equipment.asset).resourceDamage, num4, 1f + base.channel.owner.player.skills.mastery(2, 2) * 0.5f, out eplayerKill, out num3);
                            }
                        }
                    }
                }
                else if (input.type == ERaycastInfoType.OBJECT && input.transform != null && input.section < 255)
                {
                    InteractableObjectRubble component5 = input.transform.GetComponent <InteractableObjectRubble>();
                    if (component5 != null && !component5.isSectionDead(input.section) && (component5.asset.rubbleIsVulnerable || ((ItemWeaponAsset)base.player.equipment.asset).isInvulnerable))
                    {
                        DamageTool.damage(input.transform, input.direction, input.section, ((ItemMeleeAsset)base.player.equipment.asset).objectDamage, num4, out eplayerKill, out num3);
                    }
                }
                if (input.type != ERaycastInfoType.PLAYER && input.type != ERaycastInfoType.ZOMBIE && input.type != ERaycastInfoType.ANIMAL && !base.player.life.isAggressor)
                {
                    float num5 = ((ItemMeleeAsset)base.player.equipment.asset).range + Provider.modeConfigData.Players.Ray_Aggressor_Distance;
                    num5 *= num5;
                    float num6 = Provider.modeConfigData.Players.Ray_Aggressor_Distance;
                    num6 *= num6;
                    Vector3 forward = base.player.look.aim.forward;
                    for (int i = 0; i < Provider.clients.Count; i++)
                    {
                        if (Provider.clients[i] != base.channel.owner)
                        {
                            Player player = Provider.clients[i].player;
                            if (!(player == null))
                            {
                                Vector3 vector  = player.look.aim.position - base.player.look.aim.position;
                                Vector3 vector2 = Vector3.Project(vector, forward);
                                if (vector2.sqrMagnitude < num5 && (vector2 - vector).sqrMagnitude < num6)
                                {
                                    base.player.life.markAggressive(false, true);
                                }
                            }
                        }
                    }
                }
                if (Level.info.type == ELevelType.HORDE)
                {
                    if (input.zombie != null)
                    {
                        if (input.limb == ELimb.SKULL)
                        {
                            base.player.skills.askPay(10u);
                        }
                        else
                        {
                            base.player.skills.askPay(5u);
                        }
                    }
                    if (eplayerKill == EPlayerKill.ZOMBIE)
                    {
                        if (input.limb == ELimb.SKULL)
                        {
                            base.player.skills.askPay(50u);
                        }
                        else
                        {
                            base.player.skills.askPay(25u);
                        }
                    }
                }
                else
                {
                    if (eplayerKill == EPlayerKill.PLAYER)
                    {
                        base.player.sendStat(EPlayerStat.KILLS_PLAYERS);
                        if (Level.info.type == ELevelType.ARENA)
                        {
                            base.player.skills.askPay(100u);
                        }
                    }
                    else if (eplayerKill == EPlayerKill.ZOMBIE)
                    {
                        base.player.sendStat(EPlayerStat.KILLS_ZOMBIES_NORMAL);
                    }
                    else if (eplayerKill == EPlayerKill.MEGA)
                    {
                        base.player.sendStat(EPlayerStat.KILLS_ZOMBIES_MEGA);
                    }
                    else if (eplayerKill == EPlayerKill.ANIMAL)
                    {
                        base.player.sendStat(EPlayerStat.KILLS_ANIMALS);
                    }
                    else if (eplayerKill == EPlayerKill.RESOURCE)
                    {
                        base.player.sendStat(EPlayerStat.FOUND_RESOURCES);
                    }
                    if (num3 > 0u)
                    {
                        base.player.skills.askPay(num3);
                    }
                }
            }
        }