Пример #1
0
 public void tellObjectResource(CSteamID steamID, byte x, byte y, ushort index, ushort amount)
 {
     if (base.channel.checkServer(steamID))
     {
         if (!Regions.checkSafe((int)x, (int)y))
         {
             return;
         }
         ObjectRegion objectRegion = ObjectManager.regions[(int)x, (int)y];
         if (!Provider.isServer && !objectRegion.isNetworked)
         {
             return;
         }
         if ((int)index >= LevelObjects.objects[(int)x, (int)y].Count)
         {
             return;
         }
         InteractableObjectResource interactableObjectResource = LevelObjects.objects[(int)x, (int)y][(int)index].interactable as InteractableObjectResource;
         if (interactableObjectResource != null)
         {
             interactableObjectResource.updateAmount(amount);
         }
     }
 }
Пример #2
0
 // Token: 0x0600397E RID: 14718 RVA: 0x001AAFB4 File Offset: 0x001A93B4
 private bool fire(bool mode)
 {
     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.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);
 }
Пример #3
0
 // 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);
 }