Ejemplo n.º 1
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            // Try to spawn the zombie just like ZombieManager does
            // In a finished version, this would also need to be configurable
            UnturnedPlayer    untPlayer  = (UnturnedPlayer)caller;
            EZombieSpeciality speciality = EZombieSpeciality.NORMAL;
            byte    type  = 1;
            byte    shirt = (byte)Random.Range(0, 1);
            byte    pants = (byte)Random.Range(0, 1);
            byte    hat   = (byte)Random.Range(0, 1);
            byte    gear  = (byte)Random.Range(0, 1);
            byte    move  = (byte)Random.Range(0, 4);
            byte    idle  = (byte)Random.Range(0, 3);
            Vector3 point = untPlayer.Position;

            point.y += 0.1f;
            byte bound = untPlayer.Player.movement.bound;
            // The newewst zombie will have this id
            ushort zombieId = (ushort)ZombieManager.regions[bound].zombies.Count;

            // Add the zombie
            ZombieManager.instance.addZombie(bound, type, (byte)speciality, shirt, pants, hat, gear, move, idle, point, Random.Range(0f, 360f), false);

            // Get the Zombie by it's new id
            Zombie zombie = ZombieManager.getZombie(point, zombieId);

            /*zombie.sendRevive
             * (
             *  type,
             *  (byte)speciality,
             *  shirt,
             *  pants,
             *  hat,
             *  gear,
             *  untPlayer.Position,
             *  0
             * );*/

            UnturnedChat.Say("Spawned zombie with id " + zombieId);
        }
Ejemplo n.º 2
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);
                    }
                }
            }
        }