示例#1
0
        public void askSalvageStructure(CSteamID steamID, byte x, byte y, ushort index)
        {
            StructureRegion structureRegion;

            if (Provider.isServer && StructureManager.tryGetRegion(x, y, out structureRegion))
            {
                Player player = PlayerTool.getPlayer(steamID);
                if (player == null)
                {
                    return;
                }
                if (player.life.isDead)
                {
                    return;
                }
                if ((int)index >= structureRegion.drops.Count)
                {
                    return;
                }
                if (!OwnershipTool.checkToggle(player.channel.owner.playerID.steamID, structureRegion.structures[(int)index].owner, player.quests.groupID, structureRegion.structures[(int)index].group))
                {
                    return;
                }
                ItemStructureAsset itemStructureAsset = (ItemStructureAsset)Assets.find(EAssetType.ITEM, structureRegion.structures[(int)index].structure.id);
                if (itemStructureAsset != null)
                {
                    if (itemStructureAsset.isUnpickupable)
                    {
                        return;
                    }
                    if (structureRegion.structures[(int)index].structure.health == itemStructureAsset.health)
                    {
                        player.inventory.forceAddItem(new Item(structureRegion.structures[(int)index].structure.id, EItemOrigin.NATURE), true);
                    }
                    else if (itemStructureAsset.isSalvageable)
                    {
                        for (int i = 0; i < itemStructureAsset.blueprints.Count; i++)
                        {
                            Blueprint blueprint = itemStructureAsset.blueprints[i];
                            if (blueprint.outputs.Length == 1 && blueprint.outputs[0].id == itemStructureAsset.id)
                            {
                                ushort id = blueprint.supplies[Random.Range(0, blueprint.supplies.Length)].id;
                                player.inventory.forceAddItem(new Item(id, EItemOrigin.NATURE), true);
                                break;
                            }
                        }
                    }
                }
                structureRegion.structures.RemoveAt((int)index);
                StructureManager.manager.channel.send("tellTakeStructure", ESteamCall.ALL, x, y, StructureManager.STRUCTURE_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                {
                    x,
                    y,
                    index,
                    (structureRegion.drops[(int)index].model.position - player.transform.position).normalized * 100f
                });
            }
        }
示例#2
0
 private static void onServerDisconnected(CSteamID steamID)
 {
     if (Provider.isServer && Level.isLoaded)
     {
         Player player = PlayerTool.getPlayer(steamID);
         if (player != null)
         {
             player.save();
         }
     }
 }
 public void askToggleObjectBinaryState(CSteamID steamID, byte x, byte y, ushort index)
 {
     if (Provider.isServer)
     {
         if (!Regions.checkSafe((int)x, (int)y))
         {
             return;
         }
         Player player = PlayerTool.getPlayer(steamID);
         if (player == null)
         {
             return;
         }
         if (player.life.isDead)
         {
             return;
         }
         if ((int)index >= LevelObjects.objects[(int)x, (int)y].Count)
         {
             return;
         }
         if (!player.tryToPerformRateLimitedAction())
         {
             return;
         }
         if ((LevelObjects.objects[(int)x, (int)y][(int)index].transform.position - player.transform.position).sqrMagnitude > 400f)
         {
             return;
         }
         InteractableObjectBinaryState interactableObjectBinaryState = LevelObjects.objects[(int)x, (int)y][(int)index].interactable as InteractableObjectBinaryState;
         if (interactableObjectBinaryState != null && interactableObjectBinaryState.isUsable && !interactableObjectBinaryState.objectAsset.interactabilityRemote)
         {
             if (!interactableObjectBinaryState.objectAsset.areConditionsMet(player))
             {
                 return;
             }
             if (!interactableObjectBinaryState.objectAsset.areInteractabilityConditionsMet(player))
             {
                 return;
             }
             interactableObjectBinaryState.objectAsset.applyInteractabilityConditions(player, true);
             interactableObjectBinaryState.objectAsset.grantInteractabilityRewards(player, true);
             ObjectManager.manager.channel.send("tellToggleObjectBinaryState", ESteamCall.ALL, x, y, ObjectManager.OBJECT_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
             {
                 x,
                 y,
                 index,
                 !interactableObjectBinaryState.isUsed
             });
             LevelObjects.objects[(int)x, (int)y][(int)index].state[0] = ((!interactableObjectBinaryState.isUsed) ? 0 : 1);
         }
     }
 }
 public void askUseObjectDropper(CSteamID steamID, byte x, byte y, ushort index)
 {
     if (Provider.isServer)
     {
         if (!Regions.checkSafe((int)x, (int)y))
         {
             return;
         }
         Player player = PlayerTool.getPlayer(steamID);
         if (player == null)
         {
             return;
         }
         if (player.life.isDead)
         {
             return;
         }
         if ((int)index >= LevelObjects.objects[(int)x, (int)y].Count)
         {
             return;
         }
         if (!player.tryToPerformRateLimitedAction())
         {
             return;
         }
         if ((LevelObjects.objects[(int)x, (int)y][(int)index].transform.position - player.transform.position).sqrMagnitude > 400f)
         {
             return;
         }
         InteractableObjectDropper interactableObjectDropper = LevelObjects.objects[(int)x, (int)y][(int)index].interactable as InteractableObjectDropper;
         if (interactableObjectDropper != null && interactableObjectDropper.isUsable)
         {
             if (!interactableObjectDropper.objectAsset.areConditionsMet(player))
             {
                 return;
             }
             if (!interactableObjectDropper.objectAsset.areInteractabilityConditionsMet(player))
             {
                 return;
             }
             interactableObjectDropper.objectAsset.applyInteractabilityConditions(player, true);
             interactableObjectDropper.objectAsset.grantInteractabilityRewards(player, true);
             interactableObjectDropper.drop();
         }
     }
 }
示例#5
0
 public void askUseObjectQuest(CSteamID steamID, byte x, byte y, ushort index)
 {
     if (Provider.isServer)
     {
         if (!Regions.checkSafe((int)x, (int)y))
         {
             return;
         }
         Player player = PlayerTool.getPlayer(steamID);
         if (player == null)
         {
             return;
         }
         if (player.life.isDead)
         {
             return;
         }
         if ((int)index >= LevelObjects.objects[(int)x, (int)y].Count)
         {
             return;
         }
         if ((LevelObjects.objects[(int)x, (int)y][(int)index].transform.position - player.transform.position).sqrMagnitude > 1600f)
         {
             return;
         }
         InteractableObject interactable = LevelObjects.objects[(int)x, (int)y][(int)index].interactable;
         if (interactable != null && (interactable is InteractableObjectQuest || interactable is InteractableObjectNote))
         {
             if (!interactable.objectAsset.areConditionsMet(player))
             {
                 return;
             }
             if (!interactable.objectAsset.areInteractabilityConditionsMet(player))
             {
                 return;
             }
             interactable.objectAsset.applyInteractabilityConditions(player, false);
             interactable.objectAsset.grantInteractabilityRewards(player, false);
         }
     }
 }
 public void askUseObjectNPC(CSteamID steamID, byte x, byte y, ushort index)
 {
     if (Provider.isServer)
     {
         if (!Regions.checkSafe((int)x, (int)y))
         {
             return;
         }
         Player player = PlayerTool.getPlayer(steamID);
         if (player == null)
         {
             return;
         }
         if (player.life.isDead)
         {
             return;
         }
         if ((int)index >= LevelObjects.objects[(int)x, (int)y].Count)
         {
             return;
         }
         if (!player.tryToPerformRateLimitedAction())
         {
             return;
         }
         if ((LevelObjects.objects[(int)x, (int)y][(int)index].transform.position - player.transform.position).sqrMagnitude > 400f)
         {
             return;
         }
         InteractableObjectNPC interactableObjectNPC = LevelObjects.objects[(int)x, (int)y][(int)index].interactable as InteractableObjectNPC;
         if (interactableObjectNPC != null)
         {
             if (!interactableObjectNPC.objectAsset.areConditionsMet(player))
             {
                 return;
             }
             player.quests.checkNPC = interactableObjectNPC;
         }
     }
 }
 public void askForage(CSteamID steamID, byte x, byte y, ushort index)
 {
     if (Provider.isServer)
     {
         if (!Regions.checkSafe((int)x, (int)y))
         {
             return;
         }
         Player player = PlayerTool.getPlayer(steamID);
         if (player == null)
         {
             return;
         }
         if (player.life.isDead)
         {
             return;
         }
         List <ResourceSpawnpoint> list = LevelGround.trees[(int)x, (int)y];
         if ((int)index >= list.Count)
         {
             return;
         }
         if (list[(int)index].isDead)
         {
             return;
         }
         ResourceAsset resourceAsset = (ResourceAsset)Assets.find(EAssetType.RESOURCE, LevelGround.resources[(int)list[(int)index].type].id);
         if (resourceAsset == null || !resourceAsset.isForage)
         {
             return;
         }
         list[(int)index].askDamage(1);
         if (resourceAsset.explosion != 0)
         {
             EffectManager.sendEffect(resourceAsset.explosion, x, y, ResourceManager.RESOURCE_REGIONS, list[(int)index].point);
         }
         ushort num;
         if (resourceAsset.rewardID != 0)
         {
             num = SpawnTableTool.resolve(resourceAsset.rewardID);
         }
         else
         {
             num = resourceAsset.log;
         }
         if (num != 0)
         {
             player.inventory.forceAddItem(new Item(num, EItemOrigin.NATURE), true);
             if (UnityEngine.Random.value < player.skills.mastery(2, 5))
             {
                 player.inventory.forceAddItem(new Item(num, EItemOrigin.NATURE), true);
             }
         }
         player.sendStat(EPlayerStat.FOUND_PLANTS);
         player.skills.askPay(1u);
         ResourceManager.manager.channel.send("tellResourceDead", ESteamCall.ALL, x, y, ResourceManager.RESOURCE_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
         {
             x,
             y,
             index,
             Vector3.zero
         });
     }
 }
示例#8
0
 public void askTakeItem(CSteamID steamID, byte x, byte y, uint instanceID, byte to_x, byte to_y, byte to_rot, byte to_page)
 {
     if (Provider.isServer)
     {
         if (!Regions.checkSafe((int)x, (int)y))
         {
             return;
         }
         Player player = PlayerTool.getPlayer(steamID);
         if (player == null)
         {
             return;
         }
         if (player.life.isDead)
         {
             return;
         }
         if (!player.tryToPerformRateLimitedAction())
         {
             return;
         }
         if (player.animator.gesture == EPlayerGesture.ARREST_START)
         {
             return;
         }
         ItemRegion itemRegion = ItemManager.regions[(int)x, (int)y];
         ushort     num        = 0;
         while ((int)num < itemRegion.items.Count)
         {
             if (itemRegion.items[(int)num].instanceID == instanceID)
             {
                 if (Dedicator.isDedicated && (itemRegion.items[(int)num].point - player.transform.position).sqrMagnitude > 400f)
                 {
                     return;
                 }
                 bool flag;
                 if (to_page == 255)
                 {
                     flag = player.inventory.tryAddItem(ItemManager.regions[(int)x, (int)y].items[(int)num].item, true);
                 }
                 else
                 {
                     flag = player.inventory.tryAddItem(ItemManager.regions[(int)x, (int)y].items[(int)num].item, to_x, to_y, to_page, to_rot);
                 }
                 if (flag)
                 {
                     if (!player.equipment.wasTryingToSelect && !player.equipment.isSelected)
                     {
                         player.animator.sendGesture(EPlayerGesture.PICKUP, true);
                     }
                     EffectManager.sendEffect(7, EffectManager.SMALL, ItemManager.regions[(int)x, (int)y].items[(int)num].point);
                     ItemManager.regions[(int)x, (int)y].items.RemoveAt((int)num);
                     player.sendStat(EPlayerStat.FOUND_ITEMS);
                     base.channel.send("tellTakeItem", ESteamCall.CLIENTS, x, y, ItemManager.ITEM_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                     {
                         x,
                         y,
                         instanceID
                     });
                 }
                 else
                 {
                     player.sendMessage(EPlayerMessage.SPACE);
                 }
                 return;
             }
             else
             {
                 num += 1;
             }
         }
     }
 }
示例#9
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);
                    }
                }
            }
        }