Beispiel #1
0
        public void BuildingEditData(IPlayer player, string newBuildingName, int newEntryFee)
        {
            player.GetData("current:doors", out IColShape colShape);
            if (colShape == null)
            {
                return;
            }

            BuildingEntity buildingEntity = colShape.GetBuildingEntity();

            if (!buildingEntity.IsCharacterOwner(player) && !buildingEntity.CanPlayerEditBuilding(player.GetAccountEntity().characterEntity))
            {
                return;
            }

            //string newBuildingName = args[0].ToString();
            //int newEntryFee = Convert.ToInt32(args[1]);

            Alt.Log($"name: {newBuildingName} entryfee: {newEntryFee}");

            buildingEntity.DbModel.Name     = newBuildingName;
            buildingEntity.DbModel.EntryFee = newEntryFee;

            player.SendNativeNotify(null, NotificationNativeType.Building, 1, "Edycja budynku", "~g~Budynek", "Edycja budynku przebiegła pomyślnie", 1);
        }
Beispiel #2
0
        public void RequestLockBuilding(IPlayer player)
        {
            player.GetData("current:doors", out IColShape colShape);
            if (colShape == null)
            {
                return;
            }

            BuildingEntity buildingEntity = colShape.GetBuildingEntity();

            if (!buildingEntity.IsCharacterOwner(player) && !buildingEntity.CanPlayerLockDoor(player.GetAccountEntity().characterEntity))
            {
                return;
            }
            Alt.Log("Przeszlo Lock pomyslnie");
            if (buildingEntity.IsLocked)
            {
                buildingEntity.IsLocked = false;
                player.SendNativeNotify(null, NotificationNativeType.Building, 1, "Otworzyłeś budynek", "~g~Budynek", "Ten budynek został otwarty");
            }
            else
            {
                buildingEntity.IsLocked = true;
                player.SendNativeNotify(null, NotificationNativeType.Building, 1, "Zamknąłeś budynek", "~g~Budynek", "Ten budynek został zamknięty");
            }

            Timer timer = new Timer(4000);

            timer.Start();
        }
Beispiel #3
0
        public static async Task LoadBuildingsAsync(UnitOfWork unit)
        {
            RoleplayContext ctx = Singleton.GetDatabaseInstance();

            foreach (BuildingModel building in await unit.BuildingRepository.GetAll())
            {
                Alt.Log($"[BUILDING-ENTITY: LOAD]: budynek o ID: {building.Id} został wczytany poprawnie!");
                BuildingEntity buildingEntity = new BuildingEntity(building);
                await buildingEntity.Spawn();
            }
        }
Beispiel #4
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);
        });
Beispiel #5
0
        public void OnExitBuilding(IPlayer player)
        {
            player.GetData("current:doors", out IColShape colShape);
            if (colShape == null)
            {
                return;
            }

            BuildingEntity buildingEntity = colShape.GetBuildingEntity();

            if (buildingEntity.IsLocked)
            {
                player.SendNativeNotify(null, NotificationNativeType.Building, 1, "Drzwi są zamknięte", "~g~Budynek", "Drzwi od tego budynku są zamknięte");
                return;
            }

            player.GetAccountEntity().characterEntity.Dimension = 0; // Defaultowy świat graczy
            player.Position = new Position(buildingEntity.DbModel.InternalPickupPositionX, buildingEntity.DbModel.InternalPickupPositionY, buildingEntity.DbModel.InternalPickupPositionZ);

            buildingEntity.PlayersInBuilding.Remove(player);

            player.DeleteData("current:doors");
        }
Beispiel #6
0
        public void OnEnterBuilding(IPlayer player)
        {
            player.GetData("current:doors", out IColShape colShape);
            if (colShape == null)
            {
                return;
            }

            BuildingEntity buildingEntity = colShape.GetBuildingEntity();

            if (buildingEntity.IsLocked)
            {
                player.SendNativeNotify(null, NotificationNativeType.Building, 1, "Drzwi są zamknięte", "~g~Budynek", "Drzwi od tego budynku są zamknięte");
                return;
            }

            if (buildingEntity.DbModel.EntryFee > 0 && (!buildingEntity.IsCharacterOwner(player) && !buildingEntity.IsCharacterTenant(player.GetAccountEntity().characterEntity)))
            {
                if (!player.GetAccountEntity().characterEntity.HasEnoughMoney(buildingEntity.DbModel.EntryFee, false))
                {
                    player.SendNativeNotify(null, NotificationNativeType.Normal, 1, "Nie masz przy sobie gotówki", "~g~Budynek", $"Aby wejść do tego budynku potrzebujesz ~g~{buildingEntity.DbModel.EntryFee}$");
                    return;
                }

                player.GetAccountEntity().characterEntity.RemoveMoney(buildingEntity.DbModel.EntryFee, false);
                buildingEntity.AddMoney(buildingEntity.DbModel.EntryFee);

                player.SendNativeNotify(null, NotificationNativeType.Building, 1, "Pobrano opłatę", "~g~Budynek", $"Pobrano opłatę {buildingEntity.DbModel.EntryFee}$ za wejście do budynku", 1);
            }

            // W późniejszym czasie wczytywanie customowych obiektów - dorobić tabelę building_objects i tam umieszczać obiekty

            player.GetAccountEntity().characterEntity.Dimension = buildingEntity.DbModel.Id;

            player.Position = new Position(buildingEntity.DbModel.ExternalPickupPositionX, buildingEntity.DbModel.ExternalPickupPositionY, buildingEntity.DbModel.ExternalPickupPositionZ);
            buildingEntity.PlayersInBuilding.Add(player);
        }
Beispiel #7
0
        public void GetBuildingManageData(IPlayer player)
        {
            player.GetData("current:doors", out IColShape colShape);
            if (colShape == null)
            {
                return;
            }

            BuildingEntity buildingEntity = colShape.GetBuildingEntity();

            if (!buildingEntity.IsCharacterOwner(player) && !buildingEntity.IsCharacterTenant(player.GetAccountEntity().characterEntity))
            {
                return;
            }

            BuildingTenantModel tenant = buildingEntity.DbModel.BuildingTenants.SingleOrDefault(plr => plr.CharacterId == player.GetAccountEntity().characterEntity.DbModel.Id);

            player.Emit("building:manageData",
                        buildingEntity.DbModel,
                        buildingEntity.DbModel.ItemsInBuilding,
                        player.GetAccountEntity().characterEntity.DbModel.Items,
                        buildingEntity.PlayersInBuilding,
                        tenant);
        }