Esempio n. 1
0
        private async Task HandleColshape(IColShape colShape, IEntity targetEntity, bool state)
        {
            lock (targetEntity)
            {
                switch (targetEntity)
                {
                case IPlayer player when state:
                {
                    Logger.Info("Player entered a colshape");
                    break;
                }

                case IPlayer player:
                {
                    Logger.Info("Player left a colshape");
                    break;
                }

                case IVehicle vehicle when state:
                {
                    Logger.Info("Vehicle entered a colshape");
                    break;
                }

                case IVehicle vehicle:
                {
                    Logger.Info("Vehicle left a colshape");
                    break;
                }
                }
            }
        }
        public async Task OnEnterColshape(IColShape shape, IEntity targetEntity, bool state) => await AltAsync.Do(() =>
        {
            IPlayer player = targetEntity as IPlayer;
            if (!state)
            {
                return;
            }


            if (shape == null || !shape.Exists)
            {
                return;
            }
            if (targetEntity.Type != BaseObjectType.Player)
            {
                return;
            }
            Alt.Log("Bagażniki");

            if (!shape.HasData("vehicle:trunk"))
            {
                return;
            }
            Alt.Log("Wchodze w bagaznik colshape");
            new Interaction(player, "vehicle-trunk:open", "aby otworzyć ~g~bagażnik");
            player.SetData("current:vehicle-trunk", shape);

            //if (shape.HasData("vehicle:trunk"))
            //{

            //}
        });
Esempio n. 3
0
        public async Task OnColshape(IColShape colShape, IEntity targetEntity, bool state) => await AltAsync.Do(() =>
        {
            if (!state)
            {
                return;
            }
            if (colShape == null || !colShape.Exists)
            {
                return;
            }
            if (targetEntity.Type != BaseObjectType.Player)
            {
                return;
            }

            Alt.Log("Busy");

            BusEntity busEntity = colShape.GetBusEntity();

            if (busEntity == null || busEntity.ColShape != colShape)
            {
                return;
            }

            IPlayer player = targetEntity as IPlayer;

            if (player.IsInVehicle)
            {
                return;
            }

            new Interaction(player, "bus:openWindow", "aby otworzyć ~g~rozkład jazdy");
            player.SetData("current:bus", busEntity);
        });
Esempio n. 4
0
        public async Task OnColshape(IColShape colShape, IEntity targetEntity, bool state) => await AltAsync.Do(() =>
        {
            if (!state)
            {
                return;
            }

            if (colShape == null || !colShape.Exists)
            {
                return;
            }
            if (targetEntity.Type != BaseObjectType.Player)
            {
                return;
            }
            Alt.Log("Banki");

            AtmEntity atmEntity = colShape.GetAtmEntity();

            if (atmEntity == null || atmEntity.ColShape != colShape)
            {
                return;
            }

            IPlayer player = targetEntity as IPlayer;
            if (player.IsInVehicle)
            {
                return;
            }

            new Interaction(player, "atm:openWindow", "aby otworzyć ~g~ATM");
        });
Esempio n. 5
0
        public async Task OnEnterColshape(IColShape colShape, IEntity targetEntity, bool state) => await AltAsync.Do(() =>
        {
            if (!state)
            {
                return;
            }
            if (colShape == null || !colShape.Exists)
            {
                return;
            }
            if (targetEntity.Type != BaseObjectType.Player)
            {
                return;
            }

            AltAsync.Log("Shop");

            ShopEntity shopEntity = colShape.GetShopEntity();

            if (shopEntity == null || shopEntity.ColShape != colShape)
            {
                return;
            }

            IPlayer player = targetEntity as IPlayer;

            if (player.IsInVehicle)
            {
                return;
            }

            player.SetData("current:shop", shopEntity);
            new Interaction(player, "shop:openWindow", "aby otworzyć ~g~sklep");
        });
Esempio n. 6
0
 public void RemoveColShape(IColShape colShape)
 {
     if (colShape.Exists)
     {
         AltNative.Server.Server_DestroyColShape(NativePointer, colShape.NativePointer);
     }
 }
        public void OnEnterColshape(IColShape colShape, IEntity entity, bool state)
        {
            if (!state)
            {
                return;
            }

            if (colShape.HasData("warehouse:data"))
            {
                Alt.Log("Przechodze po HasData");
                if (entity is IPlayer player)
                {
                    Alt.Log("Colshape ma dane warehouse");
                    colShape.GetData("warehouse:data", out WarehouseEntity warehouseEntity);

                    if (warehouseEntity == null)
                    {
                        return;
                    }

                    CharacterEntity characterEntity = player.GetAccountEntity().characterEntity;

                    if (characterEntity.CurrentDeliveryOrder != null)
                    {
                        new Interaction(player, "warehouse:deliverOrder", "aby dostarczyć paczkę");
                    }
                }
            }
        }
Esempio n. 8
0
        public void CreateColShape()
        {
            IColShape col = Alt.Server.CreateColShapeCircle(new Position(this.CurrentArena.Center.X, this.CurrentArena.Center.Y, this.CurrentArena.Center.Z), (float)(this.CurrentArena.MarkerScale / 2));

            this.CurrentColshape = col;
            col.Dimension        = this.Attacker.Id;
        }
Esempio n. 9
0
 public void RemoveColShape(IColShape colShape)
 {
     CheckIfCallIsValid();
     if (colShape.Exists)
     {
         AltNative.Server.Server_DestroyColShape(NativePointer, colShape.NativePointer);
     }
 }
Esempio n. 10
0
 public JunkerJob(JobEntityModel jobEntityModel) : base(jobEntityModel)
 {
     foreach (TrashPointModel trash in TrashPoints)
     {
         IColShape trashColshape = Alt.CreateColShapeCylinder(new Position(trash.TrashPosition.X, trash.TrashPosition.Y, trash.TrashPosition.Z - 0.9f), 2f, 2f);
         trashColshape.SetData("trash:data", trash);
     }
 }
Esempio n. 11
0
        public static string GetColShapeName(this IColShape cols)
        {
            var myColshape = (ClassicColshape)cols;

            if (myColshape == null || !myColshape.Exists)
            {
                return("None");
            }
            return(myColshape.ColshapeName);
        }
Esempio n. 12
0
        public static ulong GetColshapeCarDealerVehPrice(this IColShape cols)
        {
            var myColshape = (ClassicColshape)cols;

            if (myColshape == null || !myColshape.Exists)
            {
                return(0);
            }
            return(myColshape.CarDealerVehPrice);
        }
Esempio n. 13
0
        public static void SetColShapeName(this IColShape cols, string name)
        {
            var myColshape = (ClassicColshape)cols;

            if (myColshape == null || !myColshape.Exists)
            {
                return;
            }
            myColshape.ColshapeName = name;
        }
Esempio n. 14
0
        public static void SetColShapeId(this IColShape cols, ulong id)
        {
            var myColshape = (ClassicColshape)cols;

            if (myColshape == null || !myColshape.Exists)
            {
                return;
            }
            myColshape.ColshapeId = (int)id;
        }
Esempio n. 15
0
        public static ulong GetColShapeId(this IColShape cols)
        {
            var myColshape = (ClassicColshape)cols;

            if (myColshape == null || !myColshape.Exists)
            {
                return(0);
            }
            return((ulong)myColshape.ColshapeId);
        }
Esempio n. 16
0
 public void RemoveColShape(IColShape colShape)
 {
     CheckIfCallIsValid();
     if (colShape.Exists)
     {
         unsafe
         {
             Library.Server.Core_DestroyColShape(NativePointer, colShape.ColShapeNativePointer);
         }
     }
 }
Esempio n. 17
0
        public void OnColshapeEnter(IColShape colshape, IEntity target, bool state)
        {
            if (target is not IAltPlayer targetPlayer)
            {
                return;
            }

            // entity to async
            targetPlayer.EnableWeaponUsage = state;
            targetPlayer.Emit("airport_state", state);
        }
Esempio n. 18
0
 public override void OnColShapeEvent(IColShape colShape, IEntity entity, bool state)
 {
     base.OnColShapeEvent(colShape, entity, state);
     if (!ColShapeAsyncDelegateHandlers.HasEvents())
     {
         return;
     }
     Task.Run(() =>
              ColShapeAsyncDelegateHandlers.CallAsyncWithoutTask(@delegate =>
                                                                 @delegate(colShape, entity, state)));
 }
        public static bool TryToAsync(this IColShape thisValue, IAsyncContext asyncContext, out IColShape colShape)
        {
            if (!asyncContext.CreateRef(thisValue, true))
            {
                colShape = default;
                return(false);
            }

            colShape = new AsyncColShape(thisValue, asyncContext);
            return(true);
        }
Esempio n. 20
0
        public void OnEnterColshape(IColShape colShape, IEntity targetEntity, bool state)
        {
            if (targetEntity.Type != BaseObjectType.Player)
            {
                return;
            }
            IPlayer player = targetEntity as IPlayer;

            if (state == false)
            {
                Interaction.Clear(player);
            }
        }
Esempio n. 21
0
 public AsyncColShapeRef(IColShape colShape)
 {
     if (colShape == null)
     {
         this.colShape = null;
     }
     else
     {
         lock (colShape)
         {
             this.colShape = colShape.AddRef() ? colShape : null;
         }
     }
 }
        private void ComputeWorldObject(IWorldObject worldObject)
        {
            lock (worldObject)
            {
                if (!worldObject.Exists)
                {
                    return;
                }
                pos = worldObject.Position;
            }

            var posX = OffsetPosition(pos.X);
            var posY = OffsetPosition(pos.Y);

            if (posX < 0 || posY < 0 || posX > MaxCoordinate || posY > MaxCoordinate)
            {
                return;
            }

            //TODO: when ceiling and floor is not the same divided by AreaSize we need to check two areas, that can happen on border

            var xIndex = (int)Math.Floor(posX / areaSize);

            var yIndex = (int)Math.Floor(posY / areaSize);

            lock (colShapeAreas)
            {
                var areaColShapes = colShapeAreas[xIndex][yIndex];

                for (int j = 0, innerLength = areaColShapes.Length; j < innerLength; j++)
                {
                    shape = areaColShapes[j];
                    if (!shape.IsPositionInside(in pos))
                    {
                        continue;
                    }
                    shape.SetCheck(worldObject);
                    if (shape.AddWorldObject(worldObject))
                    {
                        OnEntityEnterColShape?.Invoke(worldObject, shape);
                    }
                }
            }
        }
Esempio n. 23
0
        public override void OnColShapeEvent(IColShape colShape, IEntity entity, bool state)
        {
            base.OnColShapeEvent(colShape, entity, state);
            if (!ColShapeAsyncDelegateHandlers.HasEvents())
            {
                return;
            }
            var colShapeReference = new ColShapeRef(colShape);

            switch (entity)
            {
            case IPlayer playerEntity:
                var playerEntityReference = new PlayerRef(playerEntity);
                Task.Run(async() =>
                {
                    await ColShapeAsyncDelegateHandlers.CallAsync(@delegate =>
                                                                  @delegate(colShape, entity, state));
                    playerEntityReference.Dispose();
                    colShapeReference.Dispose();
                });
                break;

            case IVehicle vehicleEntity:
                var vehicleEntityReference = new VehicleRef(vehicleEntity);
                Task.Run(async() =>
                {
                    await ColShapeAsyncDelegateHandlers.CallAsync(@delegate =>
                                                                  @delegate(colShape, entity, state));
                    vehicleEntityReference.Dispose();
                    colShapeReference.Dispose();
                });
                break;

            default:
                Task.Run(async() =>
                {
                    await ColShapeAsyncDelegateHandlers.CallAsync(@delegate =>
                                                                  @delegate(colShape, entity, state));
                    colShapeReference.Dispose();
                });
                break;
            }
        }
Esempio n. 24
0
        public void LoadGarage()
        {
            Database db      = new Database();
            float    garageX = db.SelectFloat($"SELECT * FROM garage WHERE teamid={this.Id}", "pos_x");
            float    garageY = db.SelectFloat($"SELECT * FROM garage WHERE teamid={this.Id}", "pos_y");
            float    garageZ = db.SelectFloat($"SELECT * FROM garage WHERE teamid={this.Id}", "pos_z");

            this.Garage     = new Position(garageX, garageY, garageZ);
            this.GaragePed  = db.SelectString($"SELECT * FROM garage WHERE teamid={this.Id}", "ped");
            this.NPCHeading = db.SelectFloat($"SELECT * FROM garage WHERE teamid={this.Id}", "heading");
            float spawnX = db.SelectFloat($"SELECT * FROM garages_spawns WHERE id={this.Id}", "spawn_x");
            float spawnY = db.SelectFloat($"SELECT * FROM garages_spawns WHERE id={this.Id}", "spawn_y");
            float spawnZ = db.SelectFloat($"SELECT * FROM garages_spawns WHERE id={this.Id}", "spawn_z");

            this.GarageSpawn        = new Position(spawnX, spawnY, spawnZ);
            this.GarageSpawnHeading = db.SelectFloat($"SELECT * FROM garages_spawns WHERE id={this.Id}", "spawn_heading");
            IColShape shape = Alt.CreateColShapeCircle(this.Garage, 5f);

            shape.SetData("GARAGE", this.Id);
        }
Esempio n. 25
0
        public void OnPlayerEnterColshape(IColShape colShape, IEntity entity, bool state)
        {
            if (entity is IPlayer player)
            {
                if (colShape.HasData("job-center:data"))
                {
                    if (state)
                    {
                        colShape.GetData("job-center:data", out JobCenterEntity jobCenterEntity);
                        player.SetData("current:job-center", jobCenterEntity);

                        new Interaction(player, "job-center:showWindow", "aby otworzyć menu urzędu pracy");
                    }
                    else
                    {
                        player.DeleteData("current:job-center");
                    }
                }
            }
        }
Esempio n. 26
0
        public Task OnColShape(IColShape colShape, IEntity entity, bool state)
        {
            if (state == false)
            {
                return(Task.CompletedTask);
            }
            if (entity is IPlayer)
            {
                var player = entity as User;
                if (!player.IsInVehicle)
                {
                    return(Task.CompletedTask);
                }
                NotifyHandler.SendNotification(player, "Verlasse dieses Gebiet innerhalb von 10 Sekunden", 10000);
            }

            if (entity is IVehicle)
            {
                var veh = entity as Car;
                Console.WriteLine("Create Timer");
                var EmpTimer = new Timer();
                EmpTimer.Interval = 10000;
                EmpTimer.Enabled  = true;
                EmpTimer.Elapsed += (sender, args) =>
                {
                    Console.WriteLine("Timer elapsed");

                    if (!veh.Position.IsInRange(colShape.Position, 200f))
                    {
                        EmpTimer.Dispose();
                        return;
                    }
                    ;
                    Console.WriteLine("Veh inside!");
                    EmpTimer.Dispose();
                    veh.SetNetworkOwner(veh.Driver, false);
                    veh.Driver.Emit("NetOwner:DestroyVehicle", veh);
                };
            }
            return(Task.CompletedTask);
        }
        /// <summary>
        /// Init col shape module
        /// areaSize of 1 requires 10gb ram
        /// areaSize of 10 requires 100mb ram
        /// areaSize of 100 requires 1mb ram
        /// </summary>
        /// <param name="areaSize">Larger area size => more ram, less cpu usage</param>
        public ColShapeModule(int areaSize = 100)
        {
            this.areaSize = areaSize;
            maxAreaIndex  = MaxCoordinate / areaSize;
            colShapeAreas = new IColShape[maxAreaIndex][][];
            for (var i = 0; i < maxAreaIndex; i++)
            {
                colShapeAreas[i] = new IColShape[maxAreaIndex][];
                for (var j = 0; j < maxAreaIndex; j++)
                {
                    colShapeAreas[i][j] = new IColShape[0];
                }
            }

            var thread = new Thread(Loop)
            {
                IsBackground = true
            };

            thread.Start();
        }
Esempio n. 28
0
        public async Task OnEnterColshape(IColShape colShape, IEntity targetEntity, bool state) => await AltAsync.Do(() =>
        {
            IPlayer player = targetEntity as IPlayer;
            if (!state)
            {
                return;
            }


            if (colShape == null || !colShape.Exists)
            {
                return;
            }
            if (targetEntity.Type != BaseObjectType.Player)
            {
                return;
            }
            Alt.Log("Budynki");

            BuildingEntity buildingEntity = colShape.GetBuildingEntity();

            if (buildingEntity == null)
            {
                return;
            }
            if (buildingEntity.InteriorColshape != colShape && buildingEntity.ExteriorColshape != colShape)
            {
                return;
            }

            bool colshapeEnter = buildingEntity.InteriorColshape == colShape ? true : false;
            Alt.Log("buildingEntity.IsCharacterTenant(player.GetAccountEntity().characterEntity): " + buildingEntity.IsCharacterTenant(player.GetAccountEntity().characterEntity).ToString());
            player.EmitAsync("building:request",
                             buildingEntity.DbModel.EntryFee,
                             buildingEntity.DbModel.Name,
                             colshapeEnter,
                             buildingEntity.IsCharacterOwner(player),
                             buildingEntity.IsCharacterTenant(player.GetAccountEntity().characterEntity));
            player.SetData("current:doors", colShape);
        });
Esempio n. 29
0
        public override void OnColShapeEvent(IColShape colShape, IEntity entity, bool state)
        {
            base.OnColShapeEvent(colShape, entity, state);
            if (!ColShapeAsyncDelegateHandlers.HasEvents())
            {
                return;
            }
            var colShapeReference = new ColShapeRef(colShape);
            var baseObjectRef     = new BaseObjectRef(entity);

            Task.Run(async() =>
            {
                colShapeReference.DebugCountUp();
                baseObjectRef.DebugCountUp();
                await ColShapeAsyncDelegateHandlers.CallAsync(@delegate =>
                                                              @delegate(colShape, entity, state));
                baseObjectRef.DebugCountDown();
                colShapeReference.DebugCountDown();
                baseObjectRef.Dispose();
                colShapeReference.Dispose();
            });
        }
Esempio n. 30
0
        public void OnPlayerEnterColshape(IColShape colShape, IEntity entity, bool state)
        {
            if (entity is IPlayer player)
            {
                if (state)
                {
                    if (colShape.HasData("trash:data"))
                    {
                        CharacterEntity characterEntity = player.GetAccountEntity().characterEntity;

                        colShape.GetData("trash:data", out TrashPointModel trashPoint);
                        if (characterEntity.CurrentTrashPoint != null)
                        {
                            if (characterEntity.CurrentTrashPoint.Id == trashPoint.Id)
                            {
                                new Interaction(player, "job-junker:dump", "aby opróżnić kosz na śmieci");
                            }
                        }
                    }
                }
            }
        }