예제 #1
0
        public static void CreateProperty(Client player, string ownerType, PropertyType type, string Name)
        {
            Data.Property propertyData = new Data.Property();
            string        ownerName;

            if (ownerType == "player")
            {
                AccountController TargetAccountController = AccountController.GetAccountControllerFromName(Name);
                if (TargetAccountController == null)
                {
                    return;
                }
                propertyData.Character = TargetAccountController.CharacterController.Character;
                ownerName = TargetAccountController.CharacterController.FormatName;
            }
            else if (ownerType == "group")
            {
                Groups.GroupController GroupController = EntityManager.GetGroup(player, Name);
                if (GroupController == null)
                {
                    return;
                }

                propertyData.Group = GroupController.Group;
                ownerName          = GroupController.Group.Name;
            }
            else
            {
                API.shared.sendChatMessageToPlayer(player, "~r~ERROR: ~w~You specified an invalid owner type (player/group");
                return;
            }

            PropertyController PropertyController = new PropertyController(propertyData);

            propertyData.Type            = type;
            propertyData.ExtPosX         = player.position.X;
            propertyData.ExtPosY         = player.position.Y;
            propertyData.ExtPosZ         = player.position.Z;
            PropertyController.ownername = ownerName;

            ContextFactory.Instance.Property.Add(propertyData);
            ContextFactory.Instance.SaveChanges();
            PropertyController.CreateWorldEntity();
            API.shared.sendChatMessageToPlayer(player, "~g~Server: ~w~ Added a " + PropertyController.Type() + " owned by " + ownerName);
        }
예제 #2
0
        public static void LoadProperties()
        {
            foreach (var property in ContextFactory.Instance.Property.ToList())
            {
                PropertyController propertyController = new PropertyController(property);
                if (property.Group != null)
                {
                    propertyController.GroupController = EntityManager.GetGroup(property.Group.Id);
                    API.shared.consoleOutput("Loaded property " + property.PropertyID + " with group: " + propertyController.GroupController.Group.Name);
                    if (propertyController.GroupController != null)
                    {
                        string name = property.Group.Name;
                        if (name == null)
                        {
                            propertyController.ownername = "None";
                        }
                        else
                        {
                            propertyController.ownername = property.Name;
                        }

                        if (propertyController.GroupController.Group.Type == GroupType.Business) // If property's group is a business, initialize items.
                        {
                        }
                    }
                }
                else if (property.Character != null)
                {
                    string name = property.Character.Name;
                    if (name == null)
                    {
                        propertyController.ownername = "None";
                    }
                    else
                    {
                        propertyController.ownername = name.Replace("_", " ");
                    }
                }

                propertyController.CreateWorldEntity();
                EntityManager.Add(propertyController);
            }
            API.shared.consoleOutput("[GM] Loaded properties: " + ContextFactory.Instance.Property.Count());
        }