Example #1
0
        public static void transformStructure(Transform structure, Vector3 point, float angle_x, float angle_y, float angle_z)
        {
            angle_x = (float)(Mathf.RoundToInt(angle_x / 2f) * 2);
            angle_y = (float)(Mathf.RoundToInt(angle_y / 2f) * 2);
            angle_z = (float)(Mathf.RoundToInt(angle_z / 2f) * 2);
            byte            b;
            byte            b2;
            ushort          num;
            StructureRegion structureRegion;
            StructureDrop   structureDrop;

            if (StructureManager.tryGetInfo(structure, out b, out b2, out num, out structureRegion, out structureDrop))
            {
                StructureManager.manager.channel.send("askTransformStructure", ESteamCall.SERVER, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                {
                    b,
                    b2,
                    structureDrop.instanceID,
                    point,
                    MeasurementTool.angleToByte(angle_x),
                    MeasurementTool.angleToByte(angle_y),
                    MeasurementTool.angleToByte(angle_z)
                });
            }
        }
Example #2
0
        public static void repair(Transform structure, float damage, float times)
        {
            byte            b;
            byte            b2;
            ushort          num;
            StructureRegion structureRegion;

            if (StructureManager.tryGetInfo(structure, out b, out b2, out num, out structureRegion) && !structureRegion.structures[(int)num].structure.isDead && !structureRegion.structures[(int)num].structure.isRepaired)
            {
                ushort amount = (ushort)(damage * times);
                structureRegion.structures[(int)num].structure.askRepair(amount);
                for (int i = 0; i < Provider.clients.Count; i++)
                {
                    if (Provider.clients[i].player != null && OwnershipTool.checkToggle(Provider.clients[i].playerID.steamID, structureRegion.structures[(int)num].owner, Provider.clients[i].player.quests.groupID, structureRegion.structures[(int)num].group) && Regions.checkArea(b, b2, Provider.clients[i].player.movement.region_x, Provider.clients[i].player.movement.region_y, StructureManager.STRUCTURE_REGIONS))
                    {
                        StructureManager.manager.channel.send("tellStructureHealth", Provider.clients[i].playerID.steamID, ESteamPacket.UPDATE_UNRELIABLE_BUFFER, new object[]
                        {
                            b,
                            b2,
                            num,
                            (byte)Mathf.RoundToInt((float)structureRegion.structures[(int)num].structure.health / (float)structureRegion.structures[(int)num].structure.asset.health * 100f)
                        });
                    }
                }
            }
        }
Example #3
0
        public static void damage(Transform structure, Vector3 direction, float damage, float times, bool armor)
        {
            byte            b;
            byte            b2;
            ushort          num;
            StructureRegion structureRegion;

            if (StructureManager.tryGetInfo(structure, out b, out b2, out num, out structureRegion) && !structureRegion.structures[(int)num].structure.isDead)
            {
                if (armor)
                {
                    times *= Provider.modeConfigData.Structures.Armor_Multiplier;
                }
                ushort num2 = (ushort)(damage * times);
                structureRegion.structures[(int)num].structure.askDamage(num2);
                if (structureRegion.structures[(int)num].structure.isDead)
                {
                    ItemStructureAsset itemStructureAsset = (ItemStructureAsset)Assets.find(EAssetType.ITEM, structureRegion.structures[(int)num].structure.id);
                    if (itemStructureAsset != null && itemStructureAsset.explosion != 0)
                    {
                        EffectManager.sendEffect(itemStructureAsset.explosion, EffectManager.SMALL, structure.position + Vector3.down * StructureManager.HEIGHT);
                    }
                    structureRegion.structures.RemoveAt((int)num);
                    StructureManager.manager.channel.send("tellTakeStructure", ESteamCall.ALL, b, b2, StructureManager.STRUCTURE_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                    {
                        b,
                        b2,
                        num,
                        direction * (float)num2
                    });
                }
                else
                {
                    for (int i = 0; i < Provider.clients.Count; i++)
                    {
                        if (Provider.clients[i].player != null && OwnershipTool.checkToggle(Provider.clients[i].playerID.steamID, structureRegion.structures[(int)num].owner, Provider.clients[i].player.quests.groupID, structureRegion.structures[(int)num].group) && Regions.checkArea(b, b2, Provider.clients[i].player.movement.region_x, Provider.clients[i].player.movement.region_y, StructureManager.STRUCTURE_REGIONS))
                        {
                            StructureManager.manager.channel.send("tellStructureHealth", Provider.clients[i].playerID.steamID, ESteamPacket.UPDATE_UNRELIABLE_BUFFER, new object[]
                            {
                                b,
                                b2,
                                num,
                                (byte)Mathf.RoundToInt((float)structureRegion.structures[(int)num].structure.health / (float)structureRegion.structures[(int)num].structure.asset.health * 100f)
                            });
                        }
                    }
                }
            }
        }
Example #4
0
        public static void salvageStructure(Transform structure)
        {
            byte            b;
            byte            b2;
            ushort          num;
            StructureRegion structureRegion;

            if (StructureManager.tryGetInfo(structure, out b, out b2, out num, out structureRegion))
            {
                StructureManager.manager.channel.send("askSalvageStructure", ESteamCall.SERVER, ESteamPacket.UPDATE_UNRELIABLE_BUFFER, new object[]
                {
                    b,
                    b2,
                    num
                });
            }
        }
Example #5
0
 public virtual void write(SteamChannel channel)
 {
     channel.write(this.sequence);
     channel.write(this.recov);
     channel.write(this.keys);
     if (this.clientsideInputs == null)
     {
         channel.write(0);
     }
     else
     {
         channel.write((byte)this.clientsideInputs.Count);
         foreach (RaycastInfo raycastInfo in this.clientsideInputs)
         {
             if (raycastInfo.player != null)
             {
                 channel.write(3);
                 channel.write(raycastInfo.point);
                 channel.write(raycastInfo.direction);
                 channel.write(raycastInfo.normal);
                 channel.write((byte)raycastInfo.limb);
                 channel.write(raycastInfo.player.channel.owner.playerID.steamID);
             }
             else if (raycastInfo.zombie != null)
             {
                 channel.write(4);
                 channel.write(raycastInfo.point);
                 channel.write(raycastInfo.direction);
                 channel.write(raycastInfo.normal);
                 channel.write((byte)raycastInfo.limb);
                 channel.write(raycastInfo.zombie.id);
             }
             else if (raycastInfo.animal != null)
             {
                 channel.write(5);
                 channel.write(raycastInfo.point);
                 channel.write(raycastInfo.direction);
                 channel.write(raycastInfo.normal);
                 channel.write((byte)raycastInfo.limb);
                 channel.write(raycastInfo.animal.index);
             }
             else if (raycastInfo.vehicle != null)
             {
                 channel.write(6);
                 channel.write(raycastInfo.point);
                 channel.write(raycastInfo.normal);
                 channel.write((byte)raycastInfo.material);
                 channel.write(raycastInfo.vehicle.instanceID);
             }
             else if (raycastInfo.transform != null)
             {
                 if (raycastInfo.transform.CompareTag("Barricade"))
                 {
                     channel.write(7);
                     InteractableDoorHinge component = raycastInfo.transform.GetComponent <InteractableDoorHinge>();
                     if (component != null)
                     {
                         raycastInfo.transform = component.transform.parent.parent;
                     }
                     byte            b;
                     byte            b2;
                     ushort          num;
                     ushort          num2;
                     BarricadeRegion barricadeRegion;
                     if (BarricadeManager.tryGetInfo(raycastInfo.transform, out b, out b2, out num, out num2, out barricadeRegion))
                     {
                         channel.write(raycastInfo.point);
                         channel.write(raycastInfo.normal);
                         channel.write((byte)raycastInfo.material);
                         channel.write(b);
                         channel.write(b2);
                         channel.write(num);
                         channel.write(num2);
                     }
                     else
                     {
                         channel.write(Vector3.zero);
                         channel.write(Vector3.up);
                         channel.write(0);
                         channel.write(0);
                         channel.write(0);
                         channel.write(ushort.MaxValue);
                         channel.write(ushort.MaxValue);
                     }
                 }
                 else if (raycastInfo.transform.CompareTag("Structure"))
                 {
                     channel.write(8);
                     byte            b3;
                     byte            b4;
                     ushort          num3;
                     StructureRegion structureRegion;
                     if (StructureManager.tryGetInfo(raycastInfo.transform, out b3, out b4, out num3, out structureRegion))
                     {
                         channel.write(raycastInfo.point);
                         channel.write(raycastInfo.direction);
                         channel.write(raycastInfo.normal);
                         channel.write((byte)raycastInfo.material);
                         channel.write(b3);
                         channel.write(b4);
                         channel.write(num3);
                     }
                     else
                     {
                         channel.write(Vector3.zero);
                         channel.write(Vector3.up);
                         channel.write(Vector3.up);
                         channel.write(0);
                         channel.write(0);
                         channel.write(0);
                         channel.write(ushort.MaxValue);
                     }
                 }
                 else if (raycastInfo.transform.CompareTag("Resource"))
                 {
                     channel.write(9);
                     byte   b5;
                     byte   b6;
                     ushort num4;
                     if (ResourceManager.tryGetRegion(raycastInfo.transform, out b5, out b6, out num4))
                     {
                         channel.write(raycastInfo.point);
                         channel.write(raycastInfo.direction);
                         channel.write(raycastInfo.normal);
                         channel.write((byte)raycastInfo.material);
                         channel.write(b5);
                         channel.write(b6);
                         channel.write(num4);
                     }
                     else
                     {
                         channel.write(Vector3.zero);
                         channel.write(Vector3.up);
                         channel.write(Vector3.up);
                         channel.write(0);
                         channel.write(0);
                         channel.write(0);
                         channel.write(ushort.MaxValue);
                     }
                 }
                 else if (raycastInfo.transform.CompareTag("Small") || raycastInfo.transform.CompareTag("Medium") || raycastInfo.transform.CompareTag("Large"))
                 {
                     channel.write(2);
                     byte   b7;
                     byte   b8;
                     ushort num5;
                     if (ObjectManager.tryGetRegion(raycastInfo.transform, out b7, out b8, out num5))
                     {
                         channel.write(raycastInfo.point);
                         channel.write(raycastInfo.direction);
                         channel.write(raycastInfo.normal);
                         channel.write((byte)raycastInfo.material);
                         channel.write(raycastInfo.section);
                         channel.write(b7);
                         channel.write(b8);
                         channel.write(num5);
                     }
                     else
                     {
                         channel.write(Vector3.zero);
                         channel.write(Vector3.up);
                         channel.write(Vector3.up);
                         channel.write(0);
                         channel.write(byte.MaxValue);
                         channel.write(0);
                         channel.write(0);
                         channel.write(ushort.MaxValue);
                     }
                 }
                 else if (raycastInfo.transform.CompareTag("Ground") || raycastInfo.transform.CompareTag("Environment"))
                 {
                     channel.write(0);
                     channel.write(raycastInfo.point);
                     channel.write(raycastInfo.normal);
                     channel.write((byte)raycastInfo.material);
                 }
                 else
                 {
                     channel.write(1);
                 }
             }
             else
             {
                 channel.write(1);
             }
         }
     }
 }