Ejemplo n.º 1
0
        public async Task Load(AtlasPlayer player)
        {
            API.DoScreenFadeOut(0);

            Atlas.DiscordRichPresence.Status = player.Character.Fullname;
            Atlas.DiscordRichPresence.Commit();

            var transition = new LoadTransition();

            if (!player.Character.MarkedAsRegistered)
            {
                API.StopPlayerSwitch();
            }

            var character = player.Character;
            var position  = !character.MarkedAsRegistered
                ? CharacterExtensions.RegistrationPosition
                : character.Metadata.LastPosition ?? CharacterExtensions.DefaultPosition;

            if (position == character.Metadata.LastPosition)
            {
                position.Y += 1f;
            }

            character.Revive(position);

            try
            {
                var ped    = Cache.Entity.Id;
                var health = character.Health;

                if (health > API.GetEntityMaxHealth(ped))
                {
                    health = API.GetEntityMaxHealth(ped);
                }

                API.SetEntityHealth(ped, health);
                API.SetPedArmour(ped, character.Shield);
            }
            catch (Exception)
            {
                // Dunno
            }

            var inventories = InventoryManager.GetModule();
            var required    = new InventoryContainer[]
            {
                new EquipmentInventory(new InventoryContainerBase
                {
                    Seed       = "equipment_inventory",
                    Name       = "Utrustning",
                    SlotAmount = 5
                }),
                new PocketsInventory(new InventoryContainerBase
                {
                    Seed       = "pockets_inventory",
                    Name       = "Fickor",
                    SlotAmount = 20
                }),
                new ProximityInventory(new InventoryContainerBase
                {
                    Seed       = "proximity_inventory",
                    Name       = "Omgivning",
                    SlotAmount = 20
                })
            };

            foreach (var entry in required)
            {
                if (character.Metadata.Inventories.All(self => self.Seed != entry.Seed))
                {
                    inventories.RegisterContainer(entry);
                    character.Metadata.Inventories.Add(entry);

                    entry.CallRegistration();
                }
                else
                {
                    var created = entry;

                    switch (entry.Seed.ToUpper())
                    {
                    case "EQUIPMENT_INVENTORY":
                        created = new EquipmentInventory(
                            character.Metadata.Inventories.FirstOrDefault(
                                self => self.Seed == "equipment_inventory"));

                        break;

                    case "POCKETS_INVENTORY":
                        created = new PocketsInventory(
                            character.Metadata.Inventories.FirstOrDefault(
                                self => self.Seed == "pockets_inventory"));

                        break;

                    case "PROXIMITY_INVENTORY":
                        created = new ProximityInventory(
                            character.Metadata.Inventories.FirstOrDefault(
                                self => self.Seed == "proximity_inventory"));
                        created.Slots = new InventoryItem[created.SlotAmount];

                        break;

                    default:
                        Logger.Info($"[Inventory] Could not find default required inventory {entry.Seed}");

                        break;
                    }

                    inventories.RegisterContainer(created);
                    created.CallRegistration();
                }
            }

            inventories.Registry.ForEach(self => self.RefreshItemClassifications());

            await player.Character.Load();

            Session.Join(player.Character.MarkedAsRegistered ? 1 : 100 + API.GetPlayerServerId(API.PlayerId()));

            await SafeTeleport.Teleport(player.Entity.Id, position);

            if (player.Character.MarkedAsRegistered)
            {
                await transition.Wait();

                API.DoScreenFadeIn(5000);

                await transition.Down(player);
            }
            else
            {
                await player.Character.PostLoad();
            }

            if (API.IsScreenFadedOut() && !API.IsScreenFadingOut())
            {
                API.DoScreenFadeIn(5000);
            }

            player.EnableHud();
        }
Ejemplo n.º 2
0
 private void Start()
 {
     lt = GameObject.FindGameObjectWithTag("LevelLoader").GetComponent <LoadTransition>();
 }
Ejemplo n.º 3
0
    private void Start()
    {
        lt = GameObject.FindGameObjectWithTag("LevelLoader").GetComponent <LoadTransition>();

        player = GameObject.Find("Player").GetComponent <FirstPersonController>();
    }