コード例 #1
0
        public static void StartFurnitureConversation()
        {
            var player = OBJECT_SELF;
            var area   = GetArea(player);
            var item   = StringToObject(Events.GetEventData("ITEM_OBJECT_ID"));

            if (!Housing.CanPlaceFurniture(player, item))
            {
                return;
            }

            Events.SkipEvent();

            var furnitureTypeId = (int)Housing.GetFurnitureTypeFromItem(item);
            var targetLocation  = Location(area,
                                           Vector(
                                               (float)Convert.ToDouble(Events.GetEventData("TARGET_POSITION_X")),
                                               (float)Convert.ToDouble(Events.GetEventData("TARGET_POSITION_Y")),
                                               (float)Convert.ToDouble(Events.GetEventData("TARGET_POSITION_Z"))),
                                           0.0f);

            SetLocalInt(player, "TEMP_FURNITURE_TYPE_ID", furnitureTypeId);
            SetLocalObject(player, "TEMP_FURNITURE_OBJECT", item);
            SetLocalLocation(player, "TEMP_FURNITURE_LOCATION", targetLocation);
            Dialog.StartConversation(player, player, nameof(PlayerHouseFurnitureDialog));
        }
コード例 #2
0
        private void PlaceFurniture()
        {
            var player = GetPC();
            var model  = GetDataModel <Model>();

            // Other players might have changed the state of the house since the conversation started.
            // Check everything again to make sure the furniture can still be placed.
            if (!Housing.CanPlaceFurniture(player, model.Item))
            {
                return;
            }

            var furnitureDetail = Housing.GetFurnitureDetail(model.FurnitureType);

            model.Placeable = CreateObject(ObjectType.Placeable, furnitureDetail.Resref, model.TargetLocation);
            DestroyObject(model.Item);
            model.HasBeenPlaced = true;

            // Persist the new furniture to the DB.
            var position = GetPositionFromLocation(model.TargetLocation);
            var dbHouse  = DB.Get <PlayerHouse>(model.OwnerUUID);

            var furnitureId = Guid.NewGuid().ToString();

            dbHouse.Furnitures[furnitureId] = new PlayerHouseFurniture
            {
                FurnitureType = model.FurnitureType,
                Orientation   = 0.0f,
                X             = position.X,
                Y             = position.Y,
                Z             = position.Z
            };

            DB.Set(model.OwnerUUID, dbHouse);

            // Add an Id pointer to the placeable.
            SetLocalString(model.Placeable, "HOUSING_FURNITURE_ID", furnitureId);
        }